Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/mining.cpp
Show First 20 Lines • Show All 918 Lines • ▼ Show 20 Lines | static UniValue estimatefee(const Config &config, | ||||
CFeeRate feeRate = mempool.estimateFee(nBlocks); | CFeeRate feeRate = mempool.estimateFee(nBlocks); | ||||
if (feeRate == CFeeRate(Amount(0))) { | if (feeRate == CFeeRate(Amount(0))) { | ||||
return -1.0; | return -1.0; | ||||
} | } | ||||
return ValueFromAmount(feeRate.GetFeePerK()); | return ValueFromAmount(feeRate.GetFeePerK()); | ||||
} | } | ||||
static UniValue estimatepriority(const Config &config, | |||||
const JSONRPCRequest &request) { | |||||
if (request.fHelp || request.params.size() != 1) { | |||||
throw std::runtime_error( | |||||
"estimatepriority nblocks\n" | |||||
"\nDEPRECATED. Estimates the approximate priority " | |||||
"a zero-fee transaction needs to begin\n" | |||||
"confirmation within nblocks blocks.\n" | |||||
"\nArguments:\n" | |||||
"1. nblocks (numeric, required)\n" | |||||
"\nResult:\n" | |||||
"n (numeric) estimated priority\n" | |||||
"\n" | |||||
"A negative value is returned if not enough " | |||||
"transactions and blocks\n" | |||||
"have been observed to make an estimate.\n" | |||||
"\nExample:\n" + | |||||
HelpExampleCli("estimatepriority", "6")); | |||||
} | |||||
RPCTypeCheck(request.params, {UniValue::VNUM}); | |||||
int nBlocks = request.params[0].get_int(); | |||||
if (nBlocks < 1) { | |||||
nBlocks = 1; | |||||
} | |||||
return mempool.estimatePriority(nBlocks); | |||||
} | |||||
static UniValue estimatesmartfee(const Config &config, | static UniValue estimatesmartfee(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 1) { | if (request.fHelp || request.params.size() != 1) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"estimatesmartfee nblocks\n" | "estimatesmartfee nblocks\n" | ||||
"\nWARNING: This interface is unstable and may disappear or " | "\nWARNING: This interface is unstable and may disappear or " | ||||
"change!\n" | "change!\n" | ||||
"\nEstimates the approximate fee per kilobyte needed for a " | "\nEstimates the approximate fee per kilobyte needed for a " | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | static const CRPCCommand commands[] = { | ||||
{"mining", "getmininginfo", getmininginfo, true, {}}, | {"mining", "getmininginfo", getmininginfo, true, {}}, | ||||
{"mining", "prioritisetransaction", prioritisetransaction, true, {"txid", "priority_delta", "fee_delta"}}, | {"mining", "prioritisetransaction", prioritisetransaction, true, {"txid", "priority_delta", "fee_delta"}}, | ||||
{"mining", "getblocktemplate", getblocktemplate, true, {"template_request"}}, | {"mining", "getblocktemplate", getblocktemplate, true, {"template_request"}}, | ||||
{"mining", "submitblock", submitblock, true, {"hexdata", "parameters"}}, | {"mining", "submitblock", submitblock, true, {"hexdata", "parameters"}}, | ||||
{"generating", "generatetoaddress", generatetoaddress, true, {"nblocks", "address", "maxtries"}}, | {"generating", "generatetoaddress", generatetoaddress, true, {"nblocks", "address", "maxtries"}}, | ||||
{"util", "estimatefee", estimatefee, true, {"nblocks"}}, | {"util", "estimatefee", estimatefee, true, {"nblocks"}}, | ||||
{"util", "estimatepriority", estimatepriority, true, {"nblocks"}}, | |||||
{"util", "estimatesmartfee", estimatesmartfee, true, {"nblocks"}}, | {"util", "estimatesmartfee", estimatesmartfee, true, {"nblocks"}}, | ||||
{"util", "estimatesmartpriority", estimatesmartpriority, true, {"nblocks"}}, | {"util", "estimatesmartpriority", estimatesmartpriority, true, {"nblocks"}}, | ||||
}; | }; | ||||
// clang-format on | // clang-format on | ||||
void RegisterMiningRPCCommands(CRPCTable &t) { | void RegisterMiningRPCCommands(CRPCTable &t) { | ||||
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) | for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) | ||||
t.appendCommand(commands[vcidx].name, &commands[vcidx]); | t.appendCommand(commands[vcidx].name, &commands[vcidx]); | ||||
} | } |