Add z_consolidationstatus RPC

This commit is contained in:
Jonathan "Duke" Leto
2022-09-06 05:55:03 -07:00
parent ed1939929b
commit 5c8c7507ec
4 changed files with 43 additions and 0 deletions

View File

@@ -473,6 +473,7 @@ extern UniValue z_gettotalbalance(const UniValue& params, bool fHelp, const CPub
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_consolidationstatus(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

View File

@@ -108,6 +108,7 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() {
if (boost::get<libzcash::SaplingPaymentAddress>(&zAddress) != nullptr) {
libzcash::SaplingPaymentAddress saplingAddress = boost::get<libzcash::SaplingPaymentAddress>(zAddress);
addresses.insert(saplingAddress);
consolidationAddress = zAddress;
} else {
LogPrintf("%s: Invalid zaddr, exiting\n", opid);
return false;

View File

@@ -3315,6 +3315,45 @@ UniValue getalldata(const UniValue& params, bool fHelp,const CPubKey&)
return returnObj;
}
UniValue z_consolidationstatus(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
if (!EnsureWalletIsAvailable(fHelp))
return NullUniValue;
if (fHelp || params.size() > 0)
throw runtime_error(
"z_consolidationstatus\n"
"\nGive details about consolidation operations since the node was started."
"}\n"
"\nExamples:\n"
+ HelpExampleCli("z_consolidationstatus", "")
+ HelpExampleRpc("z_consolidationstatus", "")
);
LOCK2(cs_main, pwalletMain->cs_wallet);
UniValue ret(UniValue::VOBJ);
ret.push_back(Pair("consolidation", pwalletMain->fConsolidationEnabled));
ret.push_back(Pair("running", pwalletMain->fConsolidationRunning));
ret.push_back(Pair("amount_consolidated", pwalletMain->amountConsolidated));
if (pwalletMain->fConsolidationRunning) {
ret.push_back(Pair("next_consolidation", pwalletMain->consolidationInterval + chainActive.Tip()->GetHeight()));
} else {
if (pwalletMain->nextConsolidation == 0) {
ret.push_back(Pair("next_consolidation", chainActive.Tip()->GetHeight() + 1));
} else {
ret.push_back(Pair("next_consolidation", pwalletMain->nextConsolidation));
}
}
ret.push_back(Pair("consolidationinterval", pwalletMain->consolidationInterval));
ret.push_back(Pair("consolidationaddress", pwalletMain->consolidationAddress));
ret.push_back(Pair("consolidationtxfee",(int)fConsolidationTxFee));
return ret;
}
UniValue z_sweepstatus(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
@@ -8537,6 +8576,7 @@ static const CRPCCommand commands[] =
{ "wallet", "z_gettotalbalance", &z_gettotalbalance, false },
{ "wallet", "z_mergetoaddress", &z_mergetoaddress, false },
{ "wallet", "z_sweepstatus", &z_sweepstatus, true },
{ "wallet", "z_consolidationstatus", &z_consolidationstatus, true },
{ "wallet", "z_sendmany", &z_sendmany, false },
{ "wallet", "z_shieldcoinbase", &z_shieldcoinbase, false },
{ "wallet", "z_getoperationstatus", &z_getoperationstatus, true },

View File

@@ -813,6 +813,7 @@ public:
int sweepFee = 10000;
int sweepMaxInputs = 200;
std::string sweepAddress = "";
std::string consolidationAddress = "";
void ClearNoteWitnessCache();