aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/mining.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2018-12-21 12:29:36 -0500
committerMarcoFalke <falke.marco@gmail.com>2019-01-25 14:16:07 -0500
commitfaa1522e5ec5ec53b2b2b1ed36c11e84939bbb13 (patch)
tree8575b7dbb7409b486e5e38f575bf5ecebc06adb3 /src/rpc/mining.cpp
parent5eb32d23841bbcd8eaf7ba49dc4ddfd822bd4773 (diff)
RPCHelpMan: Pass through Result and Examples
Diffstat (limited to 'src/rpc/mining.cpp')
-rw-r--r--src/rpc/mining.cpp117
1 files changed, 63 insertions, 54 deletions
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
index 2fd6f99be5..200dfa107b 100644
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -94,14 +94,15 @@ static UniValue getnetworkhashps(const JSONRPCRequest& request)
{
{"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"
+ },
+ RPCResult{
"x (numeric) Hashes per second estimated\n"
- "\nExamples:\n"
- + HelpExampleCli("getnetworkhashps", "")
+ },
+ RPCExamples{
+ HelpExampleCli("getnetworkhashps", "")
+ HelpExampleRpc("getnetworkhashps", "")
- );
+ },
+ }.ToString());
LOCK(cs_main);
return GetNetworkHashPS(!request.params[0].isNull() ? request.params[0].get_int() : 120, !request.params[1].isNull() ? request.params[1].get_int() : -1);
@@ -165,16 +166,17 @@ static UniValue generatetoaddress(const JSONRPCRequest& request)
{"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"
+ },
+ RPCResult{
"[ blockhashes ] (array) hashes of blocks generated\n"
- "\nExamples:\n"
+ },
+ RPCExamples{
"\nGenerate 11 blocks to myaddress\n"
+ HelpExampleCli("generatetoaddress", "11 \"myaddress\"")
+ "If you are running the bitcoin core wallet, you can get a new address to send the newly generated bitcoin to with:\n"
+ HelpExampleCli("getnewaddress", "")
- );
+ },
+ }.ToString());
int nGenerate = request.params[0].get_int();
uint64_t nMaxTries = 1000000;
@@ -198,9 +200,9 @@ static UniValue getmininginfo(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"
+ "\nReturns a json object containing mining-related information.",
+ {},
+ RPCResult{
"{\n"
" \"blocks\": nnn, (numeric) The current block\n"
" \"currentblockweight\": nnn, (numeric) The last block weight\n"
@@ -211,10 +213,12 @@ static UniValue getmininginfo(const JSONRPCRequest& request)
" \"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", "")
+ },
+ RPCExamples{
+ HelpExampleCli("getmininginfo", "")
+ HelpExampleRpc("getmininginfo", "")
- );
+ },
+ }.ToString());
LOCK(cs_main);
@@ -247,14 +251,15 @@ static UniValue prioritisetransaction(const JSONRPCRequest& request)
" Note, that this value is not a fee rate. It is a value to modify absolute fee of the TX.\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"
+ },
+ RPCResult{
"true (boolean) Returns true\n"
- "\nExamples:\n"
- + HelpExampleCli("prioritisetransaction", "\"txid\" 0.0 10000")
+ },
+ RPCExamples{
+ HelpExampleCli("prioritisetransaction", "\"txid\" 0.0 10000")
+ HelpExampleRpc("prioritisetransaction", "\"txid\", 0.0, 10000")
- );
+ },
+ }.ToString());
LOCK(cs_main);
@@ -326,9 +331,8 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
},
},
"\"template_request\""},
- }}
- .ToString() +
- "\nResult:\n"
+ },
+ RPCResult{
"{\n"
" \"version\" : n, (numeric) The preferred block version\n"
" \"rules\" : [ \"rulename\", ... ], (array of strings) specific block rules that are to be enforced\n"
@@ -372,11 +376,12 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
" \"bits\" : \"xxxxxxxx\", (string) compressed target of next block\n"
" \"height\" : n (numeric) The height of the next block\n"
"}\n"
-
- "\nExamples:\n"
- + HelpExampleCli("getblocktemplate", "{\"rules\": [\"segwit\"]}")
+ },
+ RPCExamples{
+ HelpExampleCli("getblocktemplate", "{\"rules\": [\"segwit\"]}")
+ HelpExampleRpc("getblocktemplate", "{\"rules\": [\"segwit\"]}")
- );
+ },
+ }.ToString());
LOCK(cs_main);
@@ -713,13 +718,13 @@ static UniValue submitblock(const JSONRPCRequest& request)
{
{"hexdata", RPCArg::Type::STR_HEX, /* opt */ false, /* default_val */ "", "the hex-encoded block data to submit"},
{"dummy", RPCArg::Type::STR, /* opt */ true, /* default_val */ "ignored", "dummy value, for compatibility with BIP22. This value is ignored."},
- }}
- .ToString() +
- "\nResult:\n"
- "\nExamples:\n"
- + HelpExampleCli("submitblock", "\"mydata\"")
+ },
+ RPCResults{},
+ RPCExamples{
+ HelpExampleCli("submitblock", "\"mydata\"")
+ HelpExampleRpc("submitblock", "\"mydata\"")
- );
+ },
+ }.ToString());
}
std::shared_ptr<CBlock> blockptr = std::make_shared<CBlock>();
@@ -777,13 +782,15 @@ static UniValue submitheader(const JSONRPCRequest& request)
"\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"
+ },
+ RPCResult{
"None"
- "\nExamples:\n" +
- HelpExampleCli("submitheader", "\"aabbcc\"") +
- HelpExampleRpc("submitheader", "\"aabbcc\""));
+ },
+ RPCExamples{
+ HelpExampleCli("submitheader", "\"aabbcc\"") +
+ HelpExampleRpc("submitheader", "\"aabbcc\"")
+ },
+ }.ToString());
}
CBlockHeader h;
@@ -826,9 +833,8 @@ static UniValue estimatesmartfee(const JSONRPCRequest& request)
" \"UNSET\"\n"
" \"ECONOMICAL\"\n"
" \"CONSERVATIVE\""},
- }}
- .ToString() +
- "\nResult:\n"
+ },
+ RPCResult{
"{\n"
" \"feerate\" : x.x, (numeric, optional) estimate fee rate in " + CURRENCY_UNIT + "/kB\n"
" \"errors\": [ str... ] (json array of strings, optional) Errors encountered during processing\n"
@@ -839,9 +845,11 @@ static UniValue estimatesmartfee(const JSONRPCRequest& request)
"fee estimation is able to return based on how long it has been running.\n"
"An error is returned if not enough transactions and blocks\n"
"have been observed to make an estimate for any number of blocks.\n"
- "\nExample:\n"
- + HelpExampleCli("estimatesmartfee", "6")
- );
+ },
+ RPCExamples{
+ HelpExampleCli("estimatesmartfee", "6")
+ },
+ }.ToString());
RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VSTR});
RPCTypeCheckArgument(request.params[0], UniValue::VNUM);
@@ -886,9 +894,8 @@ static UniValue estimaterawfee(const JSONRPCRequest& request)
{"threshold", RPCArg::Type::NUM, /* opt */ true, /* default_val */ "0.95", "The proportion of transactions in a given feerate range that must have been\n"
" confirmed within conf_target in order to consider those feerates as high enough and proceed to check\n"
" lower buckets."},
- }}
- .ToString() +
- "\nResult:\n"
+ },
+ RPCResult{
"{\n"
" \"short\" : { (json object, optional) estimate for short time horizon\n"
" \"feerate\" : x.x, (numeric, optional) estimate fee rate in " + CURRENCY_UNIT + "/kB\n"
@@ -910,9 +917,11 @@ static UniValue estimaterawfee(const JSONRPCRequest& request)
"}\n"
"\n"
"Results are returned for any horizon which tracks blocks up to the confirmation target.\n"
- "\nExample:\n"
- + HelpExampleCli("estimaterawfee", "6 0.9")
- );
+ },
+ RPCExamples{
+ HelpExampleCli("estimaterawfee", "6 0.9")
+ },
+ }.ToString());
RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VNUM}, true);
RPCTypeCheckArgument(request.params[0], UniValue::VNUM);