Support multiple zsweepexclude zaddrs
This commit is contained in:
@@ -2121,17 +2121,17 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
|
|
||||||
for (int i = 0; i < vSweepExclude.size(); i++) {
|
for (int i = 0; i < vSweepExclude.size(); i++) {
|
||||||
LogPrintf("Sweep Excluded Address: %s\n", vSweepExclude[i]);
|
LogPrintf("Sweep Excluded Address: %s\n", vSweepExclude[i]);
|
||||||
pwalletMain->sweepExcludeAddress = vSweepExclude[i];
|
|
||||||
auto zSweepExcluded = DecodePaymentAddress(vSweepExclude[i]);
|
auto zSweepExcluded = DecodePaymentAddress(vSweepExclude[i]);
|
||||||
if (!IsValidPaymentAddress(zSweepExcluded)) {
|
if (!IsValidPaymentAddress(zSweepExcluded)) {
|
||||||
return InitError("Invalid zsweep address");
|
return InitError("Invalid zsweep address");
|
||||||
}
|
}
|
||||||
auto hasSpendingKey = boost::apply_visitor(HaveSpendingKeyForPaymentAddress(pwalletMain), zSweepExcluded);
|
auto hasSpendingKey = boost::apply_visitor(HaveSpendingKeyForPaymentAddress(pwalletMain), zSweepExcluded);
|
||||||
pwalletMain->sweepExcludeAddress = vSweepExclude[i];
|
|
||||||
|
|
||||||
if (!hasSpendingKey) {
|
if (!hasSpendingKey) {
|
||||||
return InitError("Wallet must have the spending key of zsweepexclude address");
|
return InitError("Wallet must have the spending key of zsweepexclude address");
|
||||||
}
|
}
|
||||||
|
// Add this validated zaddr to the list of excluded sweep zaddrs
|
||||||
|
pwalletMain->sweepExcludeAddresses.push_back( vSweepExclude[i] );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pwalletMain->fSaplingConsolidationEnabled) {
|
if (pwalletMain->fSaplingConsolidationEnabled) {
|
||||||
|
|||||||
@@ -74,6 +74,26 @@ void AsyncRPCOperation_sweep::main() {
|
|||||||
LogPrintf("%s", s);
|
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 AsyncRPCOperation_sweep::main_impl() {
|
||||||
bool status=true;
|
bool status=true;
|
||||||
auto opid=getId();
|
auto opid=getId();
|
||||||
@@ -88,7 +108,6 @@ bool AsyncRPCOperation_sweep::main_impl() {
|
|||||||
|
|
||||||
std::vector<SaplingNoteEntry> saplingEntries;
|
std::vector<SaplingNoteEntry> saplingEntries;
|
||||||
libzcash::SaplingPaymentAddress sweepAddress;
|
libzcash::SaplingPaymentAddress sweepAddress;
|
||||||
libzcash::SaplingPaymentAddress sweepExcludeAddress;
|
|
||||||
std::map<libzcash::SaplingPaymentAddress, std::vector<SaplingNoteEntry>> mapAddresses;
|
std::map<libzcash::SaplingPaymentAddress, std::vector<SaplingNoteEntry>> mapAddresses;
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -96,16 +115,15 @@ bool AsyncRPCOperation_sweep::main_impl() {
|
|||||||
pwalletMain->GetFilteredNotes(saplingEntries, "", 11);
|
pwalletMain->GetFilteredNotes(saplingEntries, "", 11);
|
||||||
|
|
||||||
if (!fromRPC_) {
|
if (!fromRPC_) {
|
||||||
auto zAddressExclude = DecodePaymentAddress(pwalletMain->sweepExcludeAddress);
|
|
||||||
if (boost::get<libzcash::SaplingPaymentAddress>(&zAddressExclude) != nullptr) {
|
|
||||||
sweepExcludeAddress = boost::get<libzcash::SaplingPaymentAddress>(zAddressExclude);
|
|
||||||
}
|
|
||||||
if (fSweepMapUsed) {
|
if (fSweepMapUsed) {
|
||||||
const vector<string>& v = mapMultiArgs["-zsweepaddress"];
|
const vector<string>& v = mapMultiArgs["-zsweepaddress"];
|
||||||
for(int i = 0; i < v.size(); i++) {
|
for(int i = 0; i < v.size(); i++) {
|
||||||
auto zAddress = DecodePaymentAddress(v[i]);
|
auto zAddress = DecodePaymentAddress(v[i]);
|
||||||
if (boost::get<libzcash::SaplingPaymentAddress>(&zAddress) != nullptr) {
|
if (boost::get<libzcash::SaplingPaymentAddress>(&zAddress) != nullptr) {
|
||||||
sweepAddress = boost::get<libzcash::SaplingPaymentAddress>(zAddress);
|
sweepAddress = boost::get<libzcash::SaplingPaymentAddress>(zAddress);
|
||||||
|
} else {
|
||||||
|
LogPrintf("%s: Invalid zsweepaddress configured, exiting\n", opid);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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) {
|
for (auto & entry : saplingEntries) {
|
||||||
// do not need to sweep Excluded Address
|
// do not need to sweep Excluded Addresses
|
||||||
if (sweepExcludeAddress == entry.address) { continue; }
|
if(IsExcludedAddress(entry.address) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// do not need to sweep the sweepAddress as that is the destination
|
// do not need to sweep the sweepAddress as that is the destination
|
||||||
if (sweepAddress == entry.address) {
|
if (sweepAddress == entry.address) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -815,7 +815,7 @@ public:
|
|||||||
int sweepFee = 10000;
|
int sweepFee = 10000;
|
||||||
int sweepMaxInputs = 200;
|
int sweepMaxInputs = 200;
|
||||||
std::string sweepAddress = "";
|
std::string sweepAddress = "";
|
||||||
std::string sweepExcludeAddress = "";
|
std::vector<std::string> sweepExcludeAddresses = "";
|
||||||
std::string consolidationAddress = "";
|
std::string consolidationAddress = "";
|
||||||
|
|
||||||
void ClearNoteWitnessCache();
|
void ClearNoteWitnessCache();
|
||||||
|
|||||||
Reference in New Issue
Block a user