diff options
author | fanquake <fanquake@gmail.com> | 2023-08-17 13:34:10 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2023-08-17 13:58:31 +0100 |
commit | ecb20563b6a0cdd615628da9caa1e7389998119c (patch) | |
tree | 56b2755fcf80d2c53c8dc9c0e4104e4e613fcd4f /src/rpc | |
parent | 6d473bad2260fd23c6013581e44c9970b557f495 (diff) | |
parent | 5e3e83b005518659a69916c373b808da27e51791 (diff) |
Merge bitcoin/bitcoin#28123: Bugfix: RPC: Remove quotes from non-string oneline descriptions
5e3e83b005518659a69916c373b808da27e51791 RPC/Mining: Document template_request better for getblocktemplate (Luke Dashjr)
de319c61759952318364fbcb28c47f0959d89d0e RPC/rpcdoccheck: Error if a oneline_description has a quote for a non-string (Luke Dashjr)
7c61e9df90579ed42a30016e52355e437733b128 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 5e3e83b005518659a69916c373b808da27e51791
Tree-SHA512: 363d1669a661d0acfc19fddb57e777d781c7246f330cf62160e77dde10a6adcb0249db748127067da1afe1b7d17c71cf611d9fdc3664d6bf5b3f30105637769a
Diffstat (limited to 'src/rpc')
-rw-r--r-- | src/rpc/blockchain.cpp | 2 | ||||
-rw-r--r-- | src/rpc/mining.cpp | 4 | ||||
-rw-r--r-- | src/rpc/util.cpp | 11 |
3 files changed, 13 insertions, 4 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 717a119b56..c57cda0483 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -2312,7 +2312,7 @@ static RPCHelpMan scanblocks() { {"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"}, }, - RPCArgOptions{.oneline_description="\"options\""}}, + RPCArgOptions{.oneline_description="options"}}, }, { scan_result_status_none, diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 1f9b264626..a9f9d485fb 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -554,7 +554,7 @@ static RPCHelpMan getblocktemplate() " https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki#getblocktemplate_changes\n" " https://github.com/bitcoin/bips/blob/master/bip-0145.mediawiki\n", { - {"template_request", RPCArg::Type::OBJ, RPCArg::Default{UniValue::VOBJ}, "Format of the template", + {"template_request", RPCArg::Type::OBJ, RPCArg::Optional::NO, "Format of the template", { {"mode", RPCArg::Type::STR, /* treat as named arg */ RPCArg::Optional::OMITTED, "This must be set to \"template\", \"proposal\" (see BIP 23), or omitted"}, {"capabilities", RPCArg::Type::ARR, /* treat as named arg */ RPCArg::Optional::OMITTED, "A list of strings", @@ -569,7 +569,7 @@ static RPCHelpMan getblocktemplate() {"longpollid", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "delay processing request until the result would vary significantly from the \"longpollid\" of a prior template"}, {"data", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, "proposed block data to check, encoded in hexadecimal; valid only for mode=\"proposal\""}, }, - RPCArgOptions{.oneline_description="\"template_request\""}}, + }, }, { RPCResult{"If the proposal was accepted with mode=='proposal'", RPCResult::Type::NONE, "", ""}, diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index 2732f1297a..08a778a60e 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -1138,7 +1138,16 @@ std::string RPCArg::ToStringObj(const bool oneline) const std::string RPCArg::ToString(const bool oneline) const { - if (oneline && !m_opts.oneline_description.empty()) return m_opts.oneline_description; + if (oneline && !m_opts.oneline_description.empty()) { + if (m_opts.oneline_description[0] == '\"' && m_type != Type::STR_HEX && m_type != Type::STR && gArgs.GetBoolArg("-rpcdoccheck", DEFAULT_RPC_DOC_CHECK)) { + throw std::runtime_error{ + strprintf("Internal bug detected: non-string RPC arg \"%s\" quotes oneline_description:\n%s\n%s %s\nPlease report this issue here: %s\n", + m_names, m_opts.oneline_description, + PACKAGE_NAME, FormatFullVersion(), + PACKAGE_BUGREPORT)}; + } + return m_opts.oneline_description; + } switch (m_type) { case Type::STR_HEX: |