Skip to content

Commit fab3255

Browse files
author
MarcoFalke
committed
rpc: Make rpc documentation not depend on rpc args
1 parent 41fa292 commit fab3255

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939

4040
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"};
4142

4243
static inline bool GetAvoidReuseFlag(const CWallet* const pwallet, const UniValue& param) {
4344
bool can_avoid_reuse = pwallet->IsWalletFlagSet(WALLET_FLAG_AVOID_REUSE);
@@ -98,13 +99,6 @@ std::shared_ptr<CWallet> GetWalletForJSONRPCRequest(const JSONRPCRequest& reques
9899
return wallets.size() == 1 || (request.fHelp && wallets.size() > 0) ? wallets[0] : nullptr;
99100
}
100101

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-
108102
bool EnsureWalletIsAvailable(const CWallet* pwallet, bool avoidException)
109103
{
110104
if (pwallet) return true;
@@ -369,7 +363,7 @@ static UniValue sendtoaddress(const JSONRPCRequest& request)
369363

370364
RPCHelpMan{"sendtoaddress",
371365
"\nSend an amount to a given address." +
372-
HelpRequiringPassphrase(pwallet) + "\n",
366+
HELP_REQUIRING_PASSPHRASE,
373367
{
374368
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The bitcoin address to send to."},
375369
{"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)
527521

528522
RPCHelpMan{"signmessage",
529523
"\nSign a message with the private key of an address" +
530-
HelpRequiringPassphrase(pwallet) + "\n",
524+
HELP_REQUIRING_PASSPHRASE,
531525
{
532526
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The bitcoin address to use for the private key."},
533527
{"message", RPCArg::Type::STR, RPCArg::Optional::NO, "The message to create a signature of."},
@@ -810,7 +804,7 @@ static UniValue sendmany(const JSONRPCRequest& request)
810804

811805
RPCHelpMan{"sendmany",
812806
"\nSend multiple times. Amounts are double-precision floating point numbers." +
813-
HelpRequiringPassphrase(pwallet) + "\n",
807+
HELP_REQUIRING_PASSPHRASE,
814808
{
815809
{"dummy", RPCArg::Type::STR, RPCArg::Optional::NO, "Must be set to \"\" for backwards compatibility.", "\"\""},
816810
{"amounts", RPCArg::Type::OBJ, RPCArg::Optional::NO, "The addresses and amounts",
@@ -1851,7 +1845,7 @@ static UniValue keypoolrefill(const JSONRPCRequest& request)
18511845

18521846
RPCHelpMan{"keypoolrefill",
18531847
"\nFills the keypool."+
1854-
HelpRequiringPassphrase(pwallet) + "\n",
1848+
HELP_REQUIRING_PASSPHRASE,
18551849
{
18561850
{"newsize", RPCArg::Type::NUM, /* default */ "100", "The new keypool size"},
18571851
},
@@ -3245,7 +3239,7 @@ UniValue signrawtransactionwithwallet(const JSONRPCRequest& request)
32453239
"\nSign inputs for raw transaction (serialized, hex-encoded).\n"
32463240
"The second optional argument (may be null) is an array of previous transaction outputs that\n"
32473241
"this transaction depends on but may not yet be in the block chain." +
3248-
HelpRequiringPassphrase(pwallet) + "\n",
3242+
HELP_REQUIRING_PASSPHRASE,
32493243
{
32503244
{"hexstring", RPCArg::Type::STR, RPCArg::Optional::NO, "The transaction hex string"},
32513245
{"prevtxs", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, "The previous dependent transaction outputs",
@@ -3980,7 +3974,7 @@ UniValue sethdseed(const JSONRPCRequest& request)
39803974
"\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"
39813975
"HD will have a new HD seed set so that new keys added to the keypool will be derived from this new seed.\n"
39823976
"\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,
39843978
{
39853979
{"newkeypool", RPCArg::Type::BOOL, /* default */ "true", "Whether to flush old unused addresses, including change addresses, from the keypool and regenerate it.\n"
39863980
" 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)
40574051
RPCHelpMan{"walletprocesspsbt",
40584052
"\nUpdate a PSBT with input information from our wallet and then sign inputs\n"
40594053
"that we can sign for." +
4060-
HelpRequiringPassphrase(pwallet) + "\n",
4054+
HELP_REQUIRING_PASSPHRASE,
40614055
{
40624056
{"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, "The transaction base64 string"},
40634057
{"sign", RPCArg::Type::BOOL, /* default */ "true", "Also sign the transaction when updating"},

src/wallet/rpcwallet.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ void RegisterWalletRPCCommands(interfaces::Chain& chain, std::vector<std::unique
3838
*/
3939
std::shared_ptr<CWallet> GetWalletForJSONRPCRequest(const JSONRPCRequest& request);
4040

41-
std::string HelpRequiringPassphrase(const CWallet*);
4241
void EnsureWalletIsUnlocked(const CWallet*);
4342
bool EnsureWalletIsAvailable(const CWallet*, bool avoidException);
4443
LegacyScriptPubKeyMan& EnsureLegacyScriptPubKeyMan(CWallet& wallet, bool also_create = false);

0 commit comments

Comments
 (0)