Skip to content

Commit

Permalink
[RPC] Add shieldedsupply to getsupplyinfo and getinfo
Browse files Browse the repository at this point in the history
rename moneysupply to transparentsupply
  • Loading branch information
random-zebra committed Nov 23, 2020
1 parent 18ee5ce commit c764f02
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,9 @@ UniValue getsupplyinfo(const JSONRPCRequest& request)

"\nResult:\n"
"{\n"
" \"updateheight\" : n, (numeric) The chain height when the supply was updated\n"
" \"supply\" : n (numeric) The sum of all spendable transaction outputs at height updateheight\n"
" \"updateheight\" : n, (numeric) The chain height when the transparent supply was updated\n"
" \"transparentsupply\" : n (numeric) The sum of all spendable transaction outputs at height updateheight\n"
" \"shieldedsupply\": n (numeric) Chain tip shielded pool value\n"
"}\n"

"\nExamples:\n" +
Expand All @@ -665,7 +666,9 @@ UniValue getsupplyinfo(const JSONRPCRequest& request)

UniValue ret(UniValue::VOBJ);
ret.pushKV("updateheight", MoneySupply.GetCacheHeight());
ret.pushKV("supply", ValueFromAmount(MoneySupply.Get()));
ret.pushKV("transparentsupply", ValueFromAmount(MoneySupply.Get()));
Optional<CAmount> shieldedPoolValue = WITH_LOCK(cs_main, return (chainActive.Tip() ? chainActive.Tip()->nChainSaplingValue : nullopt); );
ret.pushKV("shieldedsupply", ValuePoolDesc(shieldedPoolValue, nullopt)["chainValue"]);

return ret;
}
Expand Down
8 changes: 5 additions & 3 deletions src/rpc/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ UniValue getinfo(const JSONRPCRequest& request)
" \"proxy\": \"host:port\", (string, optional) the proxy used by the server\n"
" \"difficulty\": xxxxxx, (numeric) the current difficulty\n"
" \"testnet\": true|false, (boolean) if the server is using testnet or not\n"
" \"moneysupply\" : \"supply\" (numeric) The sum of the value of all unspent outputs when the chainstate was\n"
" \"transparentsupply\" : n (numeric) The sum of the value of all unspent outputs when the chainstate was\n"
" last flushed to disk (use getsupplyinfo to know the update-height, or\n"
" to trigger the money supply update/recalculation)"
" \"shieldedsupply\": n (numeric) Chain tip shielded pool value\n"
" \"zPIVsupply\" :\n"
" {\n"
" \"1\" : n, (numeric) supply of 1 zPIV denomination\n"
Expand Down Expand Up @@ -143,7 +144,8 @@ UniValue getinfo(const JSONRPCRequest& request)

// Add (cached) money supply via getsupplyinfo RPC
UniValue supply_info = getsupplyinfo(JSONRPCRequest());
obj.pushKV("moneysupply", supply_info["supply"]);
obj.pushKV("transparentsupply", supply_info["transparentsupply"]);
obj.pushKV("shieldedsupply", supply_info["shieldedsupply"]);

UniValue zpivObj(UniValue::VOBJ);
for (auto denom : libzerocoin::zerocoinDenomList) {
Expand Down Expand Up @@ -743,4 +745,4 @@ void RegisterMiscRPCCommands(CRPCTable &tableRPC)
{
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
tableRPC.appendCommand(commands[vcidx].name, &commands[vcidx]);
}
}

0 comments on commit c764f02

Please sign in to comment.