Skip to content

Commit 3e32499

Browse files
Change example addresses to bech32
1 parent 31c0006 commit 3e32499

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
@@ -1089,7 +1089,7 @@ A few guidelines for introducing and reviewing new RPC interfaces:
10891089
new RPC is replacing a deprecated RPC, to avoid both RPCs confusingly
10901090
showing up in the command list.
10911091

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

10951095
- *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
@@ -44,8 +44,8 @@ static UniValue validateaddress(const JSONRPCRequest& request)
4444
"}\n"
4545
},
4646
RPCExamples{
47-
HelpExampleCli("validateaddress", EXAMPLE_ADDRESS) +
48-
HelpExampleRpc("validateaddress", EXAMPLE_ADDRESS)
47+
HelpExampleCli("validateaddress", "\"" + EXAMPLE_ADDRESS[0] + "\"") +
48+
HelpExampleRpc("validateaddress", "\"" + EXAMPLE_ADDRESS[0] + "\"")
4949
},
5050
}.Check(request);
5151

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
"\"txid\" (string) The transaction id.\n"
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

@@ -605,13 +605,13 @@ static UniValue getreceivedbyaddress(const JSONRPCRequest& request)
605605
},
606606
RPCExamples{
607607
"\nThe amount from transactions with at least 1 confirmation\n"
608-
+ HelpExampleCli("getreceivedbyaddress", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\"") +
608+
+ HelpExampleCli("getreceivedbyaddress", "\"" + EXAMPLE_ADDRESS[0] + "\"") +
609609
"\nThe amount including unconfirmed transactions, zero confirmations\n"
610-
+ HelpExampleCli("getreceivedbyaddress", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 0") +
610+
+ HelpExampleCli("getreceivedbyaddress", "\"" + EXAMPLE_ADDRESS[0] + "\" 0") +
611611
"\nThe amount with at least 6 confirmations\n"
612-
+ HelpExampleCli("getreceivedbyaddress", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 6") +
612+
+ HelpExampleCli("getreceivedbyaddress", "\"" + EXAMPLE_ADDRESS[0] + "\" 6") +
613613
"\nAs a JSON-RPC call\n"
614-
+ HelpExampleRpc("getreceivedbyaddress", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", 6")
614+
+ HelpExampleRpc("getreceivedbyaddress", "\"" + EXAMPLE_ADDRESS[0] + "\", 6")
615615
},
616616
}.Check(request);
617617

@@ -850,13 +850,13 @@ static UniValue sendmany(const JSONRPCRequest& request)
850850
},
851851
RPCExamples{
852852
"\nSend two amounts to two different addresses:\n"
853-
+ HelpExampleCli("sendmany", "\"\" \"{\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\\\":0.01,\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\"") +
853+
+ HelpExampleCli("sendmany", "\"\" \"{\\\"" + EXAMPLE_ADDRESS[0] + "\\\":0.01,\\\"" + EXAMPLE_ADDRESS[1] + "\\\":0.02}\"") +
854854
"\nSend two amounts to two different addresses setting the confirmation and comment:\n"
855-
+ HelpExampleCli("sendmany", "\"\" \"{\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\\\":0.01,\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\" 6 \"testing\"") +
855+
+ HelpExampleCli("sendmany", "\"\" \"{\\\"" + EXAMPLE_ADDRESS[0] + "\\\":0.01,\\\"" + EXAMPLE_ADDRESS[1] + "\\\":0.02}\" 6 \"testing\"") +
856856
"\nSend two amounts to two different addresses, subtract fee from amount:\n"
857-
+ HelpExampleCli("sendmany", "\"\" \"{\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\\\":0.01,\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\" 1 \"\" \"[\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\\\",\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\"]\"") +
857+
+ HelpExampleCli("sendmany", "\"\" \"{\\\"" + EXAMPLE_ADDRESS[0] + "\\\":0.01,\\\"" + EXAMPLE_ADDRESS[1] + "\\\":0.02}\" 1 \"\" \"[\\\"" + EXAMPLE_ADDRESS[0] + "\\\",\\\"" + EXAMPLE_ADDRESS[1] + "\\\"]\"") +
858858
"\nAs a JSON-RPC call\n"
859-
+ HelpExampleRpc("sendmany", "\"\", {\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\":0.01,\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\":0.02}, 6, \"testing\"")
859+
+ HelpExampleRpc("sendmany", "\"\", {\"" + EXAMPLE_ADDRESS[0] + "\":0.01,\"" + EXAMPLE_ADDRESS[1] + "\":0.02}, 6, \"testing\"")
860860
},
861861
}.Check(request);
862862

@@ -977,9 +977,9 @@ static UniValue addmultisigaddress(const JSONRPCRequest& request)
977977
},
978978
RPCExamples{
979979
"\nAdd a multisig address from 2 addresses\n"
980-
+ HelpExampleCli("addmultisigaddress", "2 \"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") +
980+
+ HelpExampleCli("addmultisigaddress", "2 \"[\\\"" + EXAMPLE_ADDRESS[0] + "\\\",\\\"" + EXAMPLE_ADDRESS[1] + "\\\"]\"") +
981981
"\nAs a JSON-RPC call\n"
982-
+ HelpExampleRpc("addmultisigaddress", "2, \"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"")
982+
+ HelpExampleRpc("addmultisigaddress", "2, \"[\\\"" + EXAMPLE_ADDRESS[0] + "\\\",\\\"" + EXAMPLE_ADDRESS[1] + "\\\"]\"")
983983
},
984984
}.Check(request);
985985

@@ -1221,7 +1221,7 @@ static UniValue listreceivedbyaddress(const JSONRPCRequest& request)
12211221
HelpExampleCli("listreceivedbyaddress", "")
12221222
+ HelpExampleCli("listreceivedbyaddress", "6 true")
12231223
+ HelpExampleRpc("listreceivedbyaddress", "6, true, true")
1224-
+ HelpExampleRpc("listreceivedbyaddress", "6, true, true, \"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\"")
1224+
+ HelpExampleRpc("listreceivedbyaddress", "6, true, true, \"" + EXAMPLE_ADDRESS[0] + "\"")
12251225
},
12261226
}.Check(request);
12271227

@@ -2033,7 +2033,7 @@ static UniValue walletlock(const JSONRPCRequest& request)
20332033
"\nSet the passphrase for 2 minutes to perform a transaction\n"
20342034
+ HelpExampleCli("walletpassphrase", "\"my pass phrase\" 120") +
20352035
"\nPerform a send (requires passphrase set)\n"
2036-
+ HelpExampleCli("sendtoaddress", "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 1.0") +
2036+
+ HelpExampleCli("sendtoaddress", "\"" + EXAMPLE_ADDRESS[0] + "\" 1.0") +
20372037
"\nClear the passphrase since we are done before 2 minutes is up\n"
20382038
+ HelpExampleCli("walletlock", "") +
20392039
"\nAs a JSON-RPC call\n"
@@ -2837,8 +2837,8 @@ static UniValue listunspent(const JSONRPCRequest& request)
28372837
},
28382838
RPCExamples{
28392839
HelpExampleCli("listunspent", "")
2840-
+ HelpExampleCli("listunspent", "6 9999999 \"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\",\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"")
2841-
+ HelpExampleRpc("listunspent", "6, 9999999 \"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\",\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"")
2840+
+ HelpExampleCli("listunspent", "6 9999999 \"[\\\"" + EXAMPLE_ADDRESS[0] + "\\\",\\\"" + EXAMPLE_ADDRESS[1] + "\\\"]\"")
2841+
+ HelpExampleRpc("listunspent", "6, 9999999 \"[\\\"" + EXAMPLE_ADDRESS[0] + "\\\",\\\"" + EXAMPLE_ADDRESS[1] + "\\\"]\"")
28422842
+ HelpExampleCli("listunspent", "6 9999999 '[]' true '{ \"minimumAmount\": 0.005 }'")
28432843
+ HelpExampleRpc("listunspent", "6, 9999999, [] , true, { \"minimumAmount\": 0.005 } ")
28442844
},
@@ -3774,8 +3774,8 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
37743774
"}\n"
37753775
},
37763776
RPCExamples{
3777-
HelpExampleCli("getaddressinfo", EXAMPLE_ADDRESS) +
3778-
HelpExampleRpc("getaddressinfo", EXAMPLE_ADDRESS)
3777+
HelpExampleCli("getaddressinfo", "\"" + EXAMPLE_ADDRESS[0] + "\"") +
3778+
HelpExampleRpc("getaddressinfo", "\"" + EXAMPLE_ADDRESS[0] + "\"")
37793779
},
37803780
}.Check(request);
37813781

0 commit comments

Comments
 (0)