Skip to content

Commit

Permalink
[RPC] Introduce getbestsaplinganchor to get the most recent sapling root
Browse files Browse the repository at this point in the history
  • Loading branch information
random-zebra committed Nov 14, 2020
1 parent a0afd9f commit 101978d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,22 @@ UniValue getbestblockhash(const JSONRPCRequest& request)
return chainActive.Tip()->GetBlockHash().GetHex();
}

UniValue getbestsaplinganchor(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() != 0)
throw std::runtime_error(
"getbestsaplinganchor\n"
"\nReturns the most recent SaplingMerkleTree root.\n"

"\nResult\n"
"\"hex\" (string) the sapling anchor hex encoded\n"

"\nExamples\n" +
HelpExampleCli("getbestsaplinganchor", "") + HelpExampleRpc("getbestsaplinganchor", ""));

return pcoinsTip->GetBestAnchor().ToString();
}

void RPCNotifyBlockChange(bool fInitialDownload, const CBlockIndex* pindex)
{
if(pindex) {
Expand Down Expand Up @@ -1621,6 +1637,7 @@ static const CRPCCommand commands[] =
{ "blockchain", "getblockindexstats", &getblockindexstats, true },
{ "blockchain", "getblockchaininfo", &getblockchaininfo, true },
{ "blockchain", "getbestblockhash", &getbestblockhash, true },
{ "blockchain", "getbestsaplinganchor", &getbestsaplinganchor, true },
{ "blockchain", "getblockcount", &getblockcount, true },
{ "blockchain", "getblock", &getblock, true },
{ "blockchain", "getblockhash", &getblockhash, true },
Expand Down

0 comments on commit 101978d

Please sign in to comment.