diff --git a/src/init.cpp b/src/init.cpp index dd6666710..2827a2bb9 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -2086,6 +2086,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } auto hasSpendingKey = boost::apply_visitor(HaveSpendingKeyForPaymentAddress(pwalletMain), zSweep); auto allowSweepToExternalWallet = GetArg("-zsweepexternal", false); + pwalletMain->sweepAddress = vSweep[i]; if (!hasSpendingKey) { if (allowSweepToExternalWallet) { diff --git a/src/rpc/server.h b/src/rpc/server.h index b6a20b559..b2c361765 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -472,6 +472,7 @@ extern UniValue z_getbalance(const UniValue& params, bool fHelp, const CPubKey& extern UniValue z_gettotalbalance(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp extern UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp extern UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp +extern UniValue z_sweepstatus(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp extern UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp extern UniValue z_getoperationstatus(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp extern UniValue z_getoperationresult(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp diff --git a/src/wallet/asyncrpcoperation_sweep.cpp b/src/wallet/asyncrpcoperation_sweep.cpp index 140c9902a..a2b6a19c3 100644 --- a/src/wallet/asyncrpcoperation_sweep.cpp +++ b/src/wallet/asyncrpcoperation_sweep.cpp @@ -64,7 +64,7 @@ void AsyncRPCOperation_sweep::main() { set_state(OperationStatus::FAILED); } - std::string s = strprintf("%s: Sapling Sweep transaction created. (status=%s", getId(), getStateAsString()); + std::string s = strprintf("%s: Sweep transaction created. (status=%s", getId(), getStateAsString()); if (success) { s += strprintf(", success)\n"); } else { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 42a145b94..e596ed03f 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3315,6 +3315,48 @@ UniValue getalldata(const UniValue& params, bool fHelp,const CPubKey&) return returnObj; } +UniValue z_sweepstatus(const UniValue& params, bool fHelp, const CPubKey& mypk) +{ + + if (!EnsureWalletIsAvailable(fHelp)) + return NullUniValue; + + if (fHelp || params.size() > 0) + throw runtime_error( + "z_sweepstatus\n" + "\nGive details about zsweep operations since the node was started." + "}\n" + "\nExamples:\n" + + HelpExampleCli("z_sweepstatus", "") + + HelpExampleRpc("z_sweepstatus", "") + ); + + LOCK2(cs_main, pwalletMain->cs_wallet); + + UniValue ret(UniValue::VOBJ); + auto amount_swept; + ret.push_back(Pair("zsweep", pwalletMain->fSweepEnabled)); + ret.push_back(Pair("running", pwalletMain->fSweepRunning)); + ret.push_back(Pair("amount_swept", amount_swept)); + + if (pwalletMain->fConsolidationRunning) { + ret.push_back(Pair("next_zsweep", pwalletMain->sweepInterval + chainActive.Tip()->GetHeight())); + } else { + if (pwalletMain->nextConsolidation == 0) { + ret.push_back(Pair("next_zsweep", chainActive.Tip()->GetHeight() + 1)); + } else { + ret.push_back(Pair("next_zsweep", pwalletMain->nextSweep)); + } + } + ret.push_back(Pair("zsweepinterval", pwalletMain->sweepInterval)); + ret.push_back(Pair("zsweepaddress", pwalletMain->sweepAddress)); + ret.push_back(Pair("zsweepmaxinputs", pwalletMain->sweepMaxInputs)); + ret.push_back(Pair("zsweepfee", pwalletMain->sweepFee)); + ret.push_back(Pair("zsweepexternal", pwalletMain->fSweepExternalEnabled)); + + return ret; +} + UniValue z_listreceivedaddress(const UniValue& params, bool fHelp,const CPubKey&) { if (!EnsureWalletIsAvailable(fHelp)) diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index f633f2564..ada169c73 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -805,8 +805,12 @@ public: bool fSaplingConsolidationEnabled = false; bool fConsolidationRunning = false; bool fSweepEnabled = false; + bool fSweepExternalEnabled = false; bool fSweepRunning = false; - int nextSweep = 0; + int nextSweep = 0; + int sweepInterval = 20; + int sweepMaxInputs = 200; + std::string sweepAddress = ""; void ClearNoteWitnessCache();