1515#include " util.h"
1616#include " utilmoneystr.h"
1717#include " accumulatormap.h"
18+ #include " accumulators.h"
1819
1920#include < stdint.h>
2021#include < univalue.h>
@@ -929,6 +930,38 @@ UniValue findserial(const UniValue& params, bool fHelp)
929930 UniValue ret (UniValue::VOBJ);
930931 ret.push_back (Pair (" success" , fSuccess ));
931932 ret.push_back (Pair (" txid" , txid.GetHex ()));
932-
933933 return ret;
934934}
935+
936+ UniValue getaccumulatorvalues (const UniValue& params, bool fHelp )
937+ {
938+ if (fHelp || params.size () != 1 )
939+ throw runtime_error (
940+ " getaccumulatorvalues \" height\"\n "
941+ " \n Returns the accumulator values associated with a block height\n "
942+
943+ " \n Arguments:\n "
944+ " 1. height (numeric, required) the height of the checkpoint.\n "
945+
946+ " \n Examples:\n " +
947+ HelpExampleCli (" getaccumulatorvalues" , " \" height\" " ) + HelpExampleRpc (" getaccumulatorvalues" , " \" height\" " ));
948+
949+ int nHeight = params[0 ].get_int ();
950+
951+ CBlockIndex* pindex = chainActive[nHeight];
952+ if (!pindex)
953+ throw JSONRPCError (RPC_INVALID_PARAMETER, " invalid block height" );
954+
955+ UniValue ret (UniValue::VARR);
956+ for (libzerocoin::CoinDenomination denom : libzerocoin::zerocoinDenomList) {
957+ CBigNum bnValue;
958+ if (!GetAccumulatorValueFromDB (pindex->nAccumulatorCheckpoint , denom, bnValue))
959+ throw JSONRPCError (RPC_DATABASE_ERROR, " failed to find value in database" );
960+
961+ UniValue obj (UniValue::VOBJ);
962+ obj.push_back (Pair (std::to_string (denom), bnValue.GetHex ()));
963+ ret.push_back (obj);
964+ }
965+
966+ return ret;
967+ }
0 commit comments