Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/mining.cpp
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | static UniValue GetNetworkHashPS(int lookup, int height) { | ||||
return workDiff.getdouble() / timeDiff; | return workDiff.getdouble() / timeDiff; | ||||
} | } | ||||
static UniValue getnetworkhashps(const Config &config, | static UniValue getnetworkhashps(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getnetworkhashps", | "getnetworkhashps", | ||||
"\nReturns the estimated network hashes per second based on the last n " | "Returns the estimated network hashes per second based on the last n " | ||||
"blocks.\n" | "blocks.\n" | ||||
"Pass in [blocks] to override # of blocks, -1 specifies since last " | "Pass in [blocks] to override # of blocks, -1 specifies since last " | ||||
"difficulty change.\n" | "difficulty change.\n" | ||||
"Pass in [height] to estimate the network speed at the time when a " | "Pass in [height] to estimate the network speed at the time when a " | ||||
"certain block was found.\n", | "certain block was found.\n", | ||||
{ | { | ||||
{"nblocks", RPCArg::Type::NUM, /* default */ "120", | {"nblocks", RPCArg::Type::NUM, /* default */ "120", | ||||
"The number of blocks, or -1 for blocks since last difficulty " | "The number of blocks, or -1 for blocks since last difficulty " | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | static UniValue generateBlocks(const Config &config, | ||||
return blockHashes; | return blockHashes; | ||||
} | } | ||||
static UniValue generatetoaddress(const Config &config, | static UniValue generatetoaddress(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"generatetoaddress", | "generatetoaddress", | ||||
"\nMine blocks immediately to a specified address before the " | "Mine blocks immediately to a specified address before the " | ||||
"RPC call returns)\n", | "RPC call returns)\n", | ||||
{ | { | ||||
{"nblocks", RPCArg::Type::NUM, RPCArg::Optional::NO, | {"nblocks", RPCArg::Type::NUM, RPCArg::Optional::NO, | ||||
"How many blocks are generated immediately."}, | "How many blocks are generated immediately."}, | ||||
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, | {"address", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The address to send the newly generated bitcoin to."}, | "The address to send the newly generated bitcoin to."}, | ||||
{"maxtries", RPCArg::Type::NUM, /* default */ "1000000", | {"maxtries", RPCArg::Type::NUM, /* default */ "1000000", | ||||
"How many iterations to try."}, | "How many iterations to try."}, | ||||
Show All 25 Lines | static UniValue generatetoaddress(const Config &config, | ||||
return generateBlocks(config, coinbase_script, nGenerate, nMaxTries); | return generateBlocks(config, coinbase_script, nGenerate, nMaxTries); | ||||
} | } | ||||
static UniValue getmininginfo(const Config &config, | static UniValue getmininginfo(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getmininginfo", | "getmininginfo", | ||||
"\nReturns a json object containing mining-related " | "Returns a json object containing mining-related " | ||||
"information.", | "information.", | ||||
{}, | {}, | ||||
RPCResult{ | RPCResult{ | ||||
"{\n" | "{\n" | ||||
" \"blocks\": nnn, (numeric) The current block\n" | " \"blocks\": nnn, (numeric) The current block\n" | ||||
" \"currentblocksize\": nnn, (numeric, optional) The block size " | " \"currentblocksize\": nnn, (numeric, optional) The block size " | ||||
"of the last assembled block (only present if a block was ever " | "of the last assembled block (only present if a block was ever " | ||||
"assembled)\n" | "assembled)\n" | ||||
▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | static UniValue BIP22ValidationResult(const Config &config, | ||||
// Should be impossible. | // Should be impossible. | ||||
return "valid?"; | return "valid?"; | ||||
} | } | ||||
static UniValue getblocktemplate(const Config &config, | static UniValue getblocktemplate(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"getblocktemplate", | "getblocktemplate", | ||||
"\nIf the request parameters include a 'mode' key, that is used to " | "If the request parameters include a 'mode' key, that is used to " | ||||
"explicitly select between the default 'template' request or a " | "explicitly select between the default 'template' request or a " | ||||
"'proposal'.\n" | "'proposal'.\n" | ||||
"It returns data needed to construct a block to work on.\n" | "It returns data needed to construct a block to work on.\n" | ||||
"For full specification, see BIPs 22, 23, 9, and 145:\n" | "For full specification, see BIPs 22, 23, 9, and 145:\n" | ||||
" " | " " | ||||
"https://github.com/bitcoin/bips/blob/master/" | "https://github.com/bitcoin/bips/blob/master/" | ||||
"bip-0022.mediawiki\n" | "bip-0022.mediawiki\n" | ||||
" " | " " | ||||
▲ Show 20 Lines • Show All 354 Lines • ▼ Show 20 Lines | protected: | ||||
} | } | ||||
}; | }; | ||||
static UniValue submitblock(const Config &config, | static UniValue submitblock(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
// We allow 2 arguments for compliance with BIP22. Argument 2 is ignored. | // We allow 2 arguments for compliance with BIP22. Argument 2 is ignored. | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"submitblock", | "submitblock", | ||||
"\nAttempts to submit new block to network.\n" | "Attempts to submit new block to network.\n" | ||||
"See https://en.bitcoin.it/wiki/BIP_0022 for full specification.\n", | "See https://en.bitcoin.it/wiki/BIP_0022 for full specification.\n", | ||||
{ | { | ||||
{"hexdata", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | {"hexdata", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"the hex-encoded block data to submit"}, | "the hex-encoded block data to submit"}, | ||||
{"dummy", RPCArg::Type::STR, /* default */ "ignored", | {"dummy", RPCArg::Type::STR, /* default */ "ignored", | ||||
"dummy value, for compatibility with BIP22. This value is " | "dummy value, for compatibility with BIP22. This value is " | ||||
"ignored."}, | "ignored."}, | ||||
}, | }, | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | static UniValue submitblock(const Config &config, | ||||
return BIP22ValidationResult(config, sc.state); | return BIP22ValidationResult(config, sc.state); | ||||
} | } | ||||
static UniValue submitheader(const Config &config, | static UniValue submitheader(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"submitheader", | "submitheader", | ||||
"\nDecode the given hexdata as a header and submit it as a candidate " | "Decode the given hexdata as a header and submit it as a candidate " | ||||
"chain tip if valid." | "chain tip if valid." | ||||
"\nThrows when the header is invalid.\n", | "\nThrows when the header is invalid.\n", | ||||
{ | { | ||||
{"hexdata", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | {"hexdata", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"the hex-encoded block header data"}, | "the hex-encoded block header data"}, | ||||
}, | }, | ||||
RPCResult{"None"}, | RPCResult{"None"}, | ||||
RPCExamples{HelpExampleCli("submitheader", "\"aabbcc\"") + | RPCExamples{HelpExampleCli("submitheader", "\"aabbcc\"") + | ||||
Show All 25 Lines | static UniValue submitheader(const Config &config, | ||||
} | } | ||||
throw JSONRPCError(RPC_VERIFY_ERROR, state.GetRejectReason()); | throw JSONRPCError(RPC_VERIFY_ERROR, state.GetRejectReason()); | ||||
} | } | ||||
static UniValue estimatefee(const Config &config, | static UniValue estimatefee(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"estimatefee", | "estimatefee", | ||||
"\nEstimates the approximate fee per kilobyte needed for a " | "Estimates the approximate fee per kilobyte needed for a " | ||||
"transaction\n", | "transaction\n", | ||||
{}, | {}, | ||||
RPCResult{"n (numeric) estimated fee-per-kilobyte\n"}, | RPCResult{"n (numeric) estimated fee-per-kilobyte\n"}, | ||||
RPCExamples{HelpExampleCli("estimatefee", "")}, | RPCExamples{HelpExampleCli("estimatefee", "")}, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
return ValueFromAmount(g_mempool.estimateFee().GetFeePerK()); | return ValueFromAmount(g_mempool.estimateFee().GetFeePerK()); | ||||
Show All 24 Lines |