Skip to content

Commit 0eebe45

Browse files
author
MarcoFalke
committed
Merge #18208: rpc: Change RPCExamples to bech32
3e32499 Change example addresses to bech32 (Yusuf Sahin HAMZA) Pull request description: This is a follow-up PR to #18197 that fixes RPCExamples. Fixes #18185. ACKs for top commit: MarcoFalke: ACK 3e32499 jonatack: ACK 3e32499 Tree-SHA512: c7a6410ef8b6e169016c2c5eac3e6b9501caabd0e8a0871ec31e56bfc44589f056d3f5cb55b5a13bba36f6c15136c2352f883e30e4dcc0997ffd36b27f9173b9
2 parents 24a727e + 3e32499 commit 0eebe45

File tree

5 files changed

+28
-28
lines changed

5 files changed

+28
-28
lines changed

doc/developer-notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ A few guidelines for introducing and reviewing new RPC interfaces:
10901090
new RPC is replacing a deprecated RPC, to avoid both RPCs confusingly
10911091
showing up in the command list.
10921092

1093-
- Use *invalid* bech32 addresses (e.g. the constant `EXAMPLE_ADDRESS`) for
1093+
- Use *invalid* bech32 addresses (e.g. in the constant array `EXAMPLE_ADDRESS`) for
10941094
`RPCExamples` help documentation.
10951095

10961096
- *Rationale*: Prevent accidental transactions by users and encourage the use

src/rpc/misc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ static UniValue validateaddress(const JSONRPCRequest& request)
4545
}
4646
},
4747
RPCExamples{
48-
HelpExampleCli("validateaddress", EXAMPLE_ADDRESS) +
49-
HelpExampleRpc("validateaddress", EXAMPLE_ADDRESS)
48+
HelpExampleCli("validateaddress", "\"" + EXAMPLE_ADDRESS[0] + "\"") +
49+
HelpExampleRpc("validateaddress", "\"" + EXAMPLE_ADDRESS[0] + "\"")
5050
},
5151
}.Check(request);
5252

src/rpc/util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <tuple>
1515

1616
const std::string UNIX_EPOCH_TIME = "UNIX epoch time";
17-
const std::string EXAMPLE_ADDRESS = "\"bc1q09vm5lfy0j5reeulh4x5752q25uqqvz34hufdl\"";
17+
const std::string EXAMPLE_ADDRESS[2] = {"bc1q09vm5lfy0j5reeulh4x5752q25uqqvz34hufdl", "bc1q02ad21edsxd23d32dfgqqsz4vv4nmtfzuklhy3"};
1818

1919
void RPCTypeCheck(const UniValue& params,
2020
const std::list<UniValueType>& typesExpected,

src/rpc/util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
extern const std::string UNIX_EPOCH_TIME;
3030

3131
/**
32-
* Example bech32 address used in multiple RPCExamples. The address is intentionally
32+
* Example bech32 addresses for the RPCExamples help documentation. They are intentionally
3333
* invalid to prevent accidental transactions by users.
3434
*/
35-
extern const std::string EXAMPLE_ADDRESS;
35+
extern const std::string EXAMPLE_ADDRESS[2];
3636

3737
class FillableSigningProvider;
3838
class CPubKey;

src/wallet/rpcwallet.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,8 @@ static UniValue setlabel(const JSONRPCRequest& request)
303303
},
304304
RPCResults{},
305305
RPCExamples{
306-
HelpExampleCli("setlabel", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"tabby\"")
307-
+ HelpExampleRpc("setlabel", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"tabby\"")
306+
HelpExampleCli("setlabel", "\"" + EXAMPLE_ADDRESS[0] + "\" \"tabby\"")
307+
+ HelpExampleRpc("setlabel", "\"" + EXAMPLE_ADDRESS[0] + "\", \"tabby\"")
308308
},
309309
}.Check(request);
310310

@@ -393,10 +393,10 @@ static UniValue sendtoaddress(const JSONRPCRequest& request)
393393
RPCResult::Type::STR_HEX, "txid", "The transaction id."
394394
},
395395
RPCExamples{
396-
HelpExampleCli("sendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1")
397-
+ HelpExampleCli("sendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1 \"donation\" \"seans outpost\"")
398-
+ HelpExampleCli("sendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1 \"\" \"\" true")
399-
+ HelpExampleRpc("sendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", 0.1, \"donation\", \"seans outpost\"")
396+
HelpExampleCli("sendtoaddress", "\"" + EXAMPLE_ADDRESS[0] + "\" 0.1")
397+
+ HelpExampleCli("sendtoaddress", "\"" + EXAMPLE_ADDRESS[0] + "\" 0.1 \"donation\" \"seans outpost\"")
398+
+ HelpExampleCli("sendtoaddress", "\"" + EXAMPLE_ADDRESS[0] + "\" 0.1 \"\" \"\" true")
399+
+ HelpExampleRpc("sendtoaddress", "\"" + EXAMPLE_ADDRESS[0] + "\", 0.1, \"donation\", \"seans outpost\"")
400400
},
401401
}.Check(request);
402402

@@ -596,13 +596,13 @@ static UniValue getreceivedbyaddress(const JSONRPCRequest& request)
596596
},
597597
RPCExamples{
598598
"\nThe amount from transactions with at least 1 confirmation\n"
599-
+ HelpExampleCli("getreceivedbyaddress", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\"") +
599+
+ HelpExampleCli("getreceivedbyaddress", "\"" + EXAMPLE_ADDRESS[0] + "\"") +
600600
"\nThe amount including unconfirmed transactions, zero confirmations\n"
601-
+ HelpExampleCli("getreceivedbyaddress", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 0") +
601+
+ HelpExampleCli("getreceivedbyaddress", "\"" + EXAMPLE_ADDRESS[0] + "\" 0") +
602602
"\nThe amount with at least 6 confirmations\n"
603-
+ HelpExampleCli("getreceivedbyaddress", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 6") +
603+
+ HelpExampleCli("getreceivedbyaddress", "\"" + EXAMPLE_ADDRESS[0] + "\" 6") +
604604
"\nAs a JSON-RPC call\n"
605-
+ HelpExampleRpc("getreceivedbyaddress", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", 6")
605+
+ HelpExampleRpc("getreceivedbyaddress", "\"" + EXAMPLE_ADDRESS[0] + "\", 6")
606606
},
607607
}.Check(request);
608608

@@ -841,13 +841,13 @@ static UniValue sendmany(const JSONRPCRequest& request)
841841
},
842842
RPCExamples{
843843
"\nSend two amounts to two different addresses:\n"
844-
+ HelpExampleCli("sendmany", "\"\" \"{\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\\\":0.01,\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\"") +
844+
+ HelpExampleCli("sendmany", "\"\" \"{\\\"" + EXAMPLE_ADDRESS[0] + "\\\":0.01,\\\"" + EXAMPLE_ADDRESS[1] + "\\\":0.02}\"") +
845845
"\nSend two amounts to two different addresses setting the confirmation and comment:\n"
846-
+ HelpExampleCli("sendmany", "\"\" \"{\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\\\":0.01,\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\" 6 \"testing\"") +
846+
+ HelpExampleCli("sendmany", "\"\" \"{\\\"" + EXAMPLE_ADDRESS[0] + "\\\":0.01,\\\"" + EXAMPLE_ADDRESS[1] + "\\\":0.02}\" 6 \"testing\"") +
847847
"\nSend two amounts to two different addresses, subtract fee from amount:\n"
848-
+ HelpExampleCli("sendmany", "\"\" \"{\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\\\":0.01,\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\" 1 \"\" \"[\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\\\",\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\"]\"") +
848+
+ HelpExampleCli("sendmany", "\"\" \"{\\\"" + EXAMPLE_ADDRESS[0] + "\\\":0.01,\\\"" + EXAMPLE_ADDRESS[1] + "\\\":0.02}\" 1 \"\" \"[\\\"" + EXAMPLE_ADDRESS[0] + "\\\",\\\"" + EXAMPLE_ADDRESS[1] + "\\\"]\"") +
849849
"\nAs a JSON-RPC call\n"
850-
+ HelpExampleRpc("sendmany", "\"\", {\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\":0.01,\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\":0.02}, 6, \"testing\"")
850+
+ HelpExampleRpc("sendmany", "\"\", {\"" + EXAMPLE_ADDRESS[0] + "\":0.01,\"" + EXAMPLE_ADDRESS[1] + "\":0.02}, 6, \"testing\"")
851851
},
852852
}.Check(request);
853853

@@ -969,9 +969,9 @@ static UniValue addmultisigaddress(const JSONRPCRequest& request)
969969
},
970970
RPCExamples{
971971
"\nAdd a multisig address from 2 addresses\n"
972-
+ HelpExampleCli("addmultisigaddress", "2 \"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") +
972+
+ HelpExampleCli("addmultisigaddress", "2 \"[\\\"" + EXAMPLE_ADDRESS[0] + "\\\",\\\"" + EXAMPLE_ADDRESS[1] + "\\\"]\"") +
973973
"\nAs a JSON-RPC call\n"
974-
+ HelpExampleRpc("addmultisigaddress", "2, \"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"")
974+
+ HelpExampleRpc("addmultisigaddress", "2, \"[\\\"" + EXAMPLE_ADDRESS[0] + "\\\",\\\"" + EXAMPLE_ADDRESS[1] + "\\\"]\"")
975975
},
976976
}.Check(request);
977977

@@ -1214,7 +1214,7 @@ static UniValue listreceivedbyaddress(const JSONRPCRequest& request)
12141214
HelpExampleCli("listreceivedbyaddress", "")
12151215
+ HelpExampleCli("listreceivedbyaddress", "6 true")
12161216
+ HelpExampleRpc("listreceivedbyaddress", "6, true, true")
1217-
+ HelpExampleRpc("listreceivedbyaddress", "6, true, true, \"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\"")
1217+
+ HelpExampleRpc("listreceivedbyaddress", "6, true, true, \"" + EXAMPLE_ADDRESS[0] + "\"")
12181218
},
12191219
}.Check(request);
12201220

@@ -2042,7 +2042,7 @@ static UniValue walletlock(const JSONRPCRequest& request)
20422042
"\nSet the passphrase for 2 minutes to perform a transaction\n"
20432043
+ HelpExampleCli("walletpassphrase", "\"my pass phrase\" 120") +
20442044
"\nPerform a send (requires passphrase set)\n"
2045-
+ HelpExampleCli("sendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 1.0") +
2045+
+ HelpExampleCli("sendtoaddress", "\"" + EXAMPLE_ADDRESS[0] + "\" 1.0") +
20462046
"\nClear the passphrase since we are done before 2 minutes is up\n"
20472047
+ HelpExampleCli("walletlock", "") +
20482048
"\nAs a JSON-RPC call\n"
@@ -2859,8 +2859,8 @@ static UniValue listunspent(const JSONRPCRequest& request)
28592859
},
28602860
RPCExamples{
28612861
HelpExampleCli("listunspent", "")
2862-
+ HelpExampleCli("listunspent", "6 9999999 \"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\",\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"")
2863-
+ HelpExampleRpc("listunspent", "6, 9999999 \"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\",\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"")
2862+
+ HelpExampleCli("listunspent", "6 9999999 \"[\\\"" + EXAMPLE_ADDRESS[0] + "\\\",\\\"" + EXAMPLE_ADDRESS[1] + "\\\"]\"")
2863+
+ HelpExampleRpc("listunspent", "6, 9999999 \"[\\\"" + EXAMPLE_ADDRESS[0] + "\\\",\\\"" + EXAMPLE_ADDRESS[1] + "\\\"]\"")
28642864
+ HelpExampleCli("listunspent", "6 9999999 '[]' true '{ \"minimumAmount\": 0.005 }'")
28652865
+ HelpExampleRpc("listunspent", "6, 9999999, [] , true, { \"minimumAmount\": 0.005 } ")
28662866
},
@@ -3798,8 +3798,8 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
37983798
}
37993799
},
38003800
RPCExamples{
3801-
HelpExampleCli("getaddressinfo", EXAMPLE_ADDRESS) +
3802-
HelpExampleRpc("getaddressinfo", EXAMPLE_ADDRESS)
3801+
HelpExampleCli("getaddressinfo", "\"" + EXAMPLE_ADDRESS[0] + "\"") +
3802+
HelpExampleRpc("getaddressinfo", "\"" + EXAMPLE_ADDRESS[0] + "\"")
38033803
},
38043804
}.Check(request);
38053805

0 commit comments

Comments
 (0)