Data directory

From Bitcoin Wiki
Revision as of 02:27, 15 July 2013 by Mueslo (talk | contribs)
Jump to: navigation, search

The location where Bitcoin's data files are stored, including the wallet data file.

Default Location

Windows

Go to Start -> Run (or press WinKey+R) and run this:

explorer %APPDATA%\Bitcoin

Bitcoin's data folder will open. For most users, this is the following locations:

C:\Documents and Settings\YourUserName\Application data\Bitcoin (XP)

C:\Users\YourUserName\Appdata\Roaming\Bitcoin (Vista and 7)

"AppData" and "Application data" are hidden by default.

You can also store Bitcoin data files in any other drive or folder.

If you have already downloaded the data then you will have to move the data to the new folder. If you want to store them in D:\BitcoinData then click on "Properties" of a shortcut to bitcoin-qt.exe and add -datadir=D:\BitCoinData at the end as an example:

"C:\Program Files (x86)\Bitcoin\bitcoin-qt.exe" -datadir=d:\BitCoinData

Start Bitcoin, now you will see all the files are created in the new data directory.

Linux

By default Bitcoin will put its data here:

~/.bitcoin/

You need to do a "ls -a" to see directories that start with a dot.

If that's not it, you can do a search like this:

find / -name wallet.dat -print 2>/dev/null

Mac

By default Bitcoin will put its data here:

~/Library/Application Support/Bitcoin/

Directory Contents

Files

  • .lock
    • BDB lock file
  • bitcoin.conf [optional]
  • blkxxxx.dat [Versions prior to v0.8.0]
    • Contains concatenated raw blocks. Stored are actual Bitcoin blocks, in network format, dumped to disk raw.
  • blkindex.dat [Versions prior to v0.8.0]
    • Indexing information used with blkxxxx.dat
  • __db.xxx
    • Used by BDB
  • db.log
  • debug.log
    • Bitcoin's verbose log file. Automatically trimmed from time to time.
  • wallet.dat
    • Storage for keys, transactions, metadata, and options. Please be sure to make backups of this file. It contains the keys necessary for spending your bitcoins.
  • addr.dat [Versions prior to v0.7.0]
    • Storage for ip addresses to make a reconnect easier
  • peers.dat [Versions v0.7.0 and later]
    • Storage for peer information to make a reconnect easier. This file uses a bitcoin-specific file format, unrelated to any database system[1].

The data, index and log files are used by Oracle Berkeley DB, the embedded key/value data store that Bitcoin uses.

database subdirectory

Contains BDB journaling files

testnet3 subdirectory

Contains testnet versions of these files (if running with -testnet)

blocks subdirectory

[v0.8 and above] Contains blockchain data.

  • blk*.dat
    • Stored are actual Bitcoin blocks, in network format, dumped to disk raw. They are only needed for re-scanning missing transactions in a wallet, reorganizing to a different part of the chain, and serving the block data to other nodes that are synchronizing.
  • blocks/index subdirectory
    • [v0.8 and above] A LevelDB database that contains metadata about all known blocks, and where to find them on disk. Without this, finding a block would be very slow.

chainstate subdirectory

[v0.8 and above] A LevelDB database with a compact representation of all currently unspent transaction outputs and some metadata about the transactions they are from. The data here is necessary for validating new incoming blocks and transactions. It can theoretically be rebuilt from the block data (see the -reindex command line option), but this takes a rather long time. Without it, you could still theoretically do validation indeed, but it would mean a full scan through the blocks (7 GB as of may 2013) for every output being spent.

locks subdirectory

[v0.8 and above] Contains "undo" data.

  • rev*.dat

You can see blocks as 'patches' to the chain state (they consume some unspent outputs, and produce new ones), and see the undo data as reverse patches. They are necessary for rolling back the chainstate, which is necessary in case of reorganizations.

See Also

References