Skip to content

Commit ecb2056

Browse files
committed
Merge bitcoin/bitcoin#28123: Bugfix: RPC: Remove quotes from non-string oneline descriptions
5e3e83b RPC/Mining: Document template_request better for getblocktemplate (Luke Dashjr) de319c6 RPC/rpcdoccheck: Error if a oneline_description has a quote for a non-string (Luke Dashjr) 7c61e9d Bugfix: RPC: Remove quotes from non-string oneline descriptions (Luke Dashjr) Pull request description: Various JSON Object parameters had a `oneline_description` with quote characters. Fix those, and extend `rpcdoccheck` to detect them. Also, slightly improve GBT's oneline description for template_request. ACKs for top commit: MarcoFalke: review ACK 5e3e83b Tree-SHA512: 363d1669a661d0acfc19fddb57e777d781c7246f330cf62160e77dde10a6adcb0249db748127067da1afe1b7d17c71cf611d9fdc3664d6bf5b3f30105637769a
2 parents 6d473ba + 5e3e83b commit ecb2056

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

src/rpc/blockchain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2312,7 +2312,7 @@ static RPCHelpMan scanblocks()
23122312
{
23132313
{"filter_false_positives", RPCArg::Type::BOOL, RPCArg::Default{false}, "Filter false positives (slower and may fail on pruned nodes). Otherwise they may occur at a rate of 1/M"},
23142314
},
2315-
RPCArgOptions{.oneline_description="\"options\""}},
2315+
RPCArgOptions{.oneline_description="options"}},
23162316
},
23172317
{
23182318
scan_result_status_none,

src/rpc/mining.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ static RPCHelpMan getblocktemplate()
554554
" https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki#getblocktemplate_changes\n"
555555
" https://github.com/bitcoin/bips/blob/master/bip-0145.mediawiki\n",
556556
{
557-
{"template_request", RPCArg::Type::OBJ, RPCArg::Default{UniValue::VOBJ}, "Format of the template",
557+
{"template_request", RPCArg::Type::OBJ, RPCArg::Optional::NO, "Format of the template",
558558
{
559559
{"mode", RPCArg::Type::STR, /* treat as named arg */ RPCArg::Optional::OMITTED, "This must be set to \"template\", \"proposal\" (see BIP 23), or omitted"},
560560
{"capabilities", RPCArg::Type::ARR, /* treat as named arg */ RPCArg::Optional::OMITTED, "A list of strings",
@@ -569,7 +569,7 @@ static RPCHelpMan getblocktemplate()
569569
{"longpollid", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "delay processing request until the result would vary significantly from the \"longpollid\" of a prior template"},
570570
{"data", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, "proposed block data to check, encoded in hexadecimal; valid only for mode=\"proposal\""},
571571
},
572-
RPCArgOptions{.oneline_description="\"template_request\""}},
572+
},
573573
},
574574
{
575575
RPCResult{"If the proposal was accepted with mode=='proposal'", RPCResult::Type::NONE, "", ""},

src/rpc/util.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,16 @@ std::string RPCArg::ToStringObj(const bool oneline) const
11381138

11391139
std::string RPCArg::ToString(const bool oneline) const
11401140
{
1141-
if (oneline && !m_opts.oneline_description.empty()) return m_opts.oneline_description;
1141+
if (oneline && !m_opts.oneline_description.empty()) {
1142+
if (m_opts.oneline_description[0] == '\"' && m_type != Type::STR_HEX && m_type != Type::STR && gArgs.GetBoolArg("-rpcdoccheck", DEFAULT_RPC_DOC_CHECK)) {
1143+
throw std::runtime_error{
1144+
strprintf("Internal bug detected: non-string RPC arg \"%s\" quotes oneline_description:\n%s\n%s %s\nPlease report this issue here: %s\n",
1145+
m_names, m_opts.oneline_description,
1146+
PACKAGE_NAME, FormatFullVersion(),
1147+
PACKAGE_BUGREPORT)};
1148+
}
1149+
return m_opts.oneline_description;
1150+
}
11421151

11431152
switch (m_type) {
11441153
case Type::STR_HEX:

src/wallet/rpc/backup.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,12 +1297,12 @@ RPCHelpMan importmulti()
12971297
},
12981298
},
12991299
},
1300-
RPCArgOptions{.oneline_description="\"requests\""}},
1300+
RPCArgOptions{.oneline_description="requests"}},
13011301
{"options", RPCArg::Type::OBJ_NAMED_PARAMS, RPCArg::Optional::OMITTED, "",
13021302
{
13031303
{"rescan", RPCArg::Type::BOOL, RPCArg::Default{true}, "Scan the chain and mempool for wallet transactions after all imports."},
13041304
},
1305-
RPCArgOptions{.oneline_description="\"options\""}},
1305+
RPCArgOptions{.oneline_description="options"}},
13061306
},
13071307
RPCResult{
13081308
RPCResult::Type::ARR, "", "Response is an array with the same size as the input that has the execution result",
@@ -1617,7 +1617,7 @@ RPCHelpMan importdescriptors()
16171617
},
16181618
},
16191619
},
1620-
RPCArgOptions{.oneline_description="\"requests\""}},
1620+
RPCArgOptions{.oneline_description="requests"}},
16211621
},
16221622
RPCResult{
16231623
RPCResult::Type::ARR, "", "Response is an array with the same size as the input that has the execution result",

test/functional/mining_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def assert_submitblock(block, result_str_1, result_str_2=None):
172172
block.vtx = [coinbase_tx]
173173

174174
self.log.info("getblocktemplate: segwit rule must be set")
175-
assert_raises_rpc_error(-8, "getblocktemplate must be called with the segwit rule set", node.getblocktemplate)
175+
assert_raises_rpc_error(-8, "getblocktemplate must be called with the segwit rule set", node.getblocktemplate, {})
176176

177177
self.log.info("getblocktemplate: Test valid block")
178178
assert_template(node, block, None)

0 commit comments

Comments
 (0)