From 32bcfe2ce158fcb11f0e04ab2d2887668d0d2412 Mon Sep 17 00:00:00 2001 From: adityapk00 Date: Fri, 23 Nov 2018 19:18:47 -0800 Subject: [PATCH] Remove extra Tx fields --- src/mainwindow.cpp | 1 - src/mainwindow.h | 1 - src/sendtab.cpp | 6 +++--- src/turnstile.cpp | 4 ++-- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2594890..ed46021 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -573,7 +573,6 @@ void MainWindow::postToZBoard() { auto toAddr = topics[zb.topicsList->currentText()]; tx.toAddrs.push_back(ToFields{ toAddr, Settings::getZboardAmount(), memo, memo.toUtf8().toHex() }); tx.fee = Settings::getMinerFee(); - tx.sendChangeToSapling = false; json params = json::array(); rpc->fillTxJsonParams(params, tx); diff --git a/src/mainwindow.h b/src/mainwindow.h index 529ea6b..382b86e 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -23,7 +23,6 @@ struct Tx { QString fromAddr; QList toAddrs; double fee; - bool sendChangeToSapling; }; namespace Ui { diff --git a/src/sendtab.cpp b/src/sendtab.cpp index 24bc6b0..c02636d 100644 --- a/src/sendtab.cpp +++ b/src/sendtab.cpp @@ -395,7 +395,7 @@ Tx MainWindow::createTxFromSendPage() { tx.fee = Settings::getMinerFee(); } - if (sendChangeToSapling) { + if (Settings::getInstance()->getAutoShield() && sendChangeToSapling) { auto saplingAddr = std::find_if(rpc->getAllZAddresses()->begin(), rpc->getAllZAddresses()->end(), [=](auto i) -> bool { // We're finding a sapling address that is not one of the To addresses, because zcash doesn't allow duplicated addresses bool isSapling = Settings::getInstance()->isSaplingAddress(i); @@ -409,11 +409,11 @@ Tx MainWindow::createTxFromSendPage() { return true; }); + if (saplingAddr != rpc->getAllZAddresses()->end()) { - tx.sendChangeToSapling = sendChangeToSapling; double change = rpc->getAllBalances()->value(tx.fromAddr) - totalAmt - tx.fee; - QString changeMemo = "change from " + tx.fromAddr; + QString changeMemo = "Change from " + tx.fromAddr; tx.toAddrs.push_back( ToFields{*saplingAddr, change, changeMemo, changeMemo.toUtf8().toHex()} ); } } diff --git a/src/turnstile.cpp b/src/turnstile.cpp index d34bbdc..95b1bbe 100644 --- a/src/turnstile.cpp +++ b/src/turnstile.cpp @@ -304,7 +304,7 @@ void Turnstile::executeMigrationStep() { } // Create the Tx - auto tx = Tx{ nextStep->fromAddr, { to }, Settings::getMinerFee(), false }; + auto tx = Tx{ nextStep->fromAddr, { to }, Settings::getMinerFee() }; // And send it doSendTx(tx, [=] () { @@ -339,7 +339,7 @@ void Turnstile::executeMigrationStep() { QList to = { ToFields{ nextStep->destAddr, sendAmt, "", "" } }; // Create the Tx - auto tx = Tx{ nextStep->intTAddr, to, Settings::getMinerFee(), false }; + auto tx = Tx{ nextStep->intTAddr, to, Settings::getMinerFee()}; // And send it doSendTx(tx, [=] () {