Handle 0 change case
This commit is contained in:
@@ -413,8 +413,10 @@ Tx MainWindow::createTxFromSendPage() {
|
||||
if (saplingAddr != rpc->getAllZAddresses()->end()) {
|
||||
double change = rpc->getAllBalances()->value(tx.fromAddr) - totalAmt - tx.fee;
|
||||
|
||||
QString changeMemo = "Change from " + tx.fromAddr;
|
||||
tx.toAddrs.push_back( ToFields{*saplingAddr, change, changeMemo, changeMemo.toUtf8().toHex()} );
|
||||
if (Settings::getDecimalString(change) != "0") {
|
||||
QString changeMemo = "Change from " + tx.fromAddr;
|
||||
tx.toAddrs.push_back(ToFields{ *saplingAddr, change, changeMemo, changeMemo.toUtf8().toHex() });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -143,9 +143,12 @@ QString Settings::getUSDFormat(double bal) {
|
||||
|
||||
QString Settings::getDecimalString(double amt) {
|
||||
QString f = QString::number(amt, 'f', 8);
|
||||
|
||||
while (f.contains(".") && (f.right(1) == "0" || f.right(1) == ".")) {
|
||||
f = f.left(f.length() - 1);
|
||||
}
|
||||
if (f == "-0")
|
||||
f = "0";
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user