Inside Bitcoin
Opening the selected file…
Inside Bitcoin
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.
751*/752std::optional<OutputType> m_default_change_type{};753/** Absolute maximum transaction fee (in satoshis) used by default for the wallet */754CAmount m_default_max_tx_fee{DEFAULT_TRANSACTION_MAXFEE};756/** Number of pre-generated keys/scripts by each spkm (part of the look-ahead process, used to detect payments) */757int64_t m_keypool_size{DEFAULT_KEYPOOL_SIZE};759/** Notify external script when a wallet transaction comes in or is updated (handled by -walletnotify) */760std::string m_notify_tx_changed_script;762size_t KeypoolCountExternalKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);763bool TopUpKeyPool(unsigned int kpSize = 0);765// Filter struct for 'ListAddrBookAddresses'766struct AddrBookFilter {767// Fetch addresses with the provided label768std::optional<std::string> m_op_label{std::nullopt};769// Don't include change addresses by default770bool ignore_change{true};771};773/**774* Filter and retrieve destinations stored in the addressbook775*/776std::vector<CTxDestination> ListAddrBookAddresses(const std::optional<AddrBookFilter>& filter) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);778/**779* Retrieve all the known labels in the address book780*/781std::set<std::string> ListAddrBookLabels(std::optional<AddressPurpose> purpose) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);783/**784* Walk-through the address book entries.785* Stops when the provided 'ListAddrBookFunc' returns false.786*/787using ListAddrBookFunc = std::function<void(const CTxDestination& dest, const std::string& label, bool is_change, const std::optional<AddressPurpose> purpose)>;788void ForEachAddrBookEntry(const ListAddrBookFunc& func) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);790/**791* Marks all outputs in each one of the destinations dirty, so their cache is792* reset and does not return outdated information.793*/794void MarkDestinationsDirty(const std::set<CTxDestination>& destinations) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);796util::Result<CTxDestination> GetNewDestination(OutputType type, const std::string& label);797util::Result<CTxDestination> GetNewChangeDestination(OutputType type);799bool IsMine(const CTxDestination& dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);800bool IsMine(const CScript& script) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);801/** Returns amount of debit, i.e. the amount leaving this wallet due to this input */802CAmount GetDebit(const CTxIn& txin) const;803bool IsMine(const CTxOut& txout) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);804bool IsMine(const CTransaction& tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);805bool IsMine(const COutPoint& outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);806/** should probably be renamed to IsRelevantToMe */807bool IsFromMe(const CTransaction& tx) const;808CAmount GetDebit(const CTransaction& tx) const;810DBErrors PopulateWalletFromDB(bilingual_str& error, std::vector<bilingual_str>& warnings);812/** Erases the provided transactions from the wallet. */813util::Result<void> RemoveTxs(std::vector<Txid>& txs_to_remove) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);814util::Result<void> RemoveTxs(WalletBatch& batch, std::vector<Txid>& txs_to_remove) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);816bool SetAddressBook(const CTxDestination& address, const std::string& strName, const std::optional<AddressPurpose>& purpose);818bool DelAddressBook(const CTxDestination& address);819bool DelAddressBookWithDB(WalletBatch& batch, const CTxDestination& address);821bool IsAddressPreviouslySpent(const CTxDestination& dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);822bool SetAddressPreviouslySpent(WalletBatch& batch, const CTxDestination& dest, bool used) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);824std::vector<std::string> GetAddressReceiveRequests() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);825bool SetAddressReceiveRequest(WalletBatch& batch, const CTxDestination& dest, const std::string& id, const std::string& value) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);826bool EraseAddressReceiveRequest(WalletBatch& batch, const CTxDestination& dest, const std::string& id) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);828unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);830//! Get wallet transactions that conflict with given transaction (spend same outputs)831std::set<Txid> GetConflicts(const Txid& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);833//! Check if a given transaction has any of its outputs spent by another transaction in the wallet834bool HasWalletSpend(const CTransactionRef& tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);836//! Close wallet database837void Close();839/** Wallet is about to be unloaded */840btcsignals::signal<void ()> NotifyUnload;842/**843* Address book entry changed.844* @note called without lock cs_wallet held.845*/846btcsignals::signal<void(const CTxDestination& address,847const std::string& label, bool isMine,848AddressPurpose purpose, ChangeType status)>849NotifyAddressBookChanged;851/**852* Wallet transaction added, removed or updated.853* @note called with lock cs_wallet held.854*/855btcsignals::signal<void(const Txid& hashTx, ChangeType status)> NotifyTransactionChanged;857/** Show progress e.g. for rescan */858btcsignals::signal<void (const std::string &title, int nProgress)> ShowProgress;860/** Keypool has new keys */861btcsignals::signal<void ()> NotifyCanGetAddressesChanged;863/**864* Wallet status (encrypted, locked) changed.865* Note: Called without locks held.866*/867btcsignals::signal<void (CWallet* wallet)> NotifyStatusChanged;869/** Inquire whether this wallet broadcasts transactions. */870bool GetBroadcastTransactions() const { return fBroadcastTransactions; }871/** Set whether this wallet broadcasts transactions. */872void SetBroadcastTransactions(bool broadcast) { fBroadcastTransactions = broadcast; }874/** Return whether transaction can be abandoned */875bool TransactionCanBeAbandoned(const Txid& hashTx) const;877/* Mark a transaction (and it in-wallet descendants) as abandoned so its inputs may be respent. */878bool AbandonTransaction(const Txid& hashTx);879bool AbandonTransaction(CWalletTx& tx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);881/** Mark a transaction as replaced by another transaction. */882bool MarkReplaced(const Txid& originalHash, const Txid& newHash);884static bool LoadWalletArgs(std::shared_ptr<CWallet> wallet, const WalletContext& context, bilingual_str& error, std::vector<bilingual_str>& warnings);886/* Initializes, creates and returns a new CWallet; returns a null pointer in case of an error */887static std::shared_ptr<CWallet> CreateNew(WalletContext& context, const std::string& name, std::unique_ptr<WalletDatabase> database, uint64_t wallet_creation_flags, bool born_encrypted, bilingual_str& error, std::vector<bilingual_str>& warnings);889/* Initializes, loads, and returns a CWallet from an existing wallet; returns a null pointer in case of an error */890static std::shared_ptr<CWallet> LoadExisting(WalletContext& context, const std::string& name, std::unique_ptr<WalletDatabase> database, bilingual_str& error, std::vector<bilingual_str>& warnings);892/**893* Wallet post-init setup894* Gives the wallet a chance to register repetitive tasks and complete post-init tasks895*/896void postInitProcess();898[[nodiscard]] bool BackupWallet(const std::string& strDest) const;900/* Returns true if HD is enabled */901bool IsHDEnabled() const;903/* Returns true if the wallet can give out new addresses. This means it has keys in the keypool or can generate new keys */904bool CanGetAddresses(bool internal = false) const;906/* Returns the time of the first created key or, in case of an import, it could be the time of the first received transaction */907int64_t GetBirthTime() const { return m_birth_time; }909/**910* Blocks until the wallet state is up-to-date to /at least/ the current911* chain at the time this function is entered912* Obviously holding cs_main/cs_wallet when going into this call may cause913* deadlock914*/915void BlockUntilSyncedToCurrentChain() const LOCKS_EXCLUDED(::cs_main) EXCLUSIVE_LOCKS_REQUIRED(!cs_wallet);917/** set a single wallet flag */918void SetWalletFlag(uint64_t flags);920/** Unsets a single wallet flag */921void UnsetWalletFlag(uint64_t flag);923/** check if a certain wallet flag is set */924bool IsWalletFlagSet(uint64_t flag) const override;926/** overwrite all flags by the given uint64_t927flags must be uninitialised (or 0)928only known flags may be present */929void InitWalletFlags(uint64_t flags);930/** Loads the flags into the wallet. (used by LoadWallet) */931bool LoadWalletFlags(uint64_t flags);932//! Retrieve all of the wallet's flags933uint64_t GetWalletFlags() const;935/** Return wallet name for use in logs, will return "default wallet" if the wallet has no name. */936std::string LogName() const override937{938std::string name{GetName()};939return name.empty() ? "default wallet" : name;940};942/** Return wallet name for display, like LogName() but translates "default wallet" string. */943std::string DisplayName() const944{945std::string name{GetName()};946return name.empty() ? _("default wallet") : name;947};949/** Prepends the wallet name in logging output to ease debugging in multi-wallet use cases */950template <typename... Params>951void WalletLogPrintf(util::ConstevalFormatString<sizeof...(Params)> wallet_fmt, const Params&... params) const952{953LogInfo("[%s] %s", LogName(), tfm::format(wallet_fmt, params...));954};956void LogStats() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)957{958AssertLockHeld(cs_wallet);959WalletLogPrintf("setKeyPool.size() = %u\n", GetKeyPoolSize());960WalletLogPrintf("mapWallet.size() = %u\n", mapWallet.size());961WalletLogPrintf("m_address_book.size() = %u\n", m_address_book.size());962};964//! Returns all unique ScriptPubKeyMans in m_internal_spk_managers and m_external_spk_managers965std::set<ScriptPubKeyMan*> GetActiveScriptPubKeyMans() const;966bool IsActiveScriptPubKeyMan(const ScriptPubKeyMan& spkm) const;968//! Returns all unique ScriptPubKeyMans969std::set<ScriptPubKeyMan*> GetAllScriptPubKeyMans() const;971//! Get the ScriptPubKeyMan for the given OutputType and internal/external chain.972ScriptPubKeyMan* GetScriptPubKeyMan(const OutputType& type, bool internal) const;974//! Get all the ScriptPubKeyMans for a script975std::set<ScriptPubKeyMan*> GetScriptPubKeyMans(const CScript& script) const;976//! Get the ScriptPubKeyMan by id977ScriptPubKeyMan* GetScriptPubKeyMan(const uint256& id) const;979//! Get the SigningProvider for a script980std::unique_ptr<SigningProvider> GetSolvingProvider(const CScript& script) const;981std::unique_ptr<SigningProvider> GetSolvingProvider(const CScript& script, SignatureData& sigdata) const;983//! Get the wallet descriptors for a script.984std::vector<WalletDescriptor> GetWalletDescriptors(const CScript& script) const;986//! Get the LegacyDataSPKM used for all legacy output types and both internal and external chains.987LegacyDataSPKM* GetLegacyDataSPKM() const;988LegacyDataSPKM* GetOrCreateLegacyDataSPKM();990//! Create a LegacyDataSPKM and set it for all legacy output types and both internal and external chains.991void SetupLegacyDataSPKM();993bool WithEncryptionKey(std::function<bool (const CKeyingMaterial&)> cb) const override;995bool HasEncryptionKeys() const override;996bool HaveCryptedKeys() const;998/** Get last block processed height */999int GetLastBlockHeight() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)1000{
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.