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) 2018-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_INTERFACES_WALLET_H6#define BITCOIN_INTERFACES_WALLET_H8#include <addresstype.h>9#include <common/signmessage.h>10#include <common/types.h>11#include <consensus/amount.h>12#include <interfaces/chain.h>13#include <primitives/transaction.h>14#include <support/allocators/secure.h>15#include <util/fs.h>16#include <util/result.h>17#include <util/ui_change_type.h>19#include <compare>20#include <cstddef>21#include <cstdint>22#include <functional>23#include <map>24#include <memory>25#include <optional>26#include <set>27#include <string>28#include <tuple>29#include <utility>30#include <vector>32class ArgsManager;33class CKeyID;34class CPubKey;35class CScript;36class PartiallySignedTransaction;37class uint256;38enum class FeeReason;39enum class OutputType;40struct bilingual_str;41namespace wallet {42struct CreatedTransactionResult;43class CCoinControl;44class CWallet;45enum class AddressPurpose;46struct CRecipient;47struct WalletContext;48} // namespace wallet50namespace interfaces {52class Handler;53struct WalletAddress;54struct WalletBalances;55struct WalletTx;56struct WalletTxOut;57struct WalletTxStatus;58struct WalletMigrationResult;60//! Interface for accessing a wallet.61class Wallet62{63public:64virtual ~Wallet() = default;66//! Encrypt wallet.67virtual bool encryptWallet(const SecureString& wallet_passphrase) = 0;69//! Return whether wallet is encrypted.70virtual bool isCrypted() = 0;72//! Lock wallet.73virtual bool lock() = 0;75//! Unlock wallet.76virtual bool unlock(const SecureString& wallet_passphrase) = 0;78//! Return whether wallet is locked.79virtual bool isLocked() = 0;81//! Change wallet passphrase.82virtual bool changeWalletPassphrase(const SecureString& old_wallet_passphrase,83const SecureString& new_wallet_passphrase) = 0;85//! Abort a rescan.86virtual void abortRescan() = 0;88//! Back up wallet.89virtual bool backupWallet(const std::string& filename) = 0;91//! Get wallet name.92virtual std::string getWalletName() = 0;94// Get a new address.95virtual util::Result<CTxDestination> getNewDestination(OutputType type, const std::string& label) = 0;97//! Get public key.98virtual bool getPubKey(const CScript& script, const CKeyID& address, CPubKey& pub_key) = 0;100//! Sign message101virtual SigningResult signMessage(const std::string& message, const PKHash& pkhash, std::string& str_sig) = 0;103//! Return whether wallet has private key.104virtual bool isSpendable(const CTxDestination& dest) = 0;106//! Add or update address.107virtual bool setAddressBook(const CTxDestination& dest, const std::string& name, const std::optional<wallet::AddressPurpose>& purpose) = 0;109// Remove address.110virtual bool delAddressBook(const CTxDestination& dest) = 0;112//! Look up address in wallet, return whether exists.113virtual bool getAddress(const CTxDestination& dest,114std::string* name,115wallet::AddressPurpose* purpose) = 0;117//! Get wallet address list.118virtual std::vector<WalletAddress> getAddresses() = 0;120//! Get receive requests.121virtual std::vector<std::string> getAddressReceiveRequests() = 0;123//! Save or remove receive request.124virtual bool setAddressReceiveRequest(const CTxDestination& dest, const std::string& id, const std::string& value) = 0;126//! Display address on external signer127virtual util::Result<void> displayAddress(const CTxDestination& dest) = 0;129//! Lock coin.130virtual bool lockCoin(const COutPoint& output, bool write_to_db) = 0;132//! Unlock coin.133virtual bool unlockCoin(const COutPoint& output) = 0;135//! Return whether coin is locked.136virtual bool isLockedCoin(const COutPoint& output) = 0;138//! List locked coins.139virtual void listLockedCoins(std::vector<COutPoint>& outputs) = 0;141//! Create transaction.142virtual util::Result<wallet::CreatedTransactionResult> createTransaction(const std::vector<wallet::CRecipient>& recipients,143const wallet::CCoinControl& coin_control,144bool sign,145std::optional<unsigned int> change_pos) = 0;147//! Commit transaction.148virtual void commitTransaction(CTransactionRef tx, const std::vector<std::string>& messages) = 0;150//! Return whether transaction can be abandoned.151virtual bool transactionCanBeAbandoned(const Txid& txid) = 0;153//! Abandon transaction.154virtual bool abandonTransaction(const Txid& txid) = 0;156//! Return whether transaction can be bumped.157virtual bool transactionCanBeBumped(const Txid& txid) = 0;159//! Create bump transaction.160virtual bool createBumpTransaction(const Txid& txid,161const wallet::CCoinControl& coin_control,162std::vector<bilingual_str>& errors,163CAmount& old_fee,164CAmount& new_fee,165CMutableTransaction& mtx) = 0;167//! Sign bump transaction.168virtual bool signBumpTransaction(CMutableTransaction& mtx) = 0;170//! Commit bump transaction.171virtual bool commitBumpTransaction(const Txid& txid,172CMutableTransaction&& mtx,173std::vector<bilingual_str>& errors,174Txid& bumped_txid) = 0;176//! Get a transaction.177virtual CTransactionRef getTx(const Txid& txid) = 0;179//! Get transaction information.180virtual WalletTx getWalletTx(const Txid& txid) = 0;182//! Get list of all wallet transactions.183virtual std::set<WalletTx> getWalletTxs() = 0;185//! Try to get updated status for a particular transaction, if possible without blocking.186virtual bool tryGetTxStatus(const Txid& txid,187WalletTxStatus& tx_status,188int& num_blocks,189int64_t& block_time) = 0;191//! Get transaction details.192virtual WalletTx getWalletTxDetails(const Txid& txid,193WalletTxStatus& tx_status,194std::vector<std::string>& messages,195std::vector<std::string>& payment_requests,196bool& in_mempool,197int& num_blocks) = 0;199//! Fill PSBT.200virtual std::optional<common::PSBTError> fillPSBT(const common::PSBTFillOptions& options,201size_t* n_signed,202PartiallySignedTransaction& psbtx,203bool& complete) = 0;205//! Get balances.206virtual WalletBalances getBalances() = 0;208//! Get balances if possible without blocking.209virtual bool tryGetBalances(WalletBalances& balances, uint256& block_hash) = 0;211//! Get balance.212virtual CAmount getBalance() = 0;214//! Get available balance.215virtual CAmount getAvailableBalance(const wallet::CCoinControl& coin_control) = 0;217//! Return whether transaction input belongs to wallet.218virtual bool txinIsMine(const CTxIn& txin) = 0;220//! Return whether transaction output belongs to wallet.221virtual bool txoutIsMine(const CTxOut& txout) = 0;223//! Return debit amount if transaction input belongs to wallet.224virtual CAmount getDebit(const CTxIn& txin) = 0;226//! Return credit amount if transaction input belongs to wallet.227virtual CAmount getCredit(const CTxOut& txout) = 0;229//! Return AvailableCoins + LockedCoins grouped by wallet address.230//! (put change in one group with wallet address)231using CoinsList = std::map<CTxDestination, std::vector<std::tuple<COutPoint, WalletTxOut>>>;232virtual CoinsList listCoins() = 0;234//! Return wallet transaction output information.235virtual std::vector<WalletTxOut> getCoins(const std::vector<COutPoint>& outputs) = 0;237//! Get required fee.238virtual CAmount getRequiredFee(unsigned int tx_bytes) = 0;240//! Get minimum fee.241virtual CAmount getMinimumFee(unsigned int tx_bytes,242const wallet::CCoinControl& coin_control,243std::optional<int>* returned_target,244FeeReason* reason) = 0;246//! Get tx confirm target.247virtual unsigned int getConfirmTarget() = 0;249// Return whether HD enabled.250virtual bool hdEnabled() = 0;
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.