-
Notifications
You must be signed in to change notification settings - Fork 48
Wallet Database Layout
Ava Chow edited this page Sep 14, 2026
·
2 revisions
The wallet database is a SQLite Database.
The database has several pragmas set on it
-
locking_mode = exclusive -
fullfsync = true -
application_id = <network magic> -
user_version = 0 -
synchronous = offif-unsafesqlitesync
CREATE TABLE main(key BLOB PRIMARY KEY NOT NULL, value BLOB NOT NULL)
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 |
IRC Meetings & Working groups
Build & Dev
- 32.0 Release Candidate Testing Guide
- CMake Goals and Guidelines
- GitHub-alternatives-for-Bitcoin-Core
- Fuzz Trophies
- Developer Notes for Qt Code
P2P & Network
- [P2P] known TxOrphanage problems
- Addrman and eclipse attacks
- Mempool and mining
- P2P Current Priorities
- P2P Design Philosophy
Wallet
- Improving Large Wallet Performance
- Wallet Class Structure Changes
- Wallet Transaction Conflict Tracking
- Wallet Use Cases
- Database Layout
External Resources
**Archival Testing Guides **