17 "\nRequires wallet passphrase to be set with walletpassphrase call if "
18 "wallet is encrypted.\n"};
22 bool avoid_reuse = param.
isNull() ? can_avoid_reuse : param.
get_bool();
24 if (avoid_reuse && !can_avoid_reuse) {
27 "wallet does not have the \"avoid reuse\" feature enabled");
39 if (include_watchonly.
isNull()) {
50 std::string &wallet_name) {
61 std::shared_ptr<CWallet>
64 std::string wallet_name;
66 std::shared_ptr<CWallet> pwallet =
GetWallet(wallet_name);
70 "Requested wallet does not exist or is not loaded");
75 std::vector<std::shared_ptr<CWallet>> wallets =
GetWallets();
76 if (wallets.size() == 1) {
80 if (wallets.empty()) {
83 "No wallet is loaded. Load a wallet using loadwallet or create a "
84 "new one with createwallet. (Note: A default wallet is no longer "
85 "automatically created)");
89 "Wallet file not specified (must request wallet RPC "
90 "through /wallet/<filename> uri-path).");
96 "Error: Please enter the wallet passphrase with "
97 "walletpassphrase first.");
102 auto wallet_context = util::AnyPtr<WalletContext>(context);
103 if (!wallet_context) {
106 return *wallet_context;
114 if (!spk_man && also_create) {
115 spk_man =
wallet.GetOrCreateLegacyScriptPubKeyMan();
119 "This type of wallet does not support this command");
125 std::string label = value.
get_str();
132 std::tuple<std::shared_ptr<CWallet>, std::vector<bilingual_str>>
134 const std::string wallet_name) {
139 std::vector<bilingual_str> warnings;
140 std::optional<bool> load_on_start =
141 load_on_start_param.
isNull()
143 : std::make_optional<bool>(load_on_start_param.
get_bool());
144 std::shared_ptr<CWallet>
const wallet =
145 LoadWallet(*context.
chain, wallet_name, load_on_start, options, status,
158 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.
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
bool error(const char *fmt, const Args &...args)
std::string urlDecode(const std::string &urlEncoded)
void EnsureWalletIsUnlocked(const CWallet *pwallet)
std::shared_ptr< CWallet > GetWalletForJSONRPCRequest(const JSONRPCRequest &request)
Figures out what wallet, if any, to use for a JSONRPCRequest.
static const std::string WALLET_ENDPOINT_BASE
LegacyScriptPubKeyMan & EnsureLegacyScriptPubKeyMan(CWallet &wallet, bool also_create)
WalletContext & EnsureWalletContext(const std::any &context)
bool GetAvoidReuseFlag(const CWallet *const pwallet, const UniValue ¶m)
std::tuple< std::shared_ptr< CWallet >, std::vector< bilingual_str > > LoadWalletHelper(WalletContext &context, UniValue load_on_start_param, const std::string wallet_name)
bool ParseIncludeWatchonly(const UniValue &include_watchonly, const CWallet &pwallet)
Used by RPC commands that have an include_watchonly parameter.
const std::string HELP_REQUIRING_PASSPHRASE
std::string LabelFromValue(const UniValue &value)
bool GetWalletNameFromJSONRPCRequest(const JSONRPCRequest &request, std::string &wallet_name)
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)
std::shared_ptr< CWallet > GetWallet(const std::string &name)
std::vector< std::shared_ptr< CWallet > > GetWallets()
@ WALLET_FLAG_DISABLE_PRIVATE_KEYS
@ WALLET_FLAG_AVOID_REUSE