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.
252// Return whether the wallet is blank.253virtual bool canGetAddresses() = 0;255// Return whether private keys enabled.256virtual bool privateKeysDisabled() = 0;258// Return whether the wallet contains a Taproot scriptPubKeyMan259virtual bool taprootEnabled() = 0;261// Return whether wallet uses an external signer.262virtual bool hasExternalSigner() = 0;264// Get default address type.265virtual OutputType getDefaultAddressType() = 0;267//! Get max tx fee.268virtual CAmount getDefaultMaxTxFee() = 0;270// Remove wallet.271virtual void remove() = 0;273//! Register handler for unload message.274using UnloadFn = std::function<void()>;275virtual std::unique_ptr<Handler> handleUnload(UnloadFn fn) = 0;277//! Register handler for show progress messages.278using ShowProgressFn = std::function<void(const std::string& title, int progress)>;279virtual std::unique_ptr<Handler> handleShowProgress(ShowProgressFn fn) = 0;281//! Register handler for status changed messages.282using StatusChangedFn = std::function<void()>;283virtual std::unique_ptr<Handler> handleStatusChanged(StatusChangedFn fn) = 0;285//! Register handler for address book changed messages.286using AddressBookChangedFn = std::function<void(const CTxDestination& address,287const std::string& label,288bool is_mine,289wallet::AddressPurpose purpose,290ChangeType status)>;291virtual std::unique_ptr<Handler> handleAddressBookChanged(AddressBookChangedFn fn) = 0;293//! Register handler for transaction changed messages.294using TransactionChangedFn = std::function<void(const Txid& txid, ChangeType status)>;295virtual std::unique_ptr<Handler> handleTransactionChanged(TransactionChangedFn fn) = 0;297//! Register handler for keypool changed messages.298using CanGetAddressesChangedFn = std::function<void()>;299virtual std::unique_ptr<Handler> handleCanGetAddressesChanged(CanGetAddressesChangedFn fn) = 0;301//! Return pointer to internal wallet class, useful for testing.302virtual wallet::CWallet* wallet() { return nullptr; }304//! Export a watchonly wallet file. See CWallet::ExportWatchOnlyWallet305virtual util::Result<std::string> exportWatchOnlyWallet(const fs::path& destination) = 0;306};308//! Wallet chain client that in addition to having chain client methods for309//! starting up, shutting down, and registering RPCs, also has additional310//! methods (called by the GUI) to load and create wallets.311class WalletLoader : public ChainClient312{313public:314//! Create new wallet.315virtual util::Result<std::unique_ptr<Wallet>> createWallet(const std::string& name, const SecureString& passphrase, uint64_t wallet_creation_flags, std::vector<bilingual_str>& warnings) = 0;317//! Load existing wallet.318virtual util::Result<std::unique_ptr<Wallet>> loadWallet(const std::string& name, std::vector<bilingual_str>& warnings) = 0;320//! Return default wallet directory.321virtual std::string getWalletDir() = 0;323//! Restore backup wallet324virtual util::Result<std::unique_ptr<Wallet>> restoreWallet(const fs::path& backup_file, const std::string& wallet_name, std::vector<bilingual_str>& warnings, bool load_after_restore) = 0;326//! Migrate a wallet327virtual util::Result<WalletMigrationResult> migrateWallet(const std::string& name, const SecureString& passphrase, bool load_wallet) = 0;329//! Returns true if wallet stores encryption keys330virtual bool isEncrypted(const std::string& wallet_name) = 0;332//! Return available wallets in wallet directory.333virtual std::vector<std::pair<std::string, std::string>> listWalletDir() = 0;335//! Return interfaces for accessing wallets (if any).336virtual std::vector<std::unique_ptr<Wallet>> getWallets() = 0;338//! Register handler for load wallet messages. This callback is triggered by339//! createWallet and loadWallet above, and also triggered when wallets are340//! loaded at startup or by RPC.341using LoadWalletFn = std::function<void(std::unique_ptr<Wallet> wallet)>;342virtual std::unique_ptr<Handler> handleLoadWallet(LoadWalletFn fn) = 0;344//! Return pointer to internal context, useful for testing.345virtual wallet::WalletContext* context() { return nullptr; }346};348//! Information about one wallet address.349struct WalletAddress350{351CTxDestination dest;352bool is_mine;353wallet::AddressPurpose purpose;354std::string name;356WalletAddress(CTxDestination dest, bool is_mine, wallet::AddressPurpose purpose, std::string name)357: dest(std::move(dest)), is_mine(is_mine), purpose(std::move(purpose)), name(std::move(name))358{359}360};362//! Collection of wallet balances.363struct WalletBalances364{365CAmount balance = 0;366CAmount unconfirmed_balance = 0;367CAmount immature_balance = 0;368CAmount used_balance = 0;369CAmount nonmempool_balance = 0;371bool balanceChanged(const WalletBalances& prev) const372{373return balance != prev.balance || unconfirmed_balance != prev.unconfirmed_balance ||374immature_balance != prev.immature_balance ||375used_balance != prev.used_balance || nonmempool_balance != prev.nonmempool_balance;376}377};379// Wallet transaction information.380struct WalletTx381{382CTransactionRef tx;383std::vector<bool> txin_is_mine;384std::vector<bool> txout_is_mine;385std::vector<bool> txout_is_change;386std::vector<CTxDestination> txout_address;387std::vector<bool> txout_address_is_mine;388CAmount credit;389CAmount debit;390CAmount change;391int64_t time;392std::optional<std::string> from; // Deprecated393std::optional<std::string> message; // Deprecated394std::optional<std::string> comment;395std::optional<std::string> comment_to;396bool is_coinbase;398bool operator<(const WalletTx& a) const { return tx->GetHash() < a.tx->GetHash(); }399};401//! Updated transaction status.402struct WalletTxStatus403{404int block_height;405int blocks_to_maturity;406int depth_in_main_chain;407unsigned int time_received;408uint32_t lock_time;409bool is_trusted;410bool is_abandoned;411bool is_coinbase;412bool is_in_main_chain;413};415//! Wallet transaction output.416struct WalletTxOut417{418CTxOut txout;419int64_t time;420int depth_in_main_chain = -1;421bool is_spent = false;422};424//! Migrated wallet info425struct WalletMigrationResult426{427std::unique_ptr<Wallet> wallet;428std::optional<std::string> watchonly_wallet_name;429std::optional<std::string> solvables_wallet_name;430fs::path backup_path;431};433//! Return implementation of Wallet interface. This function is defined in434//! dummywallet.cpp and throws if the wallet component is not compiled.435std::unique_ptr<Wallet> MakeWallet(wallet::WalletContext& context, const std::shared_ptr<wallet::CWallet>& wallet);437//! Return implementation of ChainClient interface for a wallet loader. This438//! function will be undefined in builds where ENABLE_WALLET is false.439std::unique_ptr<WalletLoader> MakeWalletLoader(Chain& chain, ArgsManager& args);441} // namespace interfaces443#endif // BITCOIN_INTERFACES_WALLET_H
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.