Add getblocksubsidy RPC command to return the block reward for a given
block, taking into account the mining slow start.
This commit is contained in:
@@ -95,7 +95,8 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
||||
{ "zcrawpour", 2 },
|
||||
{ "zcrawpour", 3 },
|
||||
{ "zcrawpour", 4 },
|
||||
{ "zcbenchmark", 1 }
|
||||
{ "zcbenchmark", 1 },
|
||||
{ "getblocksubsidy", 0}
|
||||
};
|
||||
|
||||
class CRPCConvertTable
|
||||
|
||||
@@ -766,3 +766,27 @@ Value estimatepriority(const Array& params, bool fHelp)
|
||||
|
||||
return mempool.estimatePriority(nBlocks);
|
||||
}
|
||||
|
||||
Value getblocksubsidy(const Array& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() != 1)
|
||||
throw runtime_error(
|
||||
"getblocksubsidy index\n"
|
||||
"\nReturns block subsidy reward, taking into account the mining slow start, of block at index provided.\n"
|
||||
"\nArguments:\n"
|
||||
"1. index (numeric, required) The block index\n"
|
||||
"\nResult:\n"
|
||||
"amount (numeric) The block reward amount in ZEC.\n"
|
||||
"\nExamples:\n"
|
||||
+ HelpExampleCli("getblocksubsidy", "1000")
|
||||
+ HelpExampleRpc("getblockubsidy", "1000")
|
||||
);
|
||||
|
||||
LOCK(cs_main);
|
||||
int nHeight = params[0].get_int();
|
||||
if (nHeight < 0 || nHeight > chainActive.Height())
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range");
|
||||
|
||||
CAmount nReward = GetBlockSubsidy(nHeight, Params().GetConsensus());
|
||||
return ValueFromAmount(nReward);
|
||||
}
|
||||
|
||||
@@ -304,6 +304,7 @@ static const CRPCCommand vRPCCommands[] =
|
||||
{ "mining", "getnetworkhashps", &getnetworkhashps, true },
|
||||
{ "mining", "prioritisetransaction", &prioritisetransaction, true },
|
||||
{ "mining", "submitblock", &submitblock, true },
|
||||
{ "mining", "getblocksubsidy", &getblocksubsidy, true },
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
/* Coin generation */
|
||||
|
||||
@@ -240,6 +240,8 @@ extern json_spirit::Value getchaintips(const json_spirit::Array& params, bool fH
|
||||
extern json_spirit::Value invalidateblock(const json_spirit::Array& params, bool fHelp);
|
||||
extern json_spirit::Value reconsiderblock(const json_spirit::Array& params, bool fHelp);
|
||||
|
||||
extern json_spirit::Value getblocksubsidy(const json_spirit::Array& params, bool fHelp);
|
||||
|
||||
// in rest.cpp
|
||||
extern bool HTTPReq_REST(AcceptedConnection *conn,
|
||||
const std::string& strURI,
|
||||
|
||||
Reference in New Issue
Block a user