Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13115424
D5822.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
29 KB
Subscribers
None
D5822.diff
View Options
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -87,29 +87,28 @@
static UniValue getnetworkhashps(const Config &config,
const JSONRPCRequest &request) {
if (request.fHelp || request.params.size() > 2) {
- throw std::runtime_error(
- RPCHelpMan{"getnetworkhashps",
- "\nReturns the estimated network hashes per second "
- "based on the last n blocks.\n"
- "Pass in [blocks] to override # of blocks, -1 specifies "
- "since last difficulty change.\n"
- "Pass in [height] to estimate the network speed at the "
- "time when a certain block was found.\n",
- {
- {"nblocks", RPCArg::Type::NUM, /* opt */ true,
- /* default_val */ "120",
- "The number of blocks, or -1 for blocks since last "
- "difficulty change."},
- {"height", RPCArg::Type::NUM, /* opt */ true,
- /* default_val */ "-1",
- "To estimate at the time of the given height."},
- }}
- .ToString() +
- "\nResult:\n"
- "x (numeric) Hashes per second estimated\n"
- "\nExamples:\n" +
- HelpExampleCli("getnetworkhashps", "") +
- HelpExampleRpc("getnetworkhashps", ""));
+ throw std::runtime_error(RPCHelpMan{
+ "getnetworkhashps",
+ "\nReturns the estimated network hashes per second "
+ "based on the last n blocks.\n"
+ "Pass in [blocks] to override # of blocks, -1 specifies "
+ "since last difficulty change.\n"
+ "Pass in [height] to estimate the network speed at the "
+ "time when a certain block was found.\n",
+ {
+ {"nblocks", RPCArg::Type::NUM, /* opt */ true,
+ /* default_val */ "120",
+ "The number of blocks, or -1 for blocks since last "
+ "difficulty change."},
+ {"height", RPCArg::Type::NUM, /* opt */ true,
+ /* default_val */ "-1",
+ "To estimate at the time of the given height."},
+ },
+ RPCResult{"x (numeric) Hashes per second estimated\n"},
+ RPCExamples{HelpExampleCli("getnetworkhashps", "") +
+ HelpExampleRpc("getnetworkhashps", "")},
+ }
+ .ToStringWithResultsAndExamples());
}
LOCK(cs_main);
@@ -189,28 +188,27 @@
const JSONRPCRequest &request) {
if (request.fHelp || request.params.size() < 2 ||
request.params.size() > 3) {
- throw std::runtime_error(
- RPCHelpMan{
- "generatetoaddress",
- "\nMine blocks immediately to a specified address before the "
- "RPC call returns)\n",
- {
- {"nblocks", RPCArg::Type::NUM, /* opt */ false,
- /* default_val */ "",
- "How many blocks are generated immediately."},
- {"address", RPCArg::Type::STR, /* opt */ false,
- /* default_val */ "",
- "The address to send the newly generated bitcoin to."},
- {"maxtries", RPCArg::Type::NUM, /* opt */ true,
- /* default_val */ "1000000",
- "How many iterations to try."},
- }}
- .ToString() +
- "\nResult:\n"
- "[ blockhashes ] (array) hashes of blocks generated\n"
- "\nExamples:\n"
- "\nGenerate 11 blocks to myaddress\n" +
- HelpExampleCli("generatetoaddress", "11 \"myaddress\""));
+ throw std::runtime_error(RPCHelpMan{
+ "generatetoaddress",
+ "\nMine blocks immediately to a specified address before the "
+ "RPC call returns)\n",
+ {
+ {"nblocks", RPCArg::Type::NUM, /* opt */ false,
+ /* default_val */ "",
+ "How many blocks are generated immediately."},
+ {"address", RPCArg::Type::STR, /* opt */ false,
+ /* default_val */ "",
+ "The address to send the newly generated bitcoin to."},
+ {"maxtries", RPCArg::Type::NUM, /* opt */ true,
+ /* default_val */ "1000000", "How many iterations to try."},
+ },
+ RPCResult{
+ "[ blockhashes ] (array) hashes of blocks generated\n"},
+ RPCExamples{
+ "\nGenerate 11 blocks to myaddress\n" +
+ HelpExampleCli("generatetoaddress", "11 \"myaddress\"")},
+ }
+ .ToStringWithResultsAndExamples());
}
int nGenerate = request.params[0].get_int();
@@ -236,30 +234,32 @@
static UniValue getmininginfo(const Config &config,
const JSONRPCRequest &request) {
if (request.fHelp || request.params.size() != 0) {
- throw std::runtime_error(
- RPCHelpMan{"getmininginfo",
- "\nReturns a json object containing mining-related "
- "information.",
- {}}
- .ToString() +
- "\nResult:\n"
- "{\n"
- " \"blocks\": nnn, (numeric) The current block\n"
- " \"currentblocksize\": nnn, (numeric) The last block size\n"
- " \"currentblocktx\": nnn, (numeric) The last block "
- "transaction\n"
- " \"difficulty\": xxx.xxxxx (numeric) The current difficulty\n"
- " \"networkhashps\": nnn, (numeric) The network hashes per "
- "second\n"
- " \"pooledtx\": n (numeric) The size of the mempool\n"
- " \"chain\": \"xxxx\", (string) current network name as "
- "defined in BIP70 (main, test, regtest)\n"
- " \"warnings\": \"...\" (string) any network and "
- "blockchain warnings\n"
- "}\n"
- "\nExamples:\n" +
- HelpExampleCli("getmininginfo", "") +
- HelpExampleRpc("getmininginfo", ""));
+ throw std::runtime_error(RPCHelpMan{
+ "getmininginfo",
+ "\nReturns a json object containing mining-related "
+ "information.",
+ {},
+ RPCResult{
+ "{\n"
+ " \"blocks\": nnn, (numeric) The current block\n"
+ " \"currentblocksize\": nnn, (numeric) The last block size\n"
+ " \"currentblocktx\": nnn, (numeric) The last block "
+ "transaction\n"
+ " \"difficulty\": xxx.xxxxx (numeric) The current "
+ "difficulty\n"
+ " \"networkhashps\": nnn, (numeric) The network hashes "
+ "per second\n"
+ " \"pooledtx\": n (numeric) The size of the "
+ "mempool\n"
+ " \"chain\": \"xxxx\", (string) current network "
+ "name as defined in BIP70 (main, test, regtest)\n"
+ " \"warnings\": \"...\" (string) any network and "
+ "blockchain warnings\n"
+ "}\n"},
+ RPCExamples{HelpExampleCli("getmininginfo", "") +
+ HelpExampleRpc("getmininginfo", "")},
+ }
+ .ToStringWithResultsAndExamples());
}
LOCK(cs_main);
@@ -282,36 +282,36 @@
static UniValue prioritisetransaction(const Config &config,
const JSONRPCRequest &request) {
if (request.fHelp || request.params.size() != 3) {
- throw std::runtime_error(
- RPCHelpMan{
- "prioritisetransaction",
- "Accepts the transaction into mined blocks at a higher "
- "(or lower) priority\n",
- {
- {"txid", RPCArg::Type::STR_HEX, /* opt */ false,
- /* default_val */ "", "The transaction id."},
- {"dummy", RPCArg::Type::NUM, /* opt */ true,
- /* default_val */ "null",
- "API-Compatibility for previous API. Must be zero or "
- "null.\n"
- " DEPRECATED. For forward compatibility "
- "use named arguments and omit this parameter."},
- {"fee_delta", RPCArg::Type::NUM, /* opt */ false,
- /* default_val */ "",
- "The fee value (in satoshis) to add (or subtract, if "
- "negative).\n"
- " The fee is not actually paid, "
- "only the algorithm for selecting transactions into a "
- "block\n"
- " considers the transaction as it would "
- "have paid a higher (or lower) fee."},
- }}
- .ToString() +
- "\nResult:\n"
- "true (boolean) Returns true\n"
- "\nExamples:\n" +
- HelpExampleCli("prioritisetransaction", "\"txid\" 0.0 10000") +
- HelpExampleRpc("prioritisetransaction", "\"txid\", 0.0, 10000"));
+ throw std::runtime_error(RPCHelpMan{
+ "prioritisetransaction",
+ "Accepts the transaction into mined blocks at a higher "
+ "(or lower) priority\n",
+ {
+ {"txid", RPCArg::Type::STR_HEX, /* opt */ false,
+ /* default_val */ "", "The transaction id."},
+ {"dummy", RPCArg::Type::NUM, /* opt */ true,
+ /* default_val */ "null",
+ "API-Compatibility for previous API. Must be zero or "
+ "null.\n"
+ " DEPRECATED. For forward compatibility "
+ "use named arguments and omit this parameter."},
+ {"fee_delta", RPCArg::Type::NUM, /* opt */ false,
+ /* default_val */ "",
+ "The fee value (in satoshis) to add (or subtract, if "
+ "negative).\n"
+ " The fee is not actually paid, "
+ "only the algorithm for selecting transactions into a "
+ "block\n"
+ " considers the transaction as it would "
+ "have paid a higher (or lower) fee."},
+ },
+ RPCResult{"true (boolean) Returns true\n"},
+ RPCExamples{
+ HelpExampleCli("prioritisetransaction", "\"txid\" 0.0 10000") +
+ HelpExampleRpc("prioritisetransaction",
+ "\"txid\", 0.0, 10000")},
+ }
+ .ToStringWithResultsAndExamples());
}
LOCK(cs_main);
@@ -356,129 +356,130 @@
static UniValue getblocktemplate(const Config &config,
const JSONRPCRequest &request) {
if (request.fHelp || request.params.size() > 1) {
- throw std::runtime_error(
- RPCHelpMan{
- "getblocktemplate",
- "\nIf the request parameters include a 'mode' key, that is "
- "used to explicitly select between the default 'template' "
- "request or a 'proposal'.\n"
- "It returns data needed to construct a block to work on.\n"
- "For full specification, see BIPs 22, 23, 9, and 145:\n"
- " "
- "https://github.com/bitcoin/bips/blob/master/"
- "bip-0022.mediawiki\n"
- " "
- "https://github.com/bitcoin/bips/blob/master/"
- "bip-0023.mediawiki\n"
- " "
- "https://github.com/bitcoin/bips/blob/master/"
- "bip-0009.mediawiki#getblocktemplate_changes\n"
- " ",
- {
- {"template_request",
- RPCArg::Type::OBJ,
- /* opt */ true,
- /* default_val */ "",
- "A json object in the following spec",
+ throw std::runtime_error(RPCHelpMan{
+ "getblocktemplate",
+ "\nIf the request parameters include a 'mode' key, that is "
+ "used to explicitly select between the default 'template' "
+ "request or a 'proposal'.\n"
+ "It returns data needed to construct a block to work on.\n"
+ "For full specification, see BIPs 22, 23, 9, and 145:\n"
+ " "
+ "https://github.com/bitcoin/bips/blob/master/"
+ "bip-0022.mediawiki\n"
+ " "
+ "https://github.com/bitcoin/bips/blob/master/"
+ "bip-0023.mediawiki\n"
+ " "
+ "https://github.com/bitcoin/bips/blob/master/"
+ "bip-0009.mediawiki#getblocktemplate_changes\n"
+ " ",
+ {
+ {"template_request",
+ RPCArg::Type::OBJ,
+ /* opt */ true,
+ /* default_val */ "",
+ "A json object in the following spec",
+ {
+ {"mode", RPCArg::Type::STR, /* opt */ true,
+ /* default_val */ "",
+ "This must be set to \"template\", \"proposal\" (see "
+ "BIP 23), or omitted"},
{
- {"mode", RPCArg::Type::STR, /* opt */ true,
- /* default_val */ "",
- "This must be set to \"template\", \"proposal\" (see "
- "BIP 23), or omitted"},
+ "capabilities",
+ RPCArg::Type::ARR,
+ /* opt */ true,
+ /* default_val */ "",
+ "A list of strings",
{
- "capabilities",
- RPCArg::Type::ARR,
- /* opt */ true,
- /* default_val */ "",
- "A list of strings",
- {
- {"support", RPCArg::Type::STR, /* opt */ true,
- /* default_val */ "",
- "client side supported feature, 'longpoll', "
- "'coinbasetxn', 'coinbasevalue', 'proposal', "
- "'serverlist', 'workid'"},
- },
+ {"support", RPCArg::Type::STR, /* opt */ true,
+ /* default_val */ "",
+ "client side supported feature, 'longpoll', "
+ "'coinbasetxn', 'coinbasevalue', 'proposal', "
+ "'serverlist', 'workid'"},
},
},
- "\"template_request\""},
- }}
- .ToString() +
- "\nResult:\n"
- "{\n"
- " \"version\" : n, (numeric) The preferred "
- "block version\n"
- " \"previousblockhash\" : \"xxxx\", (string) The hash of "
- "current highest block\n"
- " \"transactions\" : [ (array) contents of "
- "non-coinbase transactions that should be included in the next "
- "block\n"
- " {\n"
- " \"data\" : \"xxxx\", (string) transaction "
- "data encoded in hexadecimal (byte-for-byte)\n"
- " \"txid\" : \"xxxx\", (string) transaction id "
- "encoded in little-endian hexadecimal\n"
- " \"hash\" : \"xxxx\", (string) hash encoded "
- "in little-endian hexadecimal (including witness data)\n"
- " \"depends\" : [ (array) array of numbers "
- "\n"
- " n (numeric) transactions "
- "before this one (by 1-based index in 'transactions' list) that "
- "must be present in the final block if this one is\n"
- " ,...\n"
- " ],\n"
- " \"fee\": n, (numeric) difference in "
- "value between transaction inputs and outputs (in satoshis); for "
- "coinbase transactions, this is a negative Number of the total "
- "collected block fees (ie, not including the block subsidy); if "
- "key is not present, fee is unknown and clients MUST NOT assume "
- "there isn't one\n"
- " \"sigops\" : n, (numeric) total SigOps "
- "count, as counted for purposes of block limits; if key is not "
- "present, sigop count is unknown and clients MUST NOT assume it is "
- "zero\n"
- " \"required\" : true|false (boolean) if provided and "
- "true, this transaction must be in the final block\n"
- " }\n"
- " ,...\n"
- " ],\n"
- " \"coinbaseaux\" : { (json object) data that "
- "should be included in the coinbase's scriptSig content\n"
- " \"flags\" : \"xx\" (string) key name is to "
- "be ignored, and value included in scriptSig\n"
- " },\n"
- " \"coinbasevalue\" : n, (numeric) maximum allowable "
- "input to coinbase transaction, including the generation award and "
- "transaction fees (in satoshis)\n"
- " \"coinbasetxn\" : { ... }, (json object) information "
- "for coinbase transaction\n"
- " \"target\" : \"xxxx\", (string) The hash target\n"
- " \"mintime\" : xxx, (numeric) The minimum "
- "timestamp appropriate for next block time in seconds since epoch "
- "(Jan 1 1970 GMT)\n"
- " \"mutable\" : [ (array of string) list of "
- "ways the block template may be changed \n"
- " \"value\" (string) A way the block "
- "template may be changed, e.g. 'time', 'transactions', "
- "'prevblock'\n"
- " ,...\n"
- " ],\n"
- " \"noncerange\" : \"00000000ffffffff\",(string) A range of valid "
- "nonces\n"
- " \"sigoplimit\" : n, (numeric) limit of sigops "
- "in blocks\n"
- " \"sizelimit\" : n, (numeric) limit of block "
- "size\n"
- " \"curtime\" : ttt, (numeric) current timestamp "
- "in seconds since epoch (Jan 1 1970 GMT)\n"
- " \"bits\" : \"xxxxxxxx\", (string) compressed "
- "target of next block\n"
- " \"height\" : n (numeric) The height of the "
- "next block\n"
- "}\n"
-
- "\nExamples:\n" +
- HelpExampleCli("getblocktemplate", "") +
- HelpExampleRpc("getblocktemplate", ""));
+ },
+ "\"template_request\""},
+ },
+ RPCResult{
+ "{\n"
+ " \"version\" : n, (numeric) The preferred "
+ "block version\n"
+ " \"previousblockhash\" : \"xxxx\", (string) The hash of "
+ "current highest block\n"
+ " \"transactions\" : [ (array) contents of "
+ "non-coinbase transactions that should be included in the next "
+ "block\n"
+ " {\n"
+ " \"data\" : \"xxxx\", (string) "
+ "transaction data encoded in hexadecimal (byte-for-byte)\n"
+ " \"txid\" : \"xxxx\", (string) "
+ "transaction id encoded in little-endian hexadecimal\n"
+ " \"hash\" : \"xxxx\", (string) hash "
+ "encoded in little-endian hexadecimal (including witness "
+ "data)\n"
+ " \"depends\" : [ (array) array of "
+ "numbers \n"
+ " n (numeric) "
+ "transactions before this one (by 1-based index in "
+ "'transactions' list) that must be present in the final block "
+ "if this one is\n"
+ " ,...\n"
+ " ],\n"
+ " \"fee\": n, (numeric) difference "
+ "in value between transaction inputs and outputs (in "
+ "satoshis); for coinbase transactions, this is a negative "
+ "Number of the total collected block fees (ie, not including "
+ "the block subsidy); if key is not present, fee is unknown and "
+ "clients MUST NOT assume there isn't one\n"
+ " \"sigops\" : n, (numeric) total "
+ "SigOps count, as counted for purposes of block limits; if key "
+ "is not present, sigop count is unknown and clients MUST NOT "
+ "assume it is zero\n"
+ " \"required\" : true|false (boolean) if provided "
+ "and true, this transaction must be in the final block\n"
+ " }\n"
+ " ,...\n"
+ " ],\n"
+ " \"coinbaseaux\" : { (json object) data that "
+ "should be included in the coinbase's scriptSig content\n"
+ " \"flags\" : \"xx\" (string) key name "
+ "is to be ignored, and value included in scriptSig\n"
+ " },\n"
+ " \"coinbasevalue\" : n, (numeric) maximum "
+ "allowable input to coinbase transaction, including the "
+ "generation award and transaction fees (in satoshis)\n"
+ " \"coinbasetxn\" : { ... }, (json object) "
+ "information for coinbase transaction\n"
+ " \"target\" : \"xxxx\", (string) The hash "
+ "target\n"
+ " \"mintime\" : xxx, (numeric) The minimum "
+ "timestamp appropriate for next block time in seconds since "
+ "epoch (Jan 1 1970 GMT)\n"
+ " \"mutable\" : [ (array of string) list "
+ "of ways the block template may be changed \n"
+ " \"value\" (string) A way the "
+ "block template may be changed, e.g. 'time', 'transactions', "
+ "'prevblock'\n"
+ " ,...\n"
+ " ],\n"
+ " \"noncerange\" : \"00000000ffffffff\",(string) A range of "
+ "valid nonces\n"
+ " \"sigoplimit\" : n, (numeric) limit of "
+ "sigops in blocks\n"
+ " \"sizelimit\" : n, (numeric) limit of "
+ "block size\n"
+ " \"curtime\" : ttt, (numeric) current "
+ "timestamp in seconds since epoch (Jan 1 1970 GMT)\n"
+ " \"bits\" : \"xxxxxxxx\", (string) compressed "
+ "target of next block\n"
+ " \"height\" : n (numeric) The height of "
+ "the next block\n"
+ "}\n"},
+ RPCExamples{HelpExampleCli("getblocktemplate", "") +
+ HelpExampleRpc("getblocktemplate", "")},
+ }
+ .ToStringWithResultsAndExamples());
}
LOCK(cs_main);
@@ -733,25 +734,24 @@
// We allow 2 arguments for compliance with BIP22. Argument 2 is ignored.
if (request.fHelp || request.params.size() < 1 ||
request.params.size() > 2) {
- throw std::runtime_error(
- RPCHelpMan{"submitblock",
- "\nAttempts to submit new block to network.\n"
- "See https://en.bitcoin.it/wiki/BIP_0022 for full "
- "specification.\n",
- {
- {"hexdata", RPCArg::Type::STR_HEX, /* opt */ false,
- /* default_val */ "",
- "the hex-encoded block data to submit"},
- {"dummy", RPCArg::Type::STR, /* opt */ true,
- /* default_val */ "",
- "dummy value, for compatibility with BIP22. This "
- "value is ignored."},
- }}
- .ToString() +
- "\nResult:\n"
- "\nExamples:\n" +
- HelpExampleCli("submitblock", "\"mydata\"") +
- HelpExampleRpc("submitblock", "\"mydata\""));
+ throw std::runtime_error(RPCHelpMan{
+ "submitblock",
+ "\nAttempts to submit new block to network.\n"
+ "See https://en.bitcoin.it/wiki/BIP_0022 for full "
+ "specification.\n",
+ {
+ {"hexdata", RPCArg::Type::STR_HEX, /* opt */ false,
+ /* default_val */ "", "the hex-encoded block data to submit"},
+ {"dummy", RPCArg::Type::STR, /* opt */ true,
+ /* default_val */ "",
+ "dummy value, for compatibility with BIP22. This "
+ "value is ignored."},
+ },
+ RPCResults{},
+ RPCExamples{HelpExampleCli("submitblock", "\"mydata\"") +
+ HelpExampleRpc("submitblock", "\"mydata\"")},
+ }
+ .ToStringWithResultsAndExamples());
}
std::shared_ptr<CBlock> blockptr = std::make_shared<CBlock>();
@@ -805,22 +805,20 @@
static UniValue submitheader(const Config &config,
const JSONRPCRequest &request) {
if (request.fHelp || request.params.size() != 1) {
- throw std::runtime_error(
- RPCHelpMan{
- "submitheader",
- "\nDecode the given hexdata as a header and submit it as a "
- "candidate chain tip if valid."
- "\nThrows when the header is invalid.\n",
- {
- {"hexdata", RPCArg::Type::STR_HEX, /* opt */ false,
- /* default_val */ "", "the hex-encoded block header data"},
- }}
- .ToString() +
- "\nResult:\n"
- "None"
- "\nExamples:\n" +
- HelpExampleCli("submitheader", "\"aabbcc\"") +
- HelpExampleRpc("submitheader", "\"aabbcc\""));
+ throw std::runtime_error(RPCHelpMan{
+ "submitheader",
+ "\nDecode the given hexdata as a header and submit it as a "
+ "candidate chain tip if valid."
+ "\nThrows when the header is invalid.\n",
+ {
+ {"hexdata", RPCArg::Type::STR_HEX, /* opt */ false,
+ /* default_val */ "", "the hex-encoded block header data"},
+ },
+ RPCResult{"None"},
+ RPCExamples{HelpExampleCli("submitheader", "\"aabbcc\"") +
+ HelpExampleRpc("submitheader", "\"aabbcc\"")},
+ }
+ .ToStringWithResultsAndExamples());
}
CBlockHeader h;
@@ -852,16 +850,15 @@
static UniValue estimatefee(const Config &config,
const JSONRPCRequest &request) {
if (request.fHelp || request.params.size() > 0) {
- throw std::runtime_error(
- RPCHelpMan{"estimatefee",
- "\nEstimates the approximate fee per kilobyte needed "
- "for a transaction\n",
- {}}
- .ToString() +
- "\nResult:\n"
- "n (numeric) estimated fee-per-kilobyte\n"
- "\nExample:\n" +
- HelpExampleCli("estimatefee", ""));
+ throw std::runtime_error(RPCHelpMan{
+ "estimatefee",
+ "\nEstimates the approximate fee per kilobyte needed "
+ "for a transaction\n",
+ {},
+ RPCResult{"n (numeric) estimated fee-per-kilobyte\n"},
+ RPCExamples{HelpExampleCli("estimatefee", "")},
+ }
+ .ToStringWithResultsAndExamples());
}
return ValueFromAmount(g_mempool.estimateFee().GetFeePerK());
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 1, 11:04 (15 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187483
Default Alt Text
D5822.diff (29 KB)
Attached To
D5822: Pass rpc/mining RPC results and examples to RPCHelpMan
Event Timeline
Log In to Comment