Skip to content

Commit dd097c4

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#18448: rpc: fix/add missing RPCExamples for "Util" RPCs
ea98d9c rpc: fix/add missing RPCExamples for "Util" RPCs (Sebastian Falbesoner) Pull request description: Similar to bitcoin/bitcoin#18398, this PR gives the RPCExamples in the RPC category "Util" (that currently contains `createmultisig`, `deriveaddresses`, `estimatesmartfee`, `getdescriptorinfo`, `signmessagewithprivkey`, `validateaddress`, `verifymessage`) some love by fixing one broken and adding three missing examples: - fixed `HelpExampleRpc` for `createmultisig` (disturbing escape characters and quotation marks) - added missing `HelpExampleRpc` for - `deriveaddresses` (also put descriptor in a new string constant) - `estimatesmartfee` - `getdescriptorinfo` (also put descriptor in a new string constant) Output for `createmultisig` example on the master branch: ``` $ curl --user __cookie__ --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "createmultisig", "params": [2, "[\"03789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd\",\"03dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a61626\"]"]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/ Enter host password for user '__cookie__': {"result":null,"error":{"code":-1,"message":"JSON value is not an array as expected"},"id":"curltest"} ``` Output for `createmultisig` example on the PR branch: ``` $ curl --user __cookie__ --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "createmultisig", "params": [2, ["03789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd","03dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a61626"]]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/ Enter host password for user '__cookie__': {"result":{"address":"3QsFXpFJf2ZY6GLWVoNFFd2xSDwdS713qX","redeemScript":"522103789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd2103dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a6162652ae","descriptor":"sh(multi(2,03789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd,03dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a61626))#4djp057k"},"error":null,"id":"curltest"} ``` ACKs for top commit: jonatack: ACK ea98d9c looked at the code, rebased to master, ran the helps, did not try running the added json-rpc examples Tree-SHA512: d6ecb6da66f19517065453357d210102e2cc9f1f8037aeb6a9177ff036d0c21773dddf5e0acdbc71edbbde3026e4d1e7ce7c0935cd3e023c60f34e1b173b3299
2 parents a70768d + ea98d9c commit dd097c4

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/rpc/mining.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,8 @@ static RPCHelpMan estimatesmartfee()
10891089
"have been observed to make an estimate for any number of blocks."},
10901090
}},
10911091
RPCExamples{
1092-
HelpExampleCli("estimatesmartfee", "6")
1092+
HelpExampleCli("estimatesmartfee", "6") +
1093+
HelpExampleRpc("estimatesmartfee", "6")
10931094
},
10941095
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
10951096
{

src/rpc/misc.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static RPCHelpMan createmultisig()
109109
"\nCreate a multisig address from 2 public keys\n"
110110
+ HelpExampleCli("createmultisig", "2 \"[\\\"03789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd\\\",\\\"03dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a61626\\\"]\"") +
111111
"\nAs a JSON-RPC call\n"
112-
+ HelpExampleRpc("createmultisig", "2, \"[\\\"03789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd\\\",\\\"03dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a61626\\\"]\"")
112+
+ HelpExampleRpc("createmultisig", "2, [\"03789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd\",\"03dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a61626\"]")
113113
},
114114
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
115115
{
@@ -158,6 +158,8 @@ static RPCHelpMan createmultisig()
158158

159159
static RPCHelpMan getdescriptorinfo()
160160
{
161+
const std::string EXAMPLE_DESCRIPTOR = "wpkh([d34db33f/84h/0h/0h]0279be667ef9dcbbac55a06295Ce870b07029Bfcdb2dce28d959f2815b16f81798)";
162+
161163
return RPCHelpMan{"getdescriptorinfo",
162164
{"\nAnalyses a descriptor.\n"},
163165
{
@@ -175,7 +177,8 @@ static RPCHelpMan getdescriptorinfo()
175177
},
176178
RPCExamples{
177179
"Analyse a descriptor\n" +
178-
HelpExampleCli("getdescriptorinfo", "\"wpkh([d34db33f/84h/0h/0h]0279be667ef9dcbbac55a06295Ce870b07029Bfcdb2dce28d959f2815b16f81798)\"")
180+
HelpExampleCli("getdescriptorinfo", "\"" + EXAMPLE_DESCRIPTOR + "\"") +
181+
HelpExampleRpc("getdescriptorinfo", "\"" + EXAMPLE_DESCRIPTOR + "\"")
179182
},
180183
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
181184
{
@@ -201,6 +204,8 @@ static RPCHelpMan getdescriptorinfo()
201204

202205
static RPCHelpMan deriveaddresses()
203206
{
207+
const std::string EXAMPLE_DESCRIPTOR = "wpkh([d34db33f/84h/0h/0h]xpub6DJ2dNUysrn5Vt36jH2KLBT2i1auw1tTSSomg8PhqNiUtx8QX2SvC9nrHu81fT41fvDUnhMjEzQgXnQjKEu3oaqMSzhSrHMxyyoEAmUHQbY/0/*)#cjjspncu";
208+
204209
return RPCHelpMan{"deriveaddresses",
205210
{"\nDerives one or more addresses corresponding to an output descriptor.\n"
206211
"Examples of output descriptors are:\n"
@@ -223,7 +228,8 @@ static RPCHelpMan deriveaddresses()
223228
},
224229
RPCExamples{
225230
"First three native segwit receive addresses\n" +
226-
HelpExampleCli("deriveaddresses", "\"wpkh([d34db33f/84h/0h/0h]xpub6DJ2dNUysrn5Vt36jH2KLBT2i1auw1tTSSomg8PhqNiUtx8QX2SvC9nrHu81fT41fvDUnhMjEzQgXnQjKEu3oaqMSzhSrHMxyyoEAmUHQbY/0/*)#cjjspncu\" \"[0,2]\"")
231+
HelpExampleCli("deriveaddresses", "\"" + EXAMPLE_DESCRIPTOR + "\" \"[0,2]\"") +
232+
HelpExampleRpc("deriveaddresses", "\"" + EXAMPLE_DESCRIPTOR + "\", \"[0,2]\"")
227233
},
228234
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
229235
{

0 commit comments

Comments
 (0)