You might be a king or a little street zsweeper, but sooner or later you will dance with the reaper
This commit is contained in:
58
src/init.cpp
58
src/init.cpp
@@ -59,6 +59,7 @@
|
||||
#include "wallet/wallet.h"
|
||||
#include "wallet/walletdb.h"
|
||||
#include "wallet/asyncrpcoperation_saplingconsolidation.h"
|
||||
#include "wallet/asyncrpcoperation_sweep.h"
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
@@ -461,6 +462,16 @@ std::string HelpMessage(HelpMessageMode mode)
|
||||
strUsage += HelpMessageOpt("-consolidation", _("Enable auto Sapling note consolidation (default: false)"));
|
||||
strUsage += HelpMessageOpt("-consolidatesaplingaddress=<zaddr>", _("Specify Sapling Address to Consolidate. (default: all)"));
|
||||
strUsage += HelpMessageOpt("-consolidationtxfee", strprintf(_("Fee amount in Puposhis used send consolidation transactions. (default %i)"), DEFAULT_CONSOLIDATION_FEE));
|
||||
|
||||
strUsage += HelpMessageOpt("-zsweep", _("Enable zaddr sweeping, automatically move all shielded funds to a one address once per X blocks"));
|
||||
strUsage += HelpMessageOpt("-zsweepaddress=<zaddr>", _("Specify the shielded address where swept funds will be sent)"));
|
||||
strUsage += HelpMessageOpt("-zsweepfee", strprintf(_("Fee amount in puposhis used send sweep transactions. (default %i)"), DEFAULT_SWEEP_FEE));
|
||||
strUsage += HelpMessageOpt("-zsweepinterval", strprintf(_("Sweep shielded funds every X blocks (default %i)"), 5));
|
||||
strUsage += HelpMessageOpt("-zsweepmaxinputs", strprintf(_("Maximum number of shielded inputs to sweep per transaction (default %i)"), 8));
|
||||
// By default we only allow sweeping to the current wallet which must have the spending key of the sweep zaddr
|
||||
// This hopefully will make it harder for people to accidentally sweep funds to a wrong zaddr and lose funds
|
||||
strUsage += HelpMessageOpt("-zsweepexternal", _("Enable sweeping to an external wallet (default false)"));
|
||||
|
||||
strUsage += HelpMessageOpt("-deletetx", _("Enable Old Transaction Deletion"));
|
||||
strUsage += HelpMessageOpt("-deleteinterval", strprintf(_("Delete transaction every <n> blocks during inital block download (default: %i)"), DEFAULT_TX_DELETE_INTERVAL));
|
||||
strUsage += HelpMessageOpt("-keeptxnum", strprintf(_("Keep the last <n> transactions (default: %i)"), DEFAULT_TX_RETENTION_LASTTX));
|
||||
@@ -2054,6 +2065,53 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
}
|
||||
}
|
||||
|
||||
//Set Sweep
|
||||
pwalletMain->fSweepEnabled = GetBoolArg("-zsweep", false);
|
||||
|
||||
if (pwalletMain->fSweepEnabled) {
|
||||
fSweepTxFee = GetArg("-zsweepfee", DEFAULT_SWEEP_FEE);
|
||||
fSweepMapUsed = !mapMultiArgs["-zsweepaddress"].empty();
|
||||
|
||||
//Validate Sapling Addresses
|
||||
vector<string>& vSweep = mapMultiArgs["-zsweepaddress"];
|
||||
if (vSweep.size() != 1) {
|
||||
return InitError("A single zsweep address must be specified.");
|
||||
}
|
||||
|
||||
for (int i = 0; i < vSweep.size(); i++) {
|
||||
// LogPrintf("Sweep Address: %s\n", vSweep[i]);
|
||||
auto zSweep = DecodePaymentAddress(vSweep[i]);
|
||||
if (!IsValidPaymentAddress(zSweep)) {
|
||||
return InitError("Invalid zsweep address");
|
||||
}
|
||||
auto hasSpendingKey = boost::apply_visitor(HaveSpendingKeyForPaymentAddress(pwalletMain), zSweep);
|
||||
auto allowSweepToExternalWallet = GetArg("-zsweepexternal", false);
|
||||
|
||||
if (!hasSpendingKey) {
|
||||
if (allowSweepToExternalWallet) {
|
||||
LogPrintf("%s: sweeping funds to a zaddr in an external wallet\n", __func__);
|
||||
} else {
|
||||
return InitError("Wallet must have the spending key of zsweep address");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pwalletMain->fSaplingConsolidationEnabled) {
|
||||
//Validate 1 Consolidation address only that matches the sweep address
|
||||
vector<string>& vaddresses = mapMultiArgs["-consolidatesaplingaddress"];
|
||||
if (vaddresses.size() == 0) {
|
||||
fConsolidationMapUsed = true;
|
||||
mapMultiArgs["-consolidatesaplingaddress"] = vSweep;
|
||||
} else {
|
||||
for (int i = 0; i < vaddresses.size(); i++) {
|
||||
if (vSweep[0] != vaddresses[i]) {
|
||||
return InitError("Consolidation can only be used on the sweep address when sweep is enabled.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Set Transaction Deletion Options
|
||||
fTxDeleteEnabled = GetBoolArg("-deletetx", false);
|
||||
fTxConflictDeleteEnabled = GetBoolArg("-deleteconflicttx", true);
|
||||
|
||||
Reference in New Issue
Block a user