14 #include <string_view> 17 #include <boost/date_time/posix_time/posix_time.hpp> 21 const std::string
HELP_REQUIRING_PASSPHRASE{
"\nRequires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.\n"};
25 static const boost::posix_time::ptime epoch = boost::posix_time::from_time_t(0);
26 static const std::locale loc(std::locale::classic(),
27 new boost::posix_time::time_input_facet(
"%Y-%m-%dT%H:%M:%SZ"));
28 std::istringstream iss(str);
30 boost::posix_time::ptime ptime(boost::date_time::not_a_date_time);
32 if (ptime.is_not_a_date_time() || epoch > ptime)
34 return (ptime - epoch).total_seconds();
39 bool avoid_reuse = param.
isNull() ? can_avoid_reuse : param.
get_bool();
41 if (avoid_reuse && !can_avoid_reuse) {
54 if (include_watchonly.
isNull()) {
78 std::string wallet_name;
80 std::shared_ptr<CWallet> pwallet =
GetWallet(context, wallet_name);
91 RPC_WALLET_NOT_FOUND,
"No wallet is loaded. Load a wallet using loadwallet or create a new one with createwallet. (Note: A default wallet is no longer automatically created)");
94 "Wallet file not specified (must request wallet RPC through /wallet/<filename> uri-path).");
106 auto wallet_context = util::AnyPtr<WalletContext>(context);
107 if (!wallet_context) {
110 return *wallet_context;
117 if (!spk_man && also_create) {
118 spk_man =
wallet.GetOrCreateLegacyScriptPubKeyMan();
137 static const std::string empty_string;
138 if (value.
isNull())
return empty_string;
140 const std::string& label{value.
get_str()};
149 for (
const auto& desc:
wallet.GetWalletDescriptors(script_pubkey)) {
150 parent_descs.
push_back(desc.descriptor->ToString());
152 entry.
pushKV(
"parent_descs", std::move(parent_descs));
186 lastprocessedblock.pushKV(
"hash",
wallet.GetLastBlockHash().GetHex());
187 lastprocessedblock.pushKV(
"height",
wallet.GetLastBlockHeight());
188 entry.
pushKV(
"lastprocessedblock", std::move(lastprocessedblock));
No wallet specified (error when there are multiple wallets loaded)
void push_back(UniValue val)
Enter the wallet passphrase with walletpassphrase first.
#define CHECK_NONFATAL(condition)
Identity function.
bool ParseIncludeWatchonly(const UniValue &include_watchonly, const CWallet &wallet)
Used by RPC commands that have an include_watchonly parameter.
const std::string & get_str() const
std::string UrlDecode(std::string_view url_encoded)
This same wallet is already loaded.
Invalid, missing or duplicate parameter.
void HandleWalletError(const std::shared_ptr< CWallet > wallet, DatabaseStatus &status, bilingual_str &error)
UniValue JSONRPCError(int code, const std::string &message)
std::string LabelFromValue(const UniValue &value)
enum JSONRPCRequest::Mode mode
WalletContext & EnsureWalletContext(const std::any &context)
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Invalid wallet specified.
const std::string HELP_REQUIRING_PASSPHRASE
LegacyScriptPubKeyMan & EnsureLegacyScriptPubKeyMan(CWallet &wallet, bool also_create)
std::shared_ptr< CWallet > GetWallet(WalletContext &context, const std::string &name)
void pushKV(std::string key, UniValue val)
Serialized script, used inside transaction inputs and outputs.
WalletContext struct containing references to state shared between CWallet instances, like the reference to the chain interface, and the list of opened wallets.
bool GetAvoidReuseFlag(const CWallet &wallet, const UniValue ¶m)
void EnsureWalletIsUnlocked(const CWallet &wallet)
std::shared_ptr< CWallet > wallet
There is already a wallet with the same name.
RPCErrorCode
Bitcoin RPC error codes.
void PushParentDescriptors(const CWallet &wallet, const CScript &script_pubkey, UniValue &entry)
Fetch parent descriptors of this scriptPubKey.
const LegacyScriptPubKeyMan & EnsureConstLegacyScriptPubKeyMan(const CWallet &wallet)
int64_t ParseISO8601DateTime(const std::string &str)
std::shared_ptr< CWallet > GetDefaultWallet(WalletContext &context, size_t &count)
static const std::string WALLET_ENDPOINT_BASE
void AppendLastProcessedBlock(UniValue &entry, const CWallet &wallet)
std::shared_ptr< CWallet > GetWalletForJSONRPCRequest(const JSONRPCRequest &request)
Figures out what wallet, if any, to use for a JSONRPCRequest.
bool GetWalletNameFromJSONRPCRequest(const JSONRPCRequest &request, std::string &wallet_name)