Back to Bitcoin

Bitcoin Core file system

doc/files.md

31.013.3 KB
Original Source

Bitcoin Core file system

Contents

Data directory location

The data directory is the default location where the Bitcoin Core files are stored.

  1. The default data directory paths for supported platforms are:
PlatformData directory path
Linux$HOME/.bitcoin/
macOS$HOME/Library/Application Support/Bitcoin/
Windows%LOCALAPPDATA%\Bitcoin\ <sup>[1]</sup>
  1. A custom data directory path can be specified with the -datadir option.

  2. 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:

Chain optionData directory path
-chain=main (default)path_to_datadir/
-chain=test or -testnetpath_to_datadir/testnet3/
-chain=testnet4 or -testnet4path_to_datadir/testnet4/
-chain=signet or -signetpath_to_datadir/signet/
-chain=regtest or -regtestpath_to_datadir/regtest/

Data directory layout

SubdirectoryFile(s)Description
blocks/Blocks directory; can be specified by -blocksdir option (except for blocks/index/)
blocks/index/LevelDB databaseBlock index; -blocksdir option does not affect this path
blocks/blkNNNNN.dat<sup>[2]</sup>Actual Bitcoin blocks (dumped in network format, 128 MiB per file)
blocks/revNNNNN.dat<sup>[2]</sup>Block undo data (custom format)
blocks/xor.datRolling XOR pattern for block and undo data files
chainstate/LevelDB databaseBlockchain state (a compact representation of all currently unspent transaction outputs (UTXOs) and metadata about the transactions they are from)
indexes/txindex/LevelDB databaseTransaction index; optional, used if -txindex=1
indexes/txospenderindex/LevelDB databaseTransaction spender index; optional, used if -txospenderindex=1
indexes/blockfilter/basic/db/LevelDB databaseBlockfilter index LevelDB database for the basic filtertype; optional, used if -blockfilterindex=basic
indexes/blockfilter/basic/fltrNNNNN.dat<sup>[2]</sup>Blockfilter index filters for the basic filtertype; optional, used if -blockfilterindex=basic
indexes/coinstatsindex/db/LevelDB databaseCoinstats index; optional, used if -coinstatsindex=1
wallets/Contains wallets; can be specified by -walletdir option; if wallets/ subdirectory does not exist, wallets reside in the data directory
./anchors.datAnchor 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
./banlist.jsonStores the addresses/subnets of banned nodes.
./bitcoin.confUser-defined configuration settings 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
./bitcoind.pidStores the process ID (PID) of bitcoind or bitcoin-qt while running; created at start and deleted on shutdown; can be specified by -pid option
./debug.logContains debug information and general logging generated by bitcoind or bitcoin-qt; can be specified by -debuglogfile option
./fee_estimates.datStores statistics used to estimate minimum transaction fees required for confirmation
./guisettings.ini.bakBackup of former GUI settings after -resetguisettings option is used
./mempool.datDump of the mempool's transactions
./onion_v3_private_keyCached Tor onion service private key for -listenonion option
./i2p_private_keyPrivate 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.
./peers.datPeer IP address database (custom format)
./settings.jsonRead-write settings set through GUI or RPC interfaces, augmenting manual settings from bitcoin.conf. File is created automatically if read-write settings storage is not disabled with -nosettings option. Path can be specified with -settings option
./.cookieSession RPC authentication cookie; if used, created at start and deleted on shutdown; can be specified by -rpccookiefile option
./.lockData directory lock file

Multi-wallet environment

Wallets are SQLite databases.

  1. Each user-defined wallet named "wallet_name" resides in the wallets/wallet_name/ subdirectory.

  2. The default (unnamed) wallet resides in wallets/ subdirectory; if the latter does not exist, the wallet resides in the data directory.

  3. A wallet database path can be specified with the -wallet option.

  4. wallet.dat files must not be shared across different node instances, as that can result in key-reuse and double-spends due to the lack of synchronization between instances.

  5. 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.

SQLite database based wallets

SubdirectoryFileDescription
./wallet.datPersonal wallet (a SQLite database) with keys and transactions
./wallet.dat-journalSQLite 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.

GUI settings

bitcoin-qt uses QSettings class; this implies platform-specific locations where application settings are stored.

Legacy subdirectories and files

These subdirectories and files are no longer used by Bitcoin Core:

PathDescriptionRepository notes
banlist.datStores the addresses/subnets of banned nodes; superseded by banlist.json in 22.0 and completely ignored in 23.0PR #20966, PR #22570
blktree/Blockchain index; replaced by blocks/index/ in 0.8.0PR #2231, 8fdc94cc
coins/Unspent transaction output database; replaced by chainstate/ in 0.8.0PR #2231, 8fdc94cc
blkindex.datBlockchain index BDB database; replaced by {chainstate/, blocks/index/, blocks/revNNNNN.dat<sup>[2]</sup>} in 0.8.0PR #1677
blk000?.datBlock data (custom format, 2 GiB per file); replaced by blocks/blkNNNNN.dat<sup>[2]</sup> in 0.8.0PR #1677
addr.datPeer IP address BDB database; replaced by peers.dat in 0.7.0PR #1198, 928d3a01
onion_private_keyCached Tor onion service private key for -listenonion option. Was used for Tor v2 services; replaced by onion_v3_private_key in 0.21.0PR #19954

Berkeley DB database based wallets

SubdirectoryFile(s)Description
database/BDB logging filesPart of BDB environment; created at start and deleted on shutdown; a user must keep it as safe as personal wallet wallet.dat
./db.logBDB error file
./wallet.datPersonal wallet (a BDB database) with keys and transactions
./.walletlockBDB wallet lock file

Notes

<a name="note1">1</a>. The / (slash, U+002F) is used as the platform-independent path component separator in this document.

<a name="note2">2</a>. NNNNN matches [0-9]{5} regex.

Installed Files

This table describes the files installed by Bitcoin Core across different platforms.

PathDescription
README.md or readme.txtProject information and instructions
bitcoin.confGenerated configuration file
bin/bitcoinCommand-line tool for interacting with Bitcoin. Calls other binaries below.
bin/bitcoin-cliTool for making node and wallet RPC calls.
bin/bitcoin-qtBitcoin node and wallet GUI
bin/bitcoin-txTool for creating and modifying transactions
bin/bitcoin-utilMiscellaneous utilities
bin/bitcoin-walletBitcoin wallet tool
bin/bitcoindBitcoin node and wallet daemon
lib/libbitcoinkernel.soShared library containing core consensus and validation code
lib/pkgconfig/libbitcoinkernel.pcPkg-config metadata for linking to libbitcoinkernel
libexec/bench_bitcoinBenchmarking tool for measuring node performance
libexec/bitcoin-chainstateTool to validate and connect blocks
libexec/bitcoin-guiIPC-enabled alternative to bitcoin-qt
libexec/bitcoin-nodeIPC-enabled alternative to bitcoind
libexec/test_bitcoinUnit test binary
libexec/test_bitcoin-qtGUI-specific unit tests
share/man/man1/Man pages for command-line tools like bitcoin-cli, bitcoind, and others
share/rpcauth/Documentation and scripts for RPC authentication setup

Notes

  • Italicized files are only installed in source builds if relevant CMake options are enabled. They are not included in binary releases.
  • README and bitcoin.conf files are included in binary releases but not installed in source builds.
  • On Windows, binaries have a .exe suffix (e.g., bitcoin-cli.exe).

Filesystem recommendations

When choosing a filesystem for the data directory (datadir) or blocks directory (blocksdir) on macOS,the exFAT filesystem should be avoided. There have been multiple reports of database corruption and data loss when using this filesystem with Bitcoin Core, see Issue #31454 for more details.