1# Bitcoin Core file system 2 3**Contents** 4 5- [Data directory location](#data-directory-location) 6 7- [Data directory layout](#data-directory-layout) 8 9- [Multi-wallet environment](#multi-wallet-environment) 10 11 - [Berkeley DB database based wallets](#berkeley-db-database-based-wallets) 12 13 - [SQLite database based wallets](#sqlite-database-based-wallets) 14 15- [GUI settings](#gui-settings) 16 17- [Legacy subdirectories and files](#legacy-subdirectories-and-files) 18 19- [Notes](#notes) 20 21## Data directory location 22 23The data directory is the default location where the Bitcoin Core files are stored. 24 251. The default data directory paths for supported platforms are: 26 27Platform | Data directory path 28---------|-------------------- 29Linux | `$HOME/.bitcoin/` 30macOS | `$HOME/Library/Application Support/Bitcoin/` 31Windows | `%APPDATA%\Bitcoin\` <sup>[\[1\]](#note1)</sup> 32 332. A custom data directory path can be specified with the `-datadir` option. 34 353. All content of the data directory, except for `bitcoin.conf` file, is chain-specific. This means the actual data directory paths for non-mainnet cases differ: 36 37Chain option | Data directory path 38-------------------------------|------------------------------ 39`-chain=main` (default) | *path_to_datadir*`/` 40`-chain=test` or `-testnet` | *path_to_datadir*`/testnet3/` 41`-chain=signet` or `-signet` | *path_to_datadir*`/signet/` 42`-chain=regtest` or `-regtest` | *path_to_datadir*`/regtest/` 43 44## Data directory layout 45 46Subdirectory | File(s) | Description 47-------------------|-----------------------|------------ 48`blocks/` | | Blocks directory; can be specified by `-blocksdir` option (except for `blocks/index/`) 49`blocks/index/` | LevelDB database | Block index; `-blocksdir` option does not affect this path 50`blocks/` | `blkNNNNN.dat`<sup>[\[2\]](#note2)</sup> | Actual Bitcoin blocks (in network format, dumped in raw on disk, 128 MiB per file) 51`blocks/` | `revNNNNN.dat`<sup>[\[2\]](#note2)</sup> | Block undo data (custom format) 52`chainstate/` | LevelDB database | Blockchain state (a compact representation of all currently unspent transaction outputs (UTXOs) and metadata about the transactions they are from) 53`indexes/txindex/` | LevelDB database | Transaction index; *optional*, used if `-txindex=1` 54`indexes/blockfilter/basic/db/` | LevelDB database | Blockfilter index LevelDB database for the basic filtertype; *optional*, used if `-blockfilterindex=basic` 55`indexes/blockfilter/basic/` | `fltrNNNNN.dat`<sup>[\[2\]](#note2)</sup> | Blockfilter index filters for the basic filtertype; *optional*, used if `-blockfilterindex=basic` 56`indexes/coinstats/db/` | LevelDB database | Coinstats index; *optional*, used if `-coinstatsindex=1` 57`wallets/` | | [Contains wallets](#multi-wallet-environment); can be specified by `-walletdir` option; if `wallets/` subdirectory does not exist, wallets reside in the [data directory](#data-directory-location) 58`./` | `anchors.dat` | Anchor IP address database, created on shutdown and deleted at startup. Anchors are last known outgoing block-relay-only peers that are tried to re-connect to on startup 59`./` | `banlist.dat` | Stores the addresses/subnets of banned nodes (deprecated). `bitcoind` or `bitcoin-qt` no longer save the banlist to this file, but read it on startup if `banlist.json` is not present. 60`./` | `banlist.json` | Stores the addresses/subnets of banned nodes. 61`./` | `bitcoin.conf` | User-defined [configuration settings](bitcoin-conf.md) for `bitcoind` or `bitcoin-qt`. File is not written to by the software and must be created manually. Path can be specified by `-conf` option 62`./` | `bitcoind.pid` | Stores the process ID (PID) of `bitcoind` or `bitcoin-qt` while running; created at start and deleted on shutdown; can be specified by `-pid` option 63`./` | `debug.log` | Contains debug information and general logging generated by `bitcoind` or `bitcoin-qt`; can be specified by `-debuglogfile` option 64`./` | `fee_estimates.dat` | Stores statistics used to estimate minimum transaction fees required for confirmation 65`./` | `guisettings.ini.bak` | Backup of former [GUI settings](#gui-settings) after `-resetguisettings` option is used 66`./` | `ip_asn.map` | IP addresses to Autonomous System Numbers (ASNs) mapping used for bucketing of the peers; path can be specified with the `-asmap` option 67`./` | `mempool.dat` | Dump of the mempool's transactions 68`./` | `onion_v3_private_key` | Cached Tor onion service private key for `-listenonion` option 69`./` | `i2p_private_key` | Private key that corresponds to our I2P address. When `-i2psam=` is specified the contents of this file is used to identify ourselves for making outgoing connections to I2P peers and possibly accepting incoming ones. Automatically generated if it does not exist. 70`./` | `peers.dat` | Peer IP address database (custom format) 71`./` | `settings.json` | Read-write settings set through GUI or RPC interfaces, augmenting manual settings from [bitcoin.conf](bitcoin-conf.md). File is created automatically if read-write settings storage is not disabled with `-nosettings` option. Path can be specified with `-settings` option 72`./` | `.cookie` | Session RPC authentication cookie; if used, created at start and deleted on shutdown; can be specified by `-rpccookiefile` option 73`./` | `.lock` | Data directory lock file 74 75## Multi-wallet environment 76 77Wallets are Berkeley DB (BDB) or SQLite databases. 78 791. Each user-defined wallet named "wallet_name" resides in the `wallets/wallet_name/` subdirectory. 80 812. The default (unnamed) wallet resides in `wallets/` subdirectory; if the latter does not exist, the wallet resides in the data directory. 82 833. A wallet database path can be specified with the `-wallet` option. 84 854. `wallet.dat` files must not be shared across different node instances, as that can result in key-reuse and double-spends due the lack of synchronization between instances. 86 875. Any copy or backup of the wallet should be done through a `backupwallet` call in order to update and lock the wallet, preventing any file corruption caused by updates during the copy. 88 89 90### Berkeley DB database based wallets 91 92Subdirectory | File(s) | Description 93-------------|-------------------|------------- 94`database/` | BDB logging files | Part of BDB environment; created at start and deleted on shutdown; a user *must keep it as safe* as personal wallet `wallet.dat` 95`./` | `db.log` | BDB error file 96`./` | `wallet.dat` | Personal wallet (a BDB database) with keys and transactions 97`./` | `.walletlock` | BDB wallet lock file 98 99### SQLite database based wallets 100 101Subdirectory | File | Description 102-------------|----------------------|------------- 103`./` | `wallet.dat` | Personal wallet (a SQLite database) with keys and transactions 104`./` | `wallet.dat-journal` | SQLite Rollback Journal file for `wallet.dat`. Usually created at start and deleted on shutdown. A user *must keep it as safe* as the `wallet.dat` file. 105 106 107## GUI settings 108 109`bitcoin-qt` uses [`QSettings`](https://doc.qt.io/qt-5/qsettings.html) class; this implies platform-specific [locations where application settings are stored](https://doc.qt.io/qt-5/qsettings.html#locations-where-application-settings-are-stored). 110 111## Legacy subdirectories and files 112 113These subdirectories and files are no longer used by Bitcoin Core: 114 115Path | Description | Repository notes 116---------------|-------------|----------------- 117`blktree/` | Blockchain index; replaced by `blocks/index/` in [0.8.0](https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-0.8.0.md#improvements) | [PR #2231](https://github.com/bitcoin/bitcoin/pull/2231), [`8fdc94cc`](https://github.com/bitcoin/bitcoin/commit/8fdc94cc8f0341e96b1edb3a5b56811c0b20bd15) 118`coins/` | Unspent transaction output database; replaced by `chainstate/` in 0.8.0 | [PR #2231](https://github.com/bitcoin/bitcoin/pull/2231), [`8fdc94cc`](https://github.com/bitcoin/bitcoin/commit/8fdc94cc8f0341e96b1edb3a5b56811c0b20bd15) 119`blkindex.dat` | Blockchain index BDB database; replaced by {`chainstate/`, `blocks/index/`, `blocks/revNNNNN.dat`<sup>[\[2\]](#note2)</sup>} in 0.8.0 | [PR #1677](https://github.com/bitcoin/bitcoin/pull/1677) 120`blk000?.dat` | Block data (custom format, 2 GiB per file); replaced by `blocks/blkNNNNN.dat`<sup>[\[2\]](#note2)</sup> in 0.8.0 | [PR #1677](https://github.com/bitcoin/bitcoin/pull/1677) 121`addr.dat` | Peer IP address BDB database; replaced by `peers.dat` in [0.7.0](https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-0.7.0.md) | [PR #1198](https://github.com/bitcoin/bitcoin/pull/1198), [`928d3a01`](https://github.com/bitcoin/bitcoin/commit/928d3a011cc66c7f907c4d053f674ea77dc611cc) 122`onion_private_key` | Cached Tor onion service private key for `-listenonion` option. Was used for Tor v2 services; replaced by `onion_v3_private_key` in [0.21.0](https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-0.21.0.md) | [PR #19954](https://github.com/bitcoin/bitcoin/pull/19954) 123 124## Notes 125 126<a name="note1">1</a>. The `/` (slash, U+002F) is used as the platform-independent path component separator in this document. 127 128<a name="note2">2</a>. `NNNNN` matches `[0-9]{5}` regex. 129