add z_getnotescount as rpc call ported for Hush from https://github.com/zcash/zcash/pull/4465
This commit is contained in:
@@ -139,6 +139,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
|||||||
{ "z_listunspent", 2 },
|
{ "z_listunspent", 2 },
|
||||||
{ "z_listunspent", 3 },
|
{ "z_listunspent", 3 },
|
||||||
{ "z_getbalance", 1},
|
{ "z_getbalance", 1},
|
||||||
|
{ "z_getnotescount", 0},
|
||||||
{ "z_gettotalbalance", 0},
|
{ "z_gettotalbalance", 0},
|
||||||
{ "z_gettotalbalance", 1},
|
{ "z_gettotalbalance", 1},
|
||||||
{ "z_gettotalbalance", 2},
|
{ "z_gettotalbalance", 2},
|
||||||
|
|||||||
@@ -4213,6 +4213,42 @@ UniValue z_getbalance(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
|||||||
return ValueFromAmount(nBalance);
|
return ValueFromAmount(nBalance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UniValue z_getnotescount(const UniValue& params, bool fHelp,const CPubKey& mypk)
|
||||||
|
{
|
||||||
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
|
return NullUniValue;
|
||||||
|
|
||||||
|
if (fHelp || params.size() > 1)
|
||||||
|
throw runtime_error(
|
||||||
|
"z_getnotescount\n"
|
||||||
|
"\nArguments:\n"
|
||||||
|
"1. minconf (numeric, optional, default=1) Only include notes in transactions confirmed at least this many times.\n"
|
||||||
|
"\nReturns the number of sprout and sapling notes available in the wallet.\n"
|
||||||
|
"\nResult:\n"
|
||||||
|
"{\n"
|
||||||
|
" \"sapling\" (numeric) the number of sapling notes in the wallet\n"
|
||||||
|
"}\n"
|
||||||
|
"\nExamples:\n"
|
||||||
|
+ HelpExampleCli("z_getnotescount", "0")
|
||||||
|
);
|
||||||
|
|
||||||
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
|
|
||||||
|
int nMinDepth = 1;
|
||||||
|
if (params.size() > 0)
|
||||||
|
nMinDepth = params[0].get_int();
|
||||||
|
|
||||||
|
int sapling = 0;
|
||||||
|
for (auto& wtx : pwalletMain->mapWallet) {
|
||||||
|
if (wtx.second.GetDepthInMainChain() >= nMinDepth) {
|
||||||
|
sapling += wtx.second.mapSaplingNoteData.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UniValue ret(UniValue::VOBJ);
|
||||||
|
ret.push_back(Pair("sapling", sapling));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
UniValue z_gettotalbalance(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
UniValue z_gettotalbalance(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||||
{
|
{
|
||||||
@@ -8368,6 +8404,7 @@ static const CRPCCommand commands[] =
|
|||||||
{ "wallet", "z_getinfo", &z_getinfo, true },
|
{ "wallet", "z_getinfo", &z_getinfo, true },
|
||||||
{ "wallet", "z_listsentbyaddress", &z_listsentbyaddress, true },
|
{ "wallet", "z_listsentbyaddress", &z_listsentbyaddress, true },
|
||||||
{ "wallet", "z_listreceivedbyaddress", &z_listreceivedbyaddress, true },
|
{ "wallet", "z_listreceivedbyaddress", &z_listreceivedbyaddress, true },
|
||||||
|
{ "wallet", "z_getnotescount", &z_getnotescount, false },
|
||||||
// TODO: rearrange into another category
|
// TODO: rearrange into another category
|
||||||
{ "disclosure", "z_getpaymentdisclosure", &z_getpaymentdisclosure, true },
|
{ "disclosure", "z_getpaymentdisclosure", &z_getpaymentdisclosure, true },
|
||||||
{ "disclosure", "z_validatepaymentdisclosure", &z_validatepaymentdisclosure, true }
|
{ "disclosure", "z_validatepaymentdisclosure", &z_validatepaymentdisclosure, true }
|
||||||
|
|||||||
Reference in New Issue
Block a user