Support multiple zsweepexclude zaddrs
This commit is contained in:
@@ -74,6 +74,26 @@ void AsyncRPCOperation_sweep::main() {
|
||||
LogPrintf("%s", s);
|
||||
}
|
||||
|
||||
// Is this zaddr excluded from zsweep ?
|
||||
bool IsExcludedAddress(libzcash::SaplingPaymentAddress zaddr) {
|
||||
for( auto & sweepExcludeAddress : pwalletMain->sweepExcludeAddresses ) {
|
||||
auto zAddressExclude = DecodePaymentAddress(sweepExcludeAddress);
|
||||
|
||||
if (boost::get<libzcash::SaplingPaymentAddress>(&zAddressExclude) != nullptr) {
|
||||
sweepExcludeAddress = boost::get<libzcash::SaplingPaymentAddress>(zAddressExclude);
|
||||
} else {
|
||||
// This is an invalid sapling zaddr
|
||||
LogPrintf("%s: Invalid zsweepexclude zaddr %s, ignoring\n", opid, sweepExcludeAddress);
|
||||
}
|
||||
|
||||
if (sweepExcludeAddress == entry.address) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AsyncRPCOperation_sweep::main_impl() {
|
||||
bool status=true;
|
||||
auto opid=getId();
|
||||
@@ -88,7 +108,6 @@ bool AsyncRPCOperation_sweep::main_impl() {
|
||||
|
||||
std::vector<SaplingNoteEntry> saplingEntries;
|
||||
libzcash::SaplingPaymentAddress sweepAddress;
|
||||
libzcash::SaplingPaymentAddress sweepExcludeAddress;
|
||||
std::map<libzcash::SaplingPaymentAddress, std::vector<SaplingNoteEntry>> mapAddresses;
|
||||
|
||||
{
|
||||
@@ -96,16 +115,15 @@ bool AsyncRPCOperation_sweep::main_impl() {
|
||||
pwalletMain->GetFilteredNotes(saplingEntries, "", 11);
|
||||
|
||||
if (!fromRPC_) {
|
||||
auto zAddressExclude = DecodePaymentAddress(pwalletMain->sweepExcludeAddress);
|
||||
if (boost::get<libzcash::SaplingPaymentAddress>(&zAddressExclude) != nullptr) {
|
||||
sweepExcludeAddress = boost::get<libzcash::SaplingPaymentAddress>(zAddressExclude);
|
||||
}
|
||||
if (fSweepMapUsed) {
|
||||
const vector<string>& v = mapMultiArgs["-zsweepaddress"];
|
||||
for(int i = 0; i < v.size(); i++) {
|
||||
auto zAddress = DecodePaymentAddress(v[i]);
|
||||
if (boost::get<libzcash::SaplingPaymentAddress>(&zAddress) != nullptr) {
|
||||
sweepAddress = boost::get<libzcash::SaplingPaymentAddress>(zAddress);
|
||||
} else {
|
||||
LogPrintf("%s: Invalid zsweepaddress configured, exiting\n", opid);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -121,10 +139,13 @@ bool AsyncRPCOperation_sweep::main_impl() {
|
||||
}
|
||||
}
|
||||
|
||||
// Map all notes by address
|
||||
// Map all notes (zutxos) by address
|
||||
for (auto & entry : saplingEntries) {
|
||||
// do not need to sweep Excluded Address
|
||||
if (sweepExcludeAddress == entry.address) { continue; }
|
||||
// do not need to sweep Excluded Addresses
|
||||
if(IsExcludedAddress(entry.address) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// do not need to sweep the sweepAddress as that is the destination
|
||||
if (sweepAddress == entry.address) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user