Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/mining.cpp
Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() > 2) { | ||||
RPCHelpMan{"getnetworkhashps", | RPCHelpMan{"getnetworkhashps", | ||||
"\nReturns the estimated network hashes per second " | "\nReturns the estimated network hashes per second " | ||||
"based on the last n blocks.\n" | "based on the last n blocks.\n" | ||||
"Pass in [blocks] to override # of blocks, -1 specifies " | "Pass in [blocks] to override # of blocks, -1 specifies " | ||||
"since last difficulty change.\n" | "since last difficulty change.\n" | ||||
"Pass in [height] to estimate the network speed at the " | "Pass in [height] to estimate the network speed at the " | ||||
"time when a certain block was found.\n", | "time when a certain block was found.\n", | ||||
{ | { | ||||
{"nblocks", RPCArg::Type::NUM, true}, | {"nblocks", RPCArg::Type::NUM, /* opt */ true, | ||||
{"height", RPCArg::Type::NUM, 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() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. nblocks (numeric, optional, default=120) The number of " | |||||
"blocks, or -1 for blocks since last difficulty change.\n" | |||||
"2. height (numeric, optional, default=-1) To estimate at the " | |||||
"time of the given height.\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"x (numeric) Hashes per second estimated\n" | "x (numeric) Hashes per second estimated\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("getnetworkhashps", "") + | HelpExampleCli("getnetworkhashps", "") + | ||||
HelpExampleRpc("getnetworkhashps", "")); | HelpExampleRpc("getnetworkhashps", "")); | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | 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) { | ||||
if (request.fHelp || request.params.size() < 2 || | if (request.fHelp || request.params.size() < 2 || | ||||
request.params.size() > 3) { | request.params.size() > 3) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"generatetoaddress", | RPCHelpMan{ | ||||
"\nMine blocks immediately to a specified address " | "generatetoaddress", | ||||
"before the RPC call returns)\n", | "\nMine blocks immediately to a specified address before the " | ||||
{ | "RPC call returns)\n", | ||||
{"nblocks", RPCArg::Type::NUM, false}, | { | ||||
{"address", RPCArg::Type::STR, false}, | {"nblocks", RPCArg::Type::NUM, /* opt */ false, | ||||
{"maxtries", RPCArg::Type::NUM, true}, | /* 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() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. nblocks (numeric, required) How many blocks are generated " | |||||
"immediately.\n" | |||||
"2. address (string, required) The address to send the newly " | |||||
"generated bitcoin to.\n" | |||||
"3. maxtries (numeric, optional) How many iterations to try " | |||||
"(default = 1000000).\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"[ blockhashes ] (array) hashes of blocks generated\n" | "[ blockhashes ] (array) hashes of blocks generated\n" | ||||
"\nExamples:\n" | "\nExamples:\n" | ||||
"\nGenerate 11 blocks to myaddress\n" + | "\nGenerate 11 blocks to myaddress\n" + | ||||
HelpExampleCli("generatetoaddress", "11 \"myaddress\"")); | HelpExampleCli("generatetoaddress", "11 \"myaddress\"")); | ||||
} | } | ||||
int nGenerate = request.params[0].get_int(); | int nGenerate = request.params[0].get_int(); | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
// 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) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"prioritisetransaction", | RPCHelpMan{ | ||||
"prioritisetransaction", | |||||
"Accepts the transaction into mined blocks at a higher " | "Accepts the transaction into mined blocks at a higher " | ||||
"(or lower) priority\n", | "(or lower) priority\n", | ||||
{ | { | ||||
{"txid", RPCArg::Type::STR_HEX, false}, | {"txid", RPCArg::Type::STR_HEX, /* opt */ false, | ||||
{"dummy", RPCArg::Type::NUM, false}, | /* default_val */ "", "The transaction id."}, | ||||
{"fee_delta", RPCArg::Type::NUM, false}, | {"dummy", RPCArg::Type::NUM, /* opt */ false, | ||||
deadalnix: The dummy became mandatory. | |||||
/* default_val */ "", | |||||
"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" | |||||
" 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() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. \"txid\" (string, required) The transaction id.\n" | |||||
"2. dummy (numeric, optional) API-Compatibility for " | |||||
"previous API. Must be zero or null.\n" | |||||
" DEPRECATED. For forward compatibility use named " | |||||
"arguments and omit this parameter.\n" | |||||
"3. fee_delta (numeric, required) 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.\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"true (boolean) Returns true\n" | "true (boolean) Returns true\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("prioritisetransaction", "\"txid\" 0.0 10000") + | HelpExampleCli("prioritisetransaction", "\"txid\" 0.0 10000") + | ||||
HelpExampleRpc("prioritisetransaction", "\"txid\", 0.0, 10000")); | HelpExampleRpc("prioritisetransaction", "\"txid\", 0.0, 10000")); | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() > 1) { | ||||
"bip-0023.mediawiki\n" | "bip-0023.mediawiki\n" | ||||
" " | " " | ||||
"https://github.com/bitcoin/bips/blob/master/" | "https://github.com/bitcoin/bips/blob/master/" | ||||
"bip-0009.mediawiki#getblocktemplate_changes\n" | "bip-0009.mediawiki#getblocktemplate_changes\n" | ||||
" ", | " ", | ||||
{ | { | ||||
{"template_request", | {"template_request", | ||||
RPCArg::Type::OBJ, | 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, true}, | "capabilities", | ||||
{"capabilities", | |||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
{ | /* opt */ true, | ||||
{"support", RPCArg::Type::STR, 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'"}, | |||||
deadalnixUnsubmitted Not Done Inline ActionsThis is adding ... at the end, so you need a coma. deadalnix: This is adding ... at the end, so you need a coma. | |||||
}, | |||||
}, | }, | ||||
true}, | |||||
}, | }, | ||||
true, | |||||
"\"template_request\""}, | "\"template_request\""}, | ||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments:\n" | |||||
"1. template_request (json object, optional) A json object " | |||||
"in the following spec\n" | |||||
" {\n" | |||||
" \"mode\":\"template\" (string, optional) This must be " | |||||
"set to \"template\", \"proposal\" (see BIP 23), or omitted\n" | |||||
" \"capabilities\":[ (array, optional) A list of " | |||||
"strings\n" | |||||
" \"support\" (string) client side supported " | |||||
"feature, 'longpoll', 'coinbasetxn', 'coinbasevalue', 'proposal', " | |||||
"'serverlist', 'workid'\n" | |||||
" ,...\n" | |||||
" ]\n" | |||||
" }\n" | |||||
"\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"{\n" | "{\n" | ||||
" \"version\" : n, (numeric) The preferred " | " \"version\" : n, (numeric) The preferred " | ||||
"block version\n" | "block version\n" | ||||
" \"previousblockhash\" : \"xxxx\", (string) The hash of " | " \"previousblockhash\" : \"xxxx\", (string) The hash of " | ||||
"current highest block\n" | "current highest block\n" | ||||
" \"transactions\" : [ (array) contents of " | " \"transactions\" : [ (array) contents of " | ||||
"non-coinbase transactions that should be included in the next " | "non-coinbase transactions that should be included in the next " | ||||
▲ Show 20 Lines • Show All 320 Lines • ▼ Show 20 Lines | static UniValue submitblock(const Config &config, | ||||
if (request.fHelp || request.params.size() < 1 || | if (request.fHelp || request.params.size() < 1 || | ||||
request.params.size() > 2) { | request.params.size() > 2) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"submitblock", | RPCHelpMan{"submitblock", | ||||
"\nAttempts to submit new block to network.\n" | "\nAttempts to submit new block to network.\n" | ||||
"See https://en.bitcoin.it/wiki/BIP_0022 for full " | "See https://en.bitcoin.it/wiki/BIP_0022 for full " | ||||
"specification.\n", | "specification.\n", | ||||
{ | { | ||||
{"hexdata", RPCArg::Type::STR_HEX, false}, | {"hexdata", RPCArg::Type::STR_HEX, /* opt */ false, | ||||
{"dummy", RPCArg::Type::STR, true}, | /* 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() + | .ToString() + | ||||
"\nArguments\n" | |||||
"1. \"hexdata\" (string, required) the hex-encoded block " | |||||
"data to submit\n" | |||||
"2. \"dummy\" (optional) dummy value, for compatibility " | |||||
"with BIP22. This value is ignored.\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("submitblock", "\"mydata\"") + | HelpExampleCli("submitblock", "\"mydata\"") + | ||||
HelpExampleRpc("submitblock", "\"mydata\"")); | HelpExampleRpc("submitblock", "\"mydata\"")); | ||||
} | } | ||||
std::shared_ptr<CBlock> blockptr = std::make_shared<CBlock>(); | std::shared_ptr<CBlock> blockptr = std::make_shared<CBlock>(); | ||||
CBlock &block = *blockptr; | CBlock &block = *blockptr; | ||||
▲ Show 20 Lines • Show All 42 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) { | ||||
if (request.fHelp || request.params.size() != 1) { | if (request.fHelp || request.params.size() != 1) { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
RPCHelpMan{"submitheader", | RPCHelpMan{ | ||||
"\nDecode the given hexdata as a header and submit it " | "submitheader", | ||||
"as a candidate chain tip if valid." | "\nDecode the given hexdata as a header and submit it as a " | ||||
"candidate chain tip if valid." | |||||
"\nThrows when the header is invalid.\n", | "\nThrows when the header is invalid.\n", | ||||
{ | { | ||||
{"hexdata", RPCArg::Type::STR_HEX, false}, | {"hexdata", RPCArg::Type::STR_HEX, /* opt */ false, | ||||
/* default_val */ "", "the hex-encoded block header data"}, | |||||
}} | }} | ||||
.ToString() + | .ToString() + | ||||
"\nArguments\n" | |||||
"1. \"hexdata\" (string, required) the " | |||||
"hex-encoded block header data\n" | |||||
"\nResult:\n" | "\nResult:\n" | ||||
"None" | "None" | ||||
"\nExamples:\n" + | "\nExamples:\n" + | ||||
HelpExampleCli("submitheader", "\"aabbcc\"") + | HelpExampleCli("submitheader", "\"aabbcc\"") + | ||||
HelpExampleRpc("submitheader", "\"aabbcc\"")); | HelpExampleRpc("submitheader", "\"aabbcc\"")); | ||||
} | } | ||||
CBlockHeader h; | CBlockHeader h; | ||||
▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines |
The dummy became mandatory.