Browse Source

Merge pull request #105 from DenioD/duke

add z_getnotescount as rpc call ported for Hush from https://github.c
pull/107/head
Duke Leto 4 years ago
committed by GitHub
parent
commit
edf1a1d3dc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      src/rpc/client.cpp
  2. 37
      src/wallet/rpcwallet.cpp

1
src/rpc/client.cpp

@ -139,6 +139,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "z_listunspent", 2 },
{ "z_listunspent", 3 },
{ "z_getbalance", 1},
{ "z_getnotescount", 0},
{ "z_gettotalbalance", 0},
{ "z_gettotalbalance", 1},
{ "z_gettotalbalance", 2},

37
src/wallet/rpcwallet.cpp

@ -4213,6 +4213,42 @@ UniValue z_getbalance(const UniValue& params, bool fHelp, const CPubKey& mypk)
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)
{
@ -8368,6 +8404,7 @@ static const CRPCCommand commands[] =
{ "wallet", "z_getinfo", &z_getinfo, true },
{ "wallet", "z_listsentbyaddress", &z_listsentbyaddress, true },
{ "wallet", "z_listreceivedbyaddress", &z_listreceivedbyaddress, true },
{ "wallet", "z_getnotescount", &z_getnotescount, false },
// TODO: rearrange into another category
{ "disclosure", "z_getpaymentdisclosure", &z_getpaymentdisclosure, true },
{ "disclosure", "z_validatepaymentdisclosure", &z_validatepaymentdisclosure, true }

Loading…
Cancel
Save