aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-04-04 03:14:33 +0800
committerMarcoFalke <falke.marco@gmail.com>2020-04-04 03:15:00 +0800
commitc8971547d9c9460fcbec6f54888df83f002c3dfd (patch)
tree42b449681627fdb3aa82c9947b6a172fb91bb92c /src
parente35e118656e9638cce019d4eeffc5f1b8639d4f5 (diff)
parentfab32557f25c93fecb7bb33f78fdf3e9160c89e5 (diff)
downloadbitcoin-c8971547d9c9460fcbec6f54888df83f002c3dfd.tar.xz
Merge #18499: rpc: Make rpc documentation not depend on call-time rpc args
fab32557f25c93fecb7bb33f78fdf3e9160c89e5 rpc: Make rpc documentation not depend on rpc args (MarcoFalke) Pull request description: This is required to host the documentation on a static resource (like a website or pdf) ACKs for top commit: emilengler: utACK fab32557f25c93fecb7bb33f78fdf3e9160c89e5 promag: ACK fab32557f25c93fecb7bb33f78fdf3e9160c89e5. Tree-SHA512: 3ca2691c7fbd5f17c75df2887753da152f66521dcb7dee4c29af6339fdea011cecdd51f825b96bde9c6aaf82f4d915cbd5aacb52e4eae3898d9dbc216f627171
Diffstat (limited to 'src')
-rw-r--r--src/wallet/rpcwallet.cpp22
-rw-r--r--src/wallet/rpcwallet.h1
2 files changed, 8 insertions, 15 deletions
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
index 5d34e592db..d8b3b57b61 100644
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -38,6 +38,7 @@
static const std::string WALLET_ENDPOINT_BASE = "/wallet/";
+static const std::string HELP_REQUIRING_PASSPHRASE{"\nRequires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.\n"};
static inline bool GetAvoidReuseFlag(const CWallet* const pwallet, const UniValue& param) {
bool can_avoid_reuse = pwallet->IsWalletFlagSet(WALLET_FLAG_AVOID_REUSE);
@@ -98,13 +99,6 @@ std::shared_ptr<CWallet> GetWalletForJSONRPCRequest(const JSONRPCRequest& reques
return wallets.size() == 1 || (request.fHelp && wallets.size() > 0) ? wallets[0] : nullptr;
}
-std::string HelpRequiringPassphrase(const CWallet* pwallet)
-{
- return pwallet && pwallet->IsCrypted()
- ? "\nRequires wallet passphrase to be set with walletpassphrase call."
- : "";
-}
-
bool EnsureWalletIsAvailable(const CWallet* pwallet, bool avoidException)
{
if (pwallet) return true;
@@ -369,7 +363,7 @@ static UniValue sendtoaddress(const JSONRPCRequest& request)
RPCHelpMan{"sendtoaddress",
"\nSend an amount to a given address." +
- HelpRequiringPassphrase(pwallet) + "\n",
+ HELP_REQUIRING_PASSPHRASE,
{
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The bitcoin address to send to."},
{"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)
RPCHelpMan{"signmessage",
"\nSign a message with the private key of an address" +
- HelpRequiringPassphrase(pwallet) + "\n",
+ HELP_REQUIRING_PASSPHRASE,
{
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The bitcoin address to use for the private key."},
{"message", RPCArg::Type::STR, RPCArg::Optional::NO, "The message to create a signature of."},
@@ -810,7 +804,7 @@ static UniValue sendmany(const JSONRPCRequest& request)
RPCHelpMan{"sendmany",
"\nSend multiple times. Amounts are double-precision floating point numbers." +
- HelpRequiringPassphrase(pwallet) + "\n",
+ HELP_REQUIRING_PASSPHRASE,
{
{"dummy", RPCArg::Type::STR, RPCArg::Optional::NO, "Must be set to \"\" for backwards compatibility.", "\"\""},
{"amounts", RPCArg::Type::OBJ, RPCArg::Optional::NO, "The addresses and amounts",
@@ -1851,7 +1845,7 @@ static UniValue keypoolrefill(const JSONRPCRequest& request)
RPCHelpMan{"keypoolrefill",
"\nFills the keypool."+
- HelpRequiringPassphrase(pwallet) + "\n",
+ HELP_REQUIRING_PASSPHRASE,
{
{"newsize", RPCArg::Type::NUM, /* default */ "100", "The new keypool size"},
},
@@ -3245,7 +3239,7 @@ UniValue signrawtransactionwithwallet(const JSONRPCRequest& request)
"\nSign inputs for raw transaction (serialized, hex-encoded).\n"
"The second optional argument (may be null) is an array of previous transaction outputs that\n"
"this transaction depends on but may not yet be in the block chain." +
- HelpRequiringPassphrase(pwallet) + "\n",
+ HELP_REQUIRING_PASSPHRASE,
{
{"hexstring", RPCArg::Type::STR, RPCArg::Optional::NO, "The transaction hex string"},
{"prevtxs", RPCArg::Type::ARR, RPCArg::Optional::OMITTED_NAMED_ARG, "The previous dependent transaction outputs",
@@ -3980,7 +3974,7 @@ UniValue sethdseed(const JSONRPCRequest& request)
"\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"
"HD will have a new HD seed set so that new keys added to the keypool will be derived from this new seed.\n"
"\nNote that you will need to MAKE A NEW BACKUP of your wallet after setting the HD wallet seed." +
- HelpRequiringPassphrase(pwallet) + "\n",
+ HELP_REQUIRING_PASSPHRASE,
{
{"newkeypool", RPCArg::Type::BOOL, /* default */ "true", "Whether to flush old unused addresses, including change addresses, from the keypool and regenerate it.\n"
" 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)
RPCHelpMan{"walletprocesspsbt",
"\nUpdate a PSBT with input information from our wallet and then sign inputs\n"
"that we can sign for." +
- HelpRequiringPassphrase(pwallet) + "\n",
+ HELP_REQUIRING_PASSPHRASE,
{
{"psbt", RPCArg::Type::STR, RPCArg::Optional::NO, "The transaction base64 string"},
{"sign", RPCArg::Type::BOOL, /* default */ "true", "Also sign the transaction when updating"},
diff --git a/src/wallet/rpcwallet.h b/src/wallet/rpcwallet.h
index 2813fa2bfc..a7a29de9c6 100644
--- a/src/wallet/rpcwallet.h
+++ b/src/wallet/rpcwallet.h
@@ -38,7 +38,6 @@ void RegisterWalletRPCCommands(interfaces::Chain& chain, std::vector<std::unique
*/
std::shared_ptr<CWallet> GetWalletForJSONRPCRequest(const JSONRPCRequest& request);
-std::string HelpRequiringPassphrase(const CWallet*);
void EnsureWalletIsUnlocked(const CWallet*);
bool EnsureWalletIsAvailable(const CWallet*, bool avoidException);
LegacyScriptPubKeyMan& EnsureLegacyScriptPubKeyMan(CWallet& wallet, bool also_create = false);