Skip to content

Commit fae840e

Browse files
author
MarcoFalke
committed
rpc: Reject beginning newline in RPC docs
It is harmless, but a bit confusing and not needed for new code. Also, update the remaining instances that were not found by the scripted-diff.
1 parent fa414ed commit fae840e

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

src/rpc/node.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,9 @@ static RPCHelpMan logging()
273273

274274
static RPCHelpMan echo(const std::string& name)
275275
{
276-
return RPCHelpMan{name,
277-
"\nSimply echo back the input arguments. This command is for testing.\n"
276+
return RPCHelpMan{
277+
name,
278+
"Simply echo back the input arguments. This command is for testing.\n"
278279
"\nIt will return an internal bug report when arg9='trigger_internal_bug' is passed.\n"
279280
"\nThe difference between echo and echojson is that echojson has argument conversion enabled in the client-side table in "
280281
"bitcoin-cli and the GUI. There is no server-side difference.",

src/rpc/output_script.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,9 @@ static RPCHelpMan getdescriptorinfo()
169169
{
170170
const std::string EXAMPLE_DESCRIPTOR = "wpkh([d34db33f/84h/0h/0h]0279be667ef9dcbbac55a06295Ce870b07029Bfcdb2dce28d959f2815b16f81798)";
171171

172-
return RPCHelpMan{"getdescriptorinfo",
173-
{"\nAnalyses a descriptor.\n"},
172+
return RPCHelpMan{
173+
"getdescriptorinfo",
174+
"Analyses a descriptor.\n",
174175
{
175176
{"descriptor", RPCArg::Type::STR, RPCArg::Optional::NO, "The descriptor."},
176177
},
@@ -260,8 +261,9 @@ static RPCHelpMan deriveaddresses()
260261
{
261262
const std::string EXAMPLE_DESCRIPTOR = "wpkh([d34db33f/84h/0h/0h]xpub6DJ2dNUysrn5Vt36jH2KLBT2i1auw1tTSSomg8PhqNiUtx8QX2SvC9nrHu81fT41fvDUnhMjEzQgXnQjKEu3oaqMSzhSrHMxyyoEAmUHQbY/0/*)#cjjspncu";
262263

263-
return RPCHelpMan{"deriveaddresses",
264-
{"\nDerives one or more addresses corresponding to an output descriptor.\n"
264+
return RPCHelpMan{
265+
"deriveaddresses",
266+
"Derives one or more addresses corresponding to an output descriptor.\n"
265267
"Examples of output descriptors are:\n"
266268
" pkh(<pubkey>) P2PKH outputs for the given pubkey\n"
267269
" wpkh(<pubkey>) Native segwit P2PKH outputs for the given pubkey\n"
@@ -270,7 +272,7 @@ static RPCHelpMan deriveaddresses()
270272
" tr(<pubkey>,multi_a(<n>,<pubkey>,<pubkey>,...)) P2TR-multisig outputs for the given threshold and pubkeys\n"
271273
"\nIn the above, <pubkey> either refers to a fixed public key in hexadecimal notation, or to an xpub/xprv optionally followed by one\n"
272274
"or more path elements separated by \"/\", where \"h\" represents a hardened child key.\n"
273-
"For more information on output descriptors, see the documentation in the doc/descriptors.md file.\n"},
275+
"For more information on output descriptors, see the documentation in the doc/descriptors.md file.\n",
274276
{
275277
{"descriptor", RPCArg::Type::STR, RPCArg::Optional::NO, "The descriptor."},
276278
{"range", RPCArg::Type::RANGE, RPCArg::Optional::OMITTED, "If a ranged descriptor is used, this specifies the end or the range (in [begin,end] notation) to derive."},

src/rpc/server.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,12 @@ static RPCHelpMan help()
156156
static RPCHelpMan stop()
157157
{
158158
static const std::string RESULT{CLIENT_NAME " stopping"};
159-
return RPCHelpMan{"stop",
159+
return RPCHelpMan{
160+
"stop",
160161
// Also accept the hidden 'wait' integer argument (milliseconds)
161162
// For instance, 'stop 1000' makes the call wait 1 second before returning
162163
// to the client (intended for testing)
163-
"\nRequest a graceful shutdown of " CLIENT_NAME ".",
164+
"Request a graceful shutdown of " CLIENT_NAME ".",
164165
{
165166
{"wait", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, "how long to wait in ms", RPCArgOptions{.hidden=true}},
166167
},

src/rpc/util.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2017-2022 The Bitcoin Core developers
1+
// Copyright (c) 2017-present The Bitcoin Core developers
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

@@ -814,6 +814,7 @@ std::string RPCHelpMan::ToString() const
814814
if (was_optional) ret += " )";
815815

816816
// Description
817+
CHECK_NONFATAL(!m_description.starts_with('\n')); // Historically \n was required, but reject it for new code.
817818
ret += "\n\n" + TrimString(m_description) + "\n";
818819

819820
// Arguments

0 commit comments

Comments
 (0)