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.
251bool IsEncrypted();253bool WriteOrderPosNext(int64_t nOrderPosNext);255bool WriteDescriptorKey(const uint256& desc_id, const CPubKey& pubkey, const CPrivKey& privkey);256bool WriteCryptedDescriptorKey(const uint256& desc_id, const CPubKey& pubkey, const std::vector<unsigned char>& secret);257bool WriteDescriptor(const uint256& desc_id, const WalletDescriptor& descriptor);258bool WriteDescriptorDerivedCache(const CExtPubKey& xpub, const uint256& desc_id, uint32_t key_exp_index, uint32_t der_index);259bool WriteDescriptorParentCache(const CExtPubKey& xpub, const uint256& desc_id, uint32_t key_exp_index);260bool WriteDescriptorLastHardenedCache(const CExtPubKey& xpub, const uint256& desc_id, uint32_t key_exp_index);261bool WriteDescriptorCacheItems(const uint256& desc_id, const DescriptorCache& cache);263bool WriteLockedUTXO(const COutPoint& output);264bool EraseLockedUTXO(const COutPoint& output);266bool WriteAddressPreviouslySpent(const CTxDestination& dest, bool previously_spent);267bool WriteAddressReceiveRequest(const CTxDestination& dest, const std::string& id, const std::string& receive_request);268bool EraseAddressReceiveRequest(const CTxDestination& dest, const std::string& id);269bool EraseAddressData(const CTxDestination& dest);271bool WriteActiveScriptPubKeyMan(uint8_t type, const uint256& id, bool internal);272bool EraseActiveScriptPubKeyMan(uint8_t type, bool internal);274DBErrors LoadWallet(CWallet* pwallet);276/**277* Write the given `client_version` to m_batch, indicating the last version278* of client software to load this wallet.279*280* @param[in] client_version `CLIENT_VERSION` outside of test code.281* @return A bool indicating whether or not the write succeeded.282*/283bool WriteVersion(int client_version) { return m_batch->Write(DBKeys::VERSION, client_version); }285//! Delete records of the given types286bool EraseRecords(const std::unordered_set<std::string>& types);288bool WriteWalletFlags(uint64_t flags);289//! Begin a new transaction290bool TxnBegin();291//! Commit current transaction292bool TxnCommit();293//! Abort current transaction294bool TxnAbort();295bool HasActiveTxn() { return m_batch->HasActiveTxn(); }297//! Registers db txn callback functions298void RegisterTxnListener(const DbTxnListener& l);300private:301std::unique_ptr<DatabaseBatch> m_batch;303// External functions listening to the current db txn outcome.304// Listeners are cleared at the end of the transaction.305std::vector<DbTxnListener> m_txn_listeners;306};308/**309* Executes the provided function 'func' within a database transaction context.310*311* This function ensures that all db modifications performed within 'func()' are312* atomically committed to the db at the end of the process. And, in case of a313* failure during execution, all performed changes are rolled back.314*315* @param database The db connection instance to perform the transaction on.316* @param process_desc A description of the process being executed, used for logging purposes in the event of a failure.317* @param func The function to be executed within the db txn context. It returns a boolean indicating whether to commit or roll back the txn.318* @return true if the db txn executed successfully, false otherwise.319*/320bool RunWithinTxn(WalletDatabase& database, std::string_view process_desc, const std::function<bool(WalletBatch&)>& func);322bool LoadKey(CWallet* pwallet, DataStream& ssKey, DataStream& ssValue, std::string& strErr);323bool LoadCryptedKey(CWallet* pwallet, DataStream& ssKey, DataStream& ssValue, std::string& strErr);324bool LoadEncryptionKey(CWallet* pwallet, DataStream& ssKey, DataStream& ssValue, std::string& strErr);325bool LoadHDChain(CWallet* pwallet, DataStream& ssValue, std::string& strErr);327//! Returns true if there are any DBKeys::LEGACY_TYPES record in the wallet db328bool HasLegacyRecords(CWallet& wallet);329bool HasLegacyRecords(CWallet& wallet, DatabaseBatch& batch);330} // namespace wallet332#endif // BITCOIN_WALLET_WALLETDB_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.