From 35f376c8b5bcbd3d3550cbbc78b40a3d78648e75 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 16 Sep 2022 14:28:51 -0400 Subject: [PATCH] Fix bugs in excluding multiple zsweep zaddrs and report all excluded zsweep zaddrs in z_sweepstatus --- src/wallet/asyncrpcoperation_sweep.cpp | 13 +++++++------ src/wallet/rpcwallet.cpp | 7 +++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/wallet/asyncrpcoperation_sweep.cpp b/src/wallet/asyncrpcoperation_sweep.cpp index 46962564d..237af4cd3 100644 --- a/src/wallet/asyncrpcoperation_sweep.cpp +++ b/src/wallet/asyncrpcoperation_sweep.cpp @@ -80,15 +80,16 @@ bool IsExcludedAddress(libzcash::SaplingPaymentAddress zaddr) { auto zAddressExclude = DecodePaymentAddress(sweepExcludeAddress); if (boost::get(&zAddressExclude) != nullptr) { - sweepExcludeAddress = boost::get(zAddressExclude); + auto excludeAddress = boost::get(zAddressExclude); + if (excludeAddress == zaddr) { + return true; + } } else { // This is an invalid sapling zaddr - LogPrintf("%s: Invalid zsweepexclude zaddr %s, ignoring\n", opid, sweepExcludeAddress); + LogPrintf("%s: Invalid zsweepexclude zaddr %s, ignoring\n", sweepExcludeAddress); + continue; } - if (sweepExcludeAddress == entry.address) { - return true; - } } return false; @@ -142,7 +143,7 @@ bool AsyncRPCOperation_sweep::main_impl() { // Map all notes (zutxos) by address for (auto & entry : saplingEntries) { // do not need to sweep Excluded Addresses - if(IsExcludedAddress(entry.address) { + if(IsExcludedAddress(entry.address)) { continue; } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 246615a5a..a09f33e79 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3370,10 +3370,9 @@ UniValue z_sweepstatus(const UniValue& params, bool fHelp, const CPubKey& mypk) ret.push_back(Pair("zsweepinterval", pwalletMain->sweepInterval)); ret.push_back(Pair("zsweepaddress", pwalletMain->sweepAddress)); UniValue excludes(UniValue::VARR); - // BOOST_FOREACH(const std::string& exclude, pwalletMain->sweepExcludeAddresses ) { - // excludes.push_back(exclude); - // } - excludes.push_back( pwalletMain->sweepExcludeAddress ); + BOOST_FOREACH(const std::string& exclude, pwalletMain->sweepExcludeAddresses ) { + excludes.push_back(exclude); + } ret.push_back(Pair("zsweepexclude", excludes)); ret.push_back(Pair("zsweepmaxinputs", pwalletMain->sweepMaxInputs)); ret.push_back(Pair("zsweepfee", pwalletMain->sweepFee));