18 "\nRequires wallet passphrase to be set with walletpassphrase call if "
19 "wallet is encrypted.\n"};
23 bool avoid_reuse = param.
isNull() ? can_avoid_reuse : param.
get_bool();
25 if (avoid_reuse && !can_avoid_reuse) {
28 "wallet does not have the \"avoid reuse\" feature enabled");
40 if (include_watchonly.
isNull()) {
51 std::string &wallet_name) {
62std::shared_ptr<CWallet>
67 std::string wallet_name;
69 std::shared_ptr<CWallet> pwallet =
GetWallet(context, wallet_name);
73 "Requested wallet does not exist or is not loaded");
78 std::vector<std::shared_ptr<CWallet>> wallets =
GetWallets(context);
79 if (wallets.size() == 1) {
83 if (wallets.empty()) {
86 "No wallet is loaded. Load a wallet using loadwallet or create a "
87 "new one with createwallet. (Note: A default wallet is no longer "
88 "automatically created)");
92 "Wallet file not specified (must request wallet RPC "
93 "through /wallet/<filename> uri-path).");
99 "Error: Please enter the wallet passphrase with "
100 "walletpassphrase first.");
105 auto wallet_context = util::AnyPtr<WalletContext>(context);
106 if (!wallet_context) {
109 return *wallet_context;
117 if (!spk_man && also_create) {
118 spk_man =
wallet.GetOrCreateLegacyScriptPubKeyMan();
122 "This type of wallet does not support this command");
128 std::string label = value.
get_str();
#define CHECK_NONFATAL(condition)
Identity function.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
bool IsLocked() const override
enum JSONRPCRequest::Mode mode
const std::string & get_str() const
bool IsWalletFlagSet(uint64_t flag) const override
Check if a certain wallet flag is set.
UniValue JSONRPCError(int code, const std::string &message)
RPCErrorCode
Bitcoin RPC error codes.
@ RPC_WALLET_NOT_SPECIFIED
No wallet specified (error when there are multiple wallets loaded)
@ RPC_WALLET_INVALID_LABEL_NAME
Invalid label name.
@ RPC_WALLET_UNLOCK_NEEDED
Enter the wallet passphrase with walletpassphrase first.
@ RPC_WALLET_ALREADY_EXISTS
There is already a wallet with the same name.
@ RPC_INVALID_PARAMETER
Invalid, missing or duplicate parameter.
@ RPC_WALLET_ERROR
Wallet errors Unspecified problem with wallet (key not found etc.)
@ RPC_WALLET_ALREADY_LOADED
This same wallet is already loaded.
@ RPC_WALLET_NOT_FOUND
Invalid wallet specified.
WalletContext struct containing references to state shared between CWallet instances,...
std::string urlDecode(const std::string &urlEncoded)
@ FAILED_INVALID_BACKUP_FILE
void EnsureWalletIsUnlocked(const CWallet *pwallet)
static const std::string WALLET_ENDPOINT_BASE
std::shared_ptr< CWallet > GetWalletForJSONRPCRequest(const JSONRPCRequest &request)
Figures out what wallet, if any, to use for a JSONRPCRequest.
LegacyScriptPubKeyMan & EnsureLegacyScriptPubKeyMan(CWallet &wallet, bool also_create)
bool GetAvoidReuseFlag(const CWallet *const pwallet, const UniValue ¶m)
void HandleWalletError(const std::shared_ptr< CWallet > wallet, DatabaseStatus &status, bilingual_str &error)
bool ParseIncludeWatchonly(const UniValue &include_watchonly, const CWallet &pwallet)
Used by RPC commands that have an include_watchonly parameter.
WalletContext & EnsureWalletContext(const std::any &context)
const std::string HELP_REQUIRING_PASSPHRASE
std::string LabelFromValue(const UniValue &value)
bool GetWalletNameFromJSONRPCRequest(const JSONRPCRequest &request, std::string &wallet_name)
std::vector< std::shared_ptr< CWallet > > GetWallets(WalletContext &context)
std::shared_ptr< CWallet > GetWallet(WalletContext &context, const std::string &name)
@ WALLET_FLAG_DISABLE_PRIVATE_KEYS
@ WALLET_FLAG_AVOID_REUSE