Inside Bitcoin
Opening the selected file…
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2017-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#ifndef BITCOIN_WALLET_RPC_UTIL_H6#define BITCOIN_WALLET_RPC_UTIL_H8#include <rpc/util.h>9#include <script/script.h>10#include <wallet/wallet.h>12#include <any>13#include <memory>14#include <optional>15#include <string>16#include <string_view>17#include <vector>19class JSONRPCRequest;20class UniValue;21struct bilingual_str;23namespace wallet {24enum class DatabaseStatus;25struct WalletContext;27extern const std::string HELP_REQUIRING_PASSPHRASE;29inline const RPCResult RESULT_LAST_PROCESSED_BLOCK { RPCResult::Type::OBJ, "lastprocessedblock", "hash and height of the block this information was generated on",{30{RPCResult::Type::STR_HEX, "hash", "hash of the block this information was generated on"},31{RPCResult::Type::NUM, "height", "height of the block this information was generated on"}}32};34/**35* Figures out what wallet, if any, to use for a JSONRPCRequest.36*37* @param[in] request JSONRPCRequest that wishes to access a wallet38* @return nullptr if no wallet should be used, or a pointer to the CWallet39*/40std::shared_ptr<CWallet> GetWalletForJSONRPCRequest(const JSONRPCRequest& request);41std::optional<std::string> GetWalletNameFromJSONRPCRequest(const JSONRPCRequest& request);42/**43* Ensures that a wallet name is specified across the endpoint and wallet_name.44* Throws `RPC_INVALID_PARAMETER` if none or different wallet names are specified.45*/46std::string EnsureUniqueWalletName(const JSONRPCRequest& request, std::optional<std::string_view> wallet_name);48void EnsureWalletIsUnlocked(const CWallet&);49WalletContext& EnsureWalletContext(const std::any& context);51bool GetAvoidReuseFlag(const CWallet& wallet, const UniValue& param);52std::string LabelFromValue(const UniValue& value);53//! Fetch parent descriptors of this scriptPubKey.54void PushParentDescriptors(const CWallet& wallet, const CScript& script_pubkey, UniValue& entry);56void HandleWalletError(const std::shared_ptr<CWallet>& wallet, DatabaseStatus& status, bilingual_str& error);57void AppendLastProcessedBlock(UniValue& entry, const CWallet& wallet) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);58} // namespace wallet60#endif // BITCOIN_WALLET_RPC_UTIL_H