Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/mining.cpp
Show First 20 Lines • Show All 233 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() != 0) { | ||||
" \"difficulty\": xxx.xxxxx (numeric) The current difficulty\n" | " \"difficulty\": xxx.xxxxx (numeric) The current difficulty\n" | ||||
" \"networkhashps\": nnn, (numeric) The network hashes per " | " \"networkhashps\": nnn, (numeric) The network hashes per " | ||||
"second\n" | "second\n" | ||||
" \"pooledtx\": n (numeric) The size of the mempool\n" | " \"pooledtx\": n (numeric) The size of the mempool\n" | ||||
" \"chain\": \"xxxx\", (string) current network name as " | " \"chain\": \"xxxx\", (string) current network name as " | ||||
"defined in BIP70 (main, test, regtest)\n" | "defined in BIP70 (main, test, regtest)\n" | ||||
" \"warnings\": \"...\" (string) any network and " | " \"warnings\": \"...\" (string) any network and " | ||||
"blockchain warnings\n" | "blockchain warnings\n" | ||||
" \"errors\": \"...\" (string) DEPRECATED. Same as " | |||||
"warnings. Only shown when bitcoind is started with " | |||||
"-deprecatedrpc=getmininginfo\n" | |||||
"}\n" | "}\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("getmininginfo", "") + | HelpExampleCli("getmininginfo", "") + | ||||
HelpExampleRpc("getmininginfo", "")); | HelpExampleRpc("getmininginfo", "")); | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
UniValue obj(UniValue::VOBJ); | UniValue obj(UniValue::VOBJ); | ||||
obj.pushKV("blocks", int(chainActive.Height())); | obj.pushKV("blocks", int(chainActive.Height())); | ||||
obj.pushKV("currentblocksize", uint64_t(nLastBlockSize)); | obj.pushKV("currentblocksize", uint64_t(nLastBlockSize)); | ||||
obj.pushKV("currentblocktx", uint64_t(nLastBlockTx)); | obj.pushKV("currentblocktx", uint64_t(nLastBlockTx)); | ||||
obj.pushKV("difficulty", double(GetDifficulty(chainActive.Tip()))); | obj.pushKV("difficulty", double(GetDifficulty(chainActive.Tip()))); | ||||
obj.pushKV("blockprioritypercentage", | obj.pushKV("blockprioritypercentage", | ||||
uint8_t(gArgs.GetArg("-blockprioritypercentage", | uint8_t(gArgs.GetArg("-blockprioritypercentage", | ||||
DEFAULT_BLOCK_PRIORITY_PERCENTAGE))); | DEFAULT_BLOCK_PRIORITY_PERCENTAGE))); | ||||
obj.pushKV("networkhashps", getnetworkhashps(config, request)); | obj.pushKV("networkhashps", getnetworkhashps(config, request)); | ||||
obj.pushKV("pooledtx", uint64_t(g_mempool.size())); | obj.pushKV("pooledtx", uint64_t(g_mempool.size())); | ||||
obj.pushKV("chain", config.GetChainParams().NetworkIDString()); | obj.pushKV("chain", config.GetChainParams().NetworkIDString()); | ||||
if (IsDeprecatedRPCEnabled(gArgs, "getmininginfo")) { | |||||
obj.pushKV("errors", GetWarnings("statusbar")); | |||||
} else { | |||||
obj.pushKV("warnings", GetWarnings("statusbar")); | obj.pushKV("warnings", GetWarnings("statusbar")); | ||||
} | |||||
return obj; | return obj; | ||||
} | } | ||||
// NOTE: Unlike wallet RPC (which use BCH values), mining RPCs follow GBT (BIP | // NOTE: Unlike wallet RPC (which use BCH values), mining RPCs follow GBT (BIP | ||||
// 22) in using satoshi amounts | // 22) in using satoshi amounts | ||||
static UniValue prioritisetransaction(const Config &config, | static UniValue prioritisetransaction(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
if (request.fHelp || request.params.size() != 3) { | if (request.fHelp || request.params.size() != 3) { | ||||
▲ Show 20 Lines • Show All 481 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() > 0) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"estimatefee\n" | "estimatefee\n" | ||||
"\nEstimates the approximate fee per kilobyte needed for a " | "\nEstimates the approximate fee per kilobyte needed for a " | ||||
"transaction\n" | "transaction\n" | ||||
"\nResult:\n" | "\nResult:\n" | ||||
"n (numeric) estimated fee-per-kilobyte\n" | "n (numeric) estimated fee-per-kilobyte\n" | ||||
"\nExample:\n" + | "\nExample:\n" + | ||||
HelpExampleCli("estimatefee", "")); | HelpExampleCli("estimatefee", "")); | ||||
} | } | ||||
if ((request.params.size() == 1) && | |||||
!IsDeprecatedRPCEnabled(gArgs, "estimatefee")) { | |||||
// FIXME: Remove this message in 0.20 | |||||
throw JSONRPCError( | |||||
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(g_mempool.estimateFee().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"}}, | ||||
Show All 15 Lines |