Wallet Database Layout - bitcoin-core/bitcoin-devwiki GitHub Wiki

The wallet database is a SQLite Database.

Pragmas

The database has several pragmas set on it

  • locking_mode = exclusive

  • fullfsync = true

  • application_id = <network magic>

  • user_version = 0

  • synchronous = off if -unsafesqlitesync

Tables

  • CREATE TABLE main(key BLOB PRIMARY KEY NOT NULL, value BLOB NOT NULL)

main

key `value Description
0x07 "acentry" No longer used
0x11 "activeexternalspk" <uint8 output type> <uint256 id> Descriptor ID for the SPKM active for an output type for receiving addresses.
0x11 "activeinternalspk" ` <uint256 id> Descriptor ID for the SPKM active for an output type for change addresses.
0x12 "bestblock_nomerkle" <CBlockLocator locator> Locator for the block that the wallet is synced up to
0x09 "bestblock" <CBlockLocator locator> Usually an empty locator, field used by old wallets that stored the best block when the wallet stored merkle branches
0x04 "ckey" <pubkey length> <pubkey> <encrypted key length> <encrypted key> <uint256 checksum> Legacy wallet encrypted private keys
0x07 "cscript" <uint160 script id> <script length> <script> Legacy wallet redeem or witness script
0x0a "defaultkey" <pubkey len> <pubkey> A public key
0x08 "destdata" <address len> <address> 0x04 "used" "1" or "p" Whether an address has been used before.
0x08 "destdata" <address len> <address> <length> "rr" <n> <string receive request> Receive request for an address
0x05 "flags" <uint64 flags> Wallet feature flags
0x07 "hdchain" <CHDChain hdchain> Legacy wallet HD chain information
0x07 "keymeta" <pubkey len> <pubkey> <CKeyMetadata> Legacy wallet metadata about a key
0x03 "key" <pubkey len> <pubkey> <CPrivKey privkey> Legacy wallet private key
0x0a "lockedutxo" <txid> <uint32 n> 0x01 UTXO that coin selection should not select
0x04 "mkey" <uint32 id> <CMasterKey encrypt key> Encrypted encryption key for encrypting private keys
0x10 "minversion" <uint32 version> Minimum wallet software version required to open this wallet. No longer used.
0x04 "name" <address len> <address> <name len> <string name> Label assigned to an address
0x04 "wkey" <CPrivKey privkey> Very old wallet record storing a key, was never actually used for anything
0x0c "orderposnext" <int64 next> nOrderPos for the next transaction to be added to the wallet
0x04 "pool" Legacy wallet keypool entry
0x07 "purpose" <address len> <address> <purpose len> <string purpose> Purpose assigned to an address
0x08 "settings" No longer used
0x02 "tx" <txid> <CTransaction tx> <uint256 block hash> 0x00 <int32 state index> 0x00 <map size> (<One of "n", "timesmart", "from", "message", "comment", "to", "replaces_txid", or "replaced_by_txid"> <string value>)* <vector len> (<One of "Message" or "PaymentRequest"> <string value>)* 0x00000000 <uint32 time received> 0x00 0x00 A transaction in the wallet with metadata
0x0a "wtxvariant" <txid> <wtxid> <tx> A transaction with a possibly different witness related to a tx record
0x07 "version" <int32 version> Version number of the last wallet software to open the wallet
0x10 "walletdescriptor" <uint256 descriptor id> WalletDescriptor A descriptor stored in the wallet, with metadata
0x15 "walletdescriptorcache" <uint256 descriptor id> <uint32 key expression index> <uint32 derivation index> <CExtPubKey> Cached derived key for a descriptor key expression
0x17 "walletdescriptorlhcache" <uint256 descriptor id> <uint32 key expression index> <CExtPubKey> The cached key at the last hardened derivation index for a descriptor key expression
0x14 "walletdescriptorckey" <uint256 descriptor id> <pubkey len> <pubkey> <encrypted privkey len> <encrypted privkey> An encrypted private key relevant to a descriptor
0x13 "walletdescriptorkey" <uint256 descriptor id> <pubkey len> <pubkey> <CPrivKey privkey> <uint256 checksum> A private key relevant to a descriptor
0x09 "watchmeta" <script len> <script> CKeyMetadata Legacy wallet metadata about a watchonly script
0x06 "watchs" script len> <script>` 0x01 Legacy wallet watchonly script
⚠️ **GitHub.com Fallback** ⚠️