|
38 | 38 |
|
39 | 39 |
|
40 | 40 | static const std::string WALLET_ENDPOINT_BASE = "/wallet/";
|
| 41 | +static const std::string HELP_REQUIRING_PASSPHRASE{"\nRequires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.\n"}; |
41 | 42 |
|
42 | 43 | static inline bool GetAvoidReuseFlag(const CWallet* const pwallet, const UniValue& param) {
|
43 | 44 | bool can_avoid_reuse = pwallet->IsWalletFlagSet(WALLET_FLAG_AVOID_REUSE);
|
@@ -98,13 +99,6 @@ std::shared_ptr<CWallet> GetWalletForJSONRPCRequest(const JSONRPCRequest& reques
|
98 | 99 | return wallets.size() == 1 || (request.fHelp && wallets.size() > 0) ? wallets[0] : nullptr;
|
99 | 100 | }
|
100 | 101 |
|
101 |
| -std::string HelpRequiringPassphrase(const CWallet* pwallet) |
102 |
| -{ |
103 |
| - return pwallet && pwallet->IsCrypted() |
104 |
| - ? "\nRequires wallet passphrase to be set with walletpassphrase call." |
105 |
| - : ""; |
106 |
| -} |
107 |
| - |
108 | 102 | bool EnsureWalletIsAvailable(const CWallet* pwallet, bool avoidException)
|
109 | 103 | {
|
110 | 104 | if (pwallet) return true;
|
@@ -369,7 +363,7 @@ static UniValue sendtoaddress(const JSONRPCRequest& request)
|
369 | 363 |
|
370 | 364 | RPCHelpMan{"sendtoaddress",
|
371 | 365 | "\nSend an amount to a given address." +
|
372 |
| - HelpRequiringPassphrase(pwallet) + "\n", |
| 366 | + HELP_REQUIRING_PASSPHRASE, |
373 | 367 | {
|
374 | 368 | {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The bitcoin address to send to."},
|
375 | 369 | {"amount", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, "The amount in " + CURRENCY_UNIT + " to send. eg 0.1"},
|
@@ -527,7 +521,7 @@ static UniValue signmessage(const JSONRPCRequest& request)
|
527 | 521 |
|
528 | 522 | RPCHelpMan{"signmessage",
|
529 | 523 | "\nSign a message with the private key of an address" +
|
530 |
| - HelpRequiringPassphrase(pwallet) + "\n", |
| 524 | + HELP_REQUIRING_PASSPHRASE, |
531 | 525 | {
|
532 | 526 | {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The bitcoin address to use for the private key."},
|
533 | 527 | {"message", RPCArg::Type::STR, RPCArg::Optional::NO, "The message to create a signature of."},
|
@@ -810,7 +804,7 @@ static UniValue sendmany(const JSONRPCRequest& request)
|
810 | 804 |
|
811 | 805 | RPCHelpMan{"sendmany",
|
812 | 806 | "\nSend multiple times. Amounts are double-precision floating point numbers." +
|
813 |
| - HelpRequiringPassphrase(pwallet) + "\n", |
| 807 | + HELP_REQUIRING_PASSPHRASE, |
814 | 808 | {
|
815 | 809 | {"dummy", RPCArg::Type::STR, RPCArg::Optional::NO, "Must be set to \"\" for backwards compatibility.", "\"\""},
|
816 | 810 | {"amounts", RPCArg::Type::OBJ, RPCArg::Optional::NO, "The addresses and amounts",
|
@@ -1851,7 +1845,7 @@ static UniValue keypoolrefill(const JSONRPCRequest& request)
|
1851 | 1845 |
|
1852 | 1846 | RPCHelpMan{"keypoolrefill",
|
1853 | 1847 | "\nFills the keypool."+
|
1854 |
| - HelpRequiringPassphrase(pwallet) + "\n", |
| 1848 | + HELP_REQUIRING_PASSPHRASE, |
1855 | 1849 | {
|
1856 | 1850 | {"newsize", RPCArg::Type::NUM, /* default */ "100", "The new keypool size"},
|
1857 | 1851 | },
|
@@ -3245,7 +3239,7 @@ UniValue signrawtransactionwithwallet(const JSONRPCRequest& request)
|
3245 | 3239 | "\nSign inputs for raw transaction (serialized, hex-encoded).\n"
|
3246 | 3240 | "The second optional argument (may be null) is an array of previous transaction outputs that\n"
|
3247 | 3241 | "this transaction depends on but may not yet be in the block chain." +
|
3248 |
| - HelpRequiringPassphrase(pwallet) + "\n", |
| 3242 | + HELP_REQUIRING_PASSPHRASE, |
3249 | 3243 | {
|
3250 | 3244 | {"hexstring", RPCArg::Type::STR, RPCArg::Optional::NO, "The transaction hex string"},
|
3251 | 3245 | {"prevtxs", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, "The previous dependent transaction outputs",
|
@@ -3980,7 +3974,7 @@ UniValue sethdseed(const JSONRPCRequest& request)
|
3980 | 3974 | "\nSet or generate a new HD wallet seed. Non-HD wallets will not be upgraded to being a HD wallet. Wallets that are already\n"
|
3981 | 3975 | "HD will have a new HD seed set so that new keys added to the keypool will be derived from this new seed.\n"
|
3982 | 3976 | "\nNote that you will need to MAKE A NEW BACKUP of your wallet after setting the HD wallet seed." +
|
3983 |
| - HelpRequiringPassphrase(pwallet) + "\n", |
| 3977 | + HELP_REQUIRING_PASSPHRASE, |
3984 | 3978 | {
|
3985 | 3979 | {"newkeypool", RPCArg::Type::BOOL, /* default */ "true", "Whether to flush old unused addresses, including change addresses, from the keypool and regenerate it.\n"
|
3986 | 3980 | " If true, the next address from getnewaddress and change address from getrawchangeaddress will be from this new seed.\n"
|
@@ -4057,7 +4051,7 @@ UniValue walletprocesspsbt(const JSONRPCRequest& request)
|
4057 | 4051 | RPCHelpMan{"walletprocesspsbt",
|
4058 | 4052 | "\nUpdate a PSBT with input information from our wallet and then sign inputs\n"
|
4059 | 4053 | "that we can sign for." +
|
4060 |
| - HelpRequiringPassphrase(pwallet) + "\n", |
| 4054 | + HELP_REQUIRING_PASSPHRASE, |
4061 | 4055 | {
|
4062 | 4056 | {"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, "The transaction base64 string"},
|
4063 | 4057 | {"sign", RPCArg::Type::BOOL, /* default */ "true", "Also sign the transaction when updating"},
|
|
0 commit comments