Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/mining.cpp
Show First 20 Lines • Show All 768 Lines • ▼ Show 20 Lines | if (!sc.found) { | ||||
return "inconclusive"; | return "inconclusive"; | ||||
} | } | ||||
return BIP22ValidationResult(config, sc.state); | return BIP22ValidationResult(config, sc.state); | ||||
} | } | ||||
static UniValue estimatefee(const Config &config, | static UniValue estimatefee(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( | ||||
"estimatefee nblocks\n" | "estimatefee\n" | ||||
"\nEstimates the approximate fee per kilobyte needed for a " | "\nEstimates the approximate fee per kilobyte needed for a " | ||||
"transaction to begin\n" | "transaction\n" | ||||
"confirmation within nblocks blocks.\n" | |||||
"\nArguments:\n" | |||||
"1. nblocks (numeric, required)\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"n (numeric) estimated fee-per-kilobyte\n" | "n (numeric) estimated fee-per-kilobyte\n" | ||||
"\n" | |||||
"A negative value is returned if not enough transactions and " | |||||
"blocks\n" | |||||
"have been observed to make an estimate.\n" | |||||
"-1 is always returned for nblocks == 1 as it is impossible to " | |||||
"calculate\n" | |||||
"a fee that is high enough to get reliably included in the next " | |||||
"block.\n" | |||||
"\nExample:\n" + | "\nExample:\n" + | ||||
HelpExampleCli("estimatefee", "6")); | HelpExampleCli("estimatefee", "")); | ||||
} | } | ||||
RPCTypeCheck(request.params, {UniValue::VNUM}); | if ((request.params.size() == 1) && | ||||
!IsDeprecatedRPCEnabled(gArgs, "estimatefee")) { | |||||
CFeeRate feeRate = g_mempool.estimateFee(); | // FIXME: Remove this message in 0.20 | ||||
if (feeRate == CFeeRate(Amount::zero())) { | throw JSONRPCError( | ||||
return -1.0; | RPC_METHOD_DEPRECATED, | ||||
"estimatefee with the nblocks argument is no longer supported\n" | |||||
"Please call estimatefee with no arguments instead.\n" | |||||
"\nExample:\n" + | |||||
HelpExampleCli("estimatefee", "")); | |||||
} | } | ||||
return ValueFromAmount(feeRate.GetFeePerK()); | return ValueFromAmount(g_mempool.estimateFee().GetFeePerK()); | ||||
} | } | ||||
// clang-format off | // clang-format off | ||||
static const ContextFreeRPCCommand commands[] = { | static const ContextFreeRPCCommand commands[] = { | ||||
// category name actor (function) argNames | // category name actor (function) argNames | ||||
// ---------- ------------------------ ---------------------- ---------- | // ---------- ------------------------ ---------------------- ---------- | ||||
{"mining", "getnetworkhashps", getnetworkhashps, {"nblocks", "height"}}, | {"mining", "getnetworkhashps", getnetworkhashps, {"nblocks", "height"}}, | ||||
{"mining", "getmininginfo", getmininginfo, {}}, | {"mining", "getmininginfo", getmininginfo, {}}, | ||||
Show All 14 Lines |