Skip to content

Commit fae542c

Browse files
author
MarcoFalke
committed
rpc: Properly document getblocktemplate return value
Can be reviewed with --ignore-all-space
1 parent fabaccf commit fae542c

File tree

1 file changed

+72
-71
lines changed

1 file changed

+72
-71
lines changed

src/rpc/mining.cpp

Lines changed: 72 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -505,83 +505,84 @@ static std::string gbt_vb_name(const Consensus::DeploymentPos pos) {
505505
static RPCHelpMan getblocktemplate()
506506
{
507507
return RPCHelpMan{"getblocktemplate",
508-
"\nIf the request parameters include a 'mode' key, that is used to explicitly select between the default 'template' request or a 'proposal'.\n"
509-
"It returns data needed to construct a block to work on.\n"
510-
"For full specification, see BIPs 22, 23, 9, and 145:\n"
511-
" https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki\n"
512-
" https://github.com/bitcoin/bips/blob/master/bip-0023.mediawiki\n"
513-
" https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki#getblocktemplate_changes\n"
514-
" https://github.com/bitcoin/bips/blob/master/bip-0145.mediawiki\n",
508+
"\nIf the request parameters include a 'mode' key, that is used to explicitly select between the default 'template' request or a 'proposal'.\n"
509+
"It returns data needed to construct a block to work on.\n"
510+
"For full specification, see BIPs 22, 23, 9, and 145:\n"
511+
" https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki\n"
512+
" https://github.com/bitcoin/bips/blob/master/bip-0023.mediawiki\n"
513+
" https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki#getblocktemplate_changes\n"
514+
" https://github.com/bitcoin/bips/blob/master/bip-0145.mediawiki\n",
515+
{
516+
{"template_request", RPCArg::Type::OBJ, "{}", "Format of the template",
517+
{
518+
{"mode", RPCArg::Type::STR, /* treat as named arg */ RPCArg::Optional::OMITTED_NAMED_ARG, "This must be set to \"template\", \"proposal\" (see BIP 23), or omitted"},
519+
{"capabilities", RPCArg::Type::ARR, /* treat as named arg */ RPCArg::Optional::OMITTED_NAMED_ARG, "A list of strings",
515520
{
516-
{"template_request", RPCArg::Type::OBJ, "{}", "Format of the template",
517-
{
518-
{"mode", RPCArg::Type::STR, /* treat as named arg */ RPCArg::Optional::OMITTED_NAMED_ARG, "This must be set to \"template\", \"proposal\" (see BIP 23), or omitted"},
519-
{"capabilities", RPCArg::Type::ARR, /* treat as named arg */ RPCArg::Optional::OMITTED_NAMED_ARG, "A list of strings",
520-
{
521-
{"str", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "client side supported feature, 'longpoll', 'coinbasevalue', 'proposal', 'serverlist', 'workid'"},
522-
},
523-
},
524-
{"rules", RPCArg::Type::ARR, RPCArg::Optional::NO, "A list of strings",
525-
{
526-
{"segwit", RPCArg::Type::STR, RPCArg::Optional::NO, "(literal) indicates client side segwit support"},
527-
{"str", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "other client side supported softfork deployment"},
528-
},
529-
},
530-
},
521+
{"str", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "client side supported feature, 'longpoll', 'coinbasevalue', 'proposal', 'serverlist', 'workid'"},
522+
}},
523+
{"rules", RPCArg::Type::ARR, RPCArg::Optional::NO, "A list of strings",
524+
{
525+
{"segwit", RPCArg::Type::STR, RPCArg::Optional::NO, "(literal) indicates client side segwit support"},
526+
{"str", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "other client side supported softfork deployment"},
527+
}},
528+
},
531529
"\"template_request\""},
532-
},
533-
RPCResult{
534-
RPCResult::Type::OBJ, "", "",
530+
},
531+
{
532+
RPCResult{"If the proposal was accepted with mode=='proposal'", RPCResult::Type::NONE, "", ""},
533+
RPCResult{"If the proposal was not accepted with mode=='proposal'", RPCResult::Type::STR, "", "According to BIP22"},
534+
RPCResult{"Otherwise", RPCResult::Type::OBJ, "", "",
535+
{
536+
{RPCResult::Type::NUM, "version", "The preferred block version"},
537+
{RPCResult::Type::ARR, "rules", "specific block rules that are to be enforced",
538+
{
539+
{RPCResult::Type::STR, "", "name of a rule the client must understand to some extent; see BIP 9 for format"},
540+
}},
541+
{RPCResult::Type::OBJ_DYN, "vbavailable", "set of pending, supported versionbit (BIP 9) softfork deployments",
542+
{
543+
{RPCResult::Type::NUM, "rulename", "identifies the bit number as indicating acceptance and readiness for the named softfork rule"},
544+
}},
545+
{RPCResult::Type::NUM, "vbrequired", "bit mask of versionbits the server requires set in submissions"},
546+
{RPCResult::Type::STR, "previousblockhash", "The hash of current highest block"},
547+
{RPCResult::Type::ARR, "transactions", "contents of non-coinbase transactions that should be included in the next block",
548+
{
549+
{RPCResult::Type::OBJ, "", "",
535550
{
536-
{RPCResult::Type::NUM, "version", "The preferred block version"},
537-
{RPCResult::Type::ARR, "rules", "specific block rules that are to be enforced",
538-
{
539-
{RPCResult::Type::STR, "", "name of a rule the client must understand to some extent; see BIP 9 for format"},
540-
}},
541-
{RPCResult::Type::OBJ_DYN, "vbavailable", "set of pending, supported versionbit (BIP 9) softfork deployments",
542-
{
543-
{RPCResult::Type::NUM, "rulename", "identifies the bit number as indicating acceptance and readiness for the named softfork rule"},
544-
}},
545-
{RPCResult::Type::NUM, "vbrequired", "bit mask of versionbits the server requires set in submissions"},
546-
{RPCResult::Type::STR, "previousblockhash", "The hash of current highest block"},
547-
{RPCResult::Type::ARR, "transactions", "contents of non-coinbase transactions that should be included in the next block",
548-
{
549-
{RPCResult::Type::OBJ, "", "",
550-
{
551-
{RPCResult::Type::STR_HEX, "data", "transaction data encoded in hexadecimal (byte-for-byte)"},
552-
{RPCResult::Type::STR_HEX, "txid", "transaction id encoded in little-endian hexadecimal"},
553-
{RPCResult::Type::STR_HEX, "hash", "hash encoded in little-endian hexadecimal (including witness data)"},
554-
{RPCResult::Type::ARR, "depends", "array of numbers",
555-
{
556-
{RPCResult::Type::NUM, "", "transactions before this one (by 1-based index in 'transactions' list) that must be present in the final block if this one is"},
557-
}},
558-
{RPCResult::Type::NUM, "fee", "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"},
559-
{RPCResult::Type::NUM, "sigops", "total SigOps cost, as counted for purposes of block limits; if key is not present, sigop cost is unknown and clients MUST NOT assume it is zero"},
560-
{RPCResult::Type::NUM, "weight", "total transaction weight, as counted for purposes of block limits"},
561-
}},
562-
}},
563-
{RPCResult::Type::OBJ_DYN, "coinbaseaux", "data that should be included in the coinbase's scriptSig content",
551+
{RPCResult::Type::STR_HEX, "data", "transaction data encoded in hexadecimal (byte-for-byte)"},
552+
{RPCResult::Type::STR_HEX, "txid", "transaction id encoded in little-endian hexadecimal"},
553+
{RPCResult::Type::STR_HEX, "hash", "hash encoded in little-endian hexadecimal (including witness data)"},
554+
{RPCResult::Type::ARR, "depends", "array of numbers",
564555
{
565-
{RPCResult::Type::STR_HEX, "key", "values must be in the coinbase (keys may be ignored)"},
556+
{RPCResult::Type::NUM, "", "transactions before this one (by 1-based index in 'transactions' list) that must be present in the final block if this one is"},
566557
}},
567-
{RPCResult::Type::NUM, "coinbasevalue", "maximum allowable input to coinbase transaction, including the generation award and transaction fees (in satoshis)"},
568-
{RPCResult::Type::STR, "longpollid", "an id to include with a request to longpoll on an update to this template"},
569-
{RPCResult::Type::STR, "target", "The hash target"},
570-
{RPCResult::Type::NUM_TIME, "mintime", "The minimum timestamp appropriate for the next block time, expressed in " + UNIX_EPOCH_TIME},
571-
{RPCResult::Type::ARR, "mutable", "list of ways the block template may be changed",
572-
{
573-
{RPCResult::Type::STR, "value", "A way the block template may be changed, e.g. 'time', 'transactions', 'prevblock'"},
574-
}},
575-
{RPCResult::Type::STR_HEX, "noncerange", "A range of valid nonces"},
576-
{RPCResult::Type::NUM, "sigoplimit", "limit of sigops in blocks"},
577-
{RPCResult::Type::NUM, "sizelimit", "limit of block size"},
578-
{RPCResult::Type::NUM, "weightlimit", "limit of block weight"},
579-
{RPCResult::Type::NUM_TIME, "curtime", "current timestamp in " + UNIX_EPOCH_TIME},
580-
{RPCResult::Type::STR, "bits", "compressed target of next block"},
581-
{RPCResult::Type::NUM, "height", "The height of the next block"},
582-
{RPCResult::Type::STR, "default_witness_commitment", /* optional */ true, "a valid witness commitment for the unmodified block template"}
558+
{RPCResult::Type::NUM, "fee", "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"},
559+
{RPCResult::Type::NUM, "sigops", "total SigOps cost, as counted for purposes of block limits; if key is not present, sigop cost is unknown and clients MUST NOT assume it is zero"},
560+
{RPCResult::Type::NUM, "weight", "total transaction weight, as counted for purposes of block limits"},
583561
}},
584-
RPCExamples{
562+
}},
563+
{RPCResult::Type::OBJ_DYN, "coinbaseaux", "data that should be included in the coinbase's scriptSig content",
564+
{
565+
{RPCResult::Type::STR_HEX, "key", "values must be in the coinbase (keys may be ignored)"},
566+
}},
567+
{RPCResult::Type::NUM, "coinbasevalue", "maximum allowable input to coinbase transaction, including the generation award and transaction fees (in satoshis)"},
568+
{RPCResult::Type::STR, "longpollid", "an id to include with a request to longpoll on an update to this template"},
569+
{RPCResult::Type::STR, "target", "The hash target"},
570+
{RPCResult::Type::NUM_TIME, "mintime", "The minimum timestamp appropriate for the next block time, expressed in " + UNIX_EPOCH_TIME},
571+
{RPCResult::Type::ARR, "mutable", "list of ways the block template may be changed",
572+
{
573+
{RPCResult::Type::STR, "value", "A way the block template may be changed, e.g. 'time', 'transactions', 'prevblock'"},
574+
}},
575+
{RPCResult::Type::STR_HEX, "noncerange", "A range of valid nonces"},
576+
{RPCResult::Type::NUM, "sigoplimit", "limit of sigops in blocks"},
577+
{RPCResult::Type::NUM, "sizelimit", "limit of block size"},
578+
{RPCResult::Type::NUM, "weightlimit", "limit of block weight"},
579+
{RPCResult::Type::NUM_TIME, "curtime", "current timestamp in " + UNIX_EPOCH_TIME},
580+
{RPCResult::Type::STR, "bits", "compressed target of next block"},
581+
{RPCResult::Type::NUM, "height", "The height of the next block"},
582+
{RPCResult::Type::STR, "default_witness_commitment", /* optional */ true, "a valid witness commitment for the unmodified block template"},
583+
}},
584+
},
585+
RPCExamples{
585586
HelpExampleCli("getblocktemplate", "'{\"rules\": [\"segwit\"]}'")
586587
+ HelpExampleRpc("getblocktemplate", "{\"rules\": [\"segwit\"]}")
587588
},

0 commit comments

Comments
 (0)