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>
65 std::string wallet_name;
67 std::shared_ptr<CWallet> pwallet =
GetWallet(wallet_name);
71 "Requested wallet does not exist or is not loaded");
76 std::vector<std::shared_ptr<CWallet>> wallets =
GetWallets();
77 if (wallets.size() == 1) {
81 if (wallets.empty()) {
84 "No wallet is loaded. Load a wallet using loadwallet or create a "
85 "new one with createwallet. (Note: A default wallet is no longer "
86 "automatically created)");
90 "Wallet file not specified (must request wallet RPC "
91 "through /wallet/<filename> uri-path).");
97 "Error: Please enter the wallet passphrase with "
98 "walletpassphrase first.");
103 auto wallet_context = util::AnyPtr<WalletContext>(context);
104 if (!wallet_context) {
107 return *wallet_context;
115 if (!spk_man && also_create) {
116 spk_man =
wallet.GetOrCreateLegacyScriptPubKeyMan();
120 "This type of wallet does not support this command");
126 std::string label = value.
get_str();
133std::tuple<std::shared_ptr<CWallet>, std::vector<bilingual_str>>
135 const std::string wallet_name) {
140 std::vector<bilingual_str> warnings;
141 std::optional<bool> load_on_start =
142 load_on_start_param.
isNull()
144 : std::make_optional<bool>(load_on_start_param.
get_bool());
145 std::shared_ptr<CWallet>
const wallet =
146 LoadWallet(*context.
chain, wallet_name, load_on_start, options, status,
159 return {
wallet, warnings};
#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.
bool error(const char *fmt, const Args &...args)
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_ERROR
Wallet errors Unspecified problem with wallet (key not found etc.)
@ RPC_WALLET_NOT_FOUND
Invalid wallet specified.
WalletContext struct containing references to state shared between CWallet instances,...
interfaces::Chain * chain
std::string urlDecode(const std::string &urlEncoded)
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)
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::tuple< std::shared_ptr< CWallet >, std::vector< bilingual_str > > LoadWalletHelper(WalletContext &context, UniValue load_on_start_param, const std::string wallet_name)
std::shared_ptr< CWallet > GetWallet(const std::string &name)
std::vector< std::shared_ptr< CWallet > > GetWallets()
std::shared_ptr< CWallet > LoadWallet(interfaces::Chain &chain, const std::string &name, std::optional< bool > load_on_start, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
@ WALLET_FLAG_DISABLE_PRIVATE_KEYS
@ WALLET_FLAG_AVOID_REUSE