Data directory: Difference between revisions

From Bitcoin Wiki
Jump to navigation Jump to search
Capsqrl (talk | contribs)
m D:\BitCoinData -> D:\BitcoinData
NotATether (talk | contribs)
m Windows 8, 10 and 11 all use AppData\Roaming
 
(16 intermediate revisions by 7 users not shown)
Line 10: Line 10:
Bitcoin's data folder will open. For most users, this is the following locations:
Bitcoin's data folder will open. For most users, this is the following locations:


  C:\Documents and Settings\YourUserName\Application data\Bitcoin (XP)
  C:\Documents and Settings\YourUserName\Application Data\Bitcoin (XP)
   
   
  C:\Users\YourUserName\Appdata\Roaming\Bitcoin (Vista and 7)
  C:\Users\YourUserName\AppData\Roaming\Bitcoin (Vista and later)


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


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


===Files===
===Files===
* .lock
**BDB lock file
* bitcoin.conf [optional]
**Contains [[Running_Bitcoin#Bitcoin.conf_Configuration_File|configuration options]]. 
* blk''xxxx''.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 blk''xxxx''.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. <span style="color:red">Please be sure to make backups of this file.  It contains the keys necessary for spending your bitcoins.</span>
* 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<ref>[http://bitcointalk.org/index.php?topic=119525.msg1287284#msg1287284 Ultraprune merged in mainline]</ref>.
The data, index and log files are used by Oracle [http://en.wikipedia.org/wiki/Berkeley_DB Berkeley DB], the embedded key/value data store that Bitcoin uses.


===database subdirectory===
An overview of these is in [https://github.com/bitcoin/bitcoin/blob/master/doc/files.md files.md] in the Bitcoin Core documentation.
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.
 
===Bootstrapping the blockchain from a snapshot distributed through BitTorrent===
There is a [https://bitcoin.org/bin/block-chain/ torrent file that gets updated] every few months that enables a much faster download of the blockchain. Once downloaded, the bootstrap.dat file can be placed in the root of the data directory, and Bitcoin Core 0.7.1 and above will automatically import it. '''NOTE:''' As of Bitcoin Core version 0.10.0 and later, the blockchain bootstrap
torrent is ''slower'' than a direct download using the bitcoin P2P protocol & client.<ref>[https://bitcoin.org/bin/block-chain/README.txt README.txt for bootstrap.dat.torrent]</ref>


===Personally identifiable data [v0.8 and above]===
===Personally identifiable data [v0.8 and above]===
Line 108: Line 62:
**This should only exist when bitcoin-qt is currently running. It contains information (BDB state) relating to your wallet.
**This should only exist when bitcoin-qt is currently running. It contains information (BDB state) relating to your wallet.
*peers.dat
*peers.dat
**Unknown whether this contains personally identifiable data. It may be safely deleted.
**It contains addresses and connection statistics of peers, but does not contain any personally identifiable data. It may be safely deleted.
*bitcoin.conf
**May contain your IP or hidden service address, paths on your filesystem, and RPC credentials.
*settings.json
**Contains GUI settings with a similar nature to those in bitcoin.conf.
*.cookie
**Contains temporary RPC credentials in situations where you haven't specified an explicit username & password. Do not share with others.
*onion_v3_private_key
**Contains your hidden service key if you are running Bitcoin Core through a Tor connection. Do not share with others or they will be able to spoof your .onion address. On older versions of Core this file was called <code>onion_v2_private_key</code>.
 


Other files and folders (blocks, blocks/index, chainstate) may be safely transferred/archived as they contain information pertaining only to the public blockchain.
Other files and folders (blocks, blocks/index, chainstate) may be safely transferred/archived as they contain information pertaining only to the public blockchain.
==Transferability==
The database files in the "blocks" and "chainstate" directories are cross-platform, and can be copied between different installations. These files, known collectively as a node's "block database", represent all of the information downloaded by a node during the syncing process. In other words, if you copy installation A's block database into installation B, installation B will then have the same syncing percentage as installation A. This is usually ''far'' faster than doing the normal initial sync over again. However, when you copy someone's database in this way, you are trusting them '''absolutely'''. Bitcoin Core treats its block database files as 100% accurate and trustworthy, whereas during the normal initial sync it treats each block offered by a peer as invalid until proven otherwise. If an attacker is able to modify your block database files, then they can do all sorts of evil things which could cause you to lose bitcoins. Therefore, you should only copy block databases from Bitcoin installations under your personal control, and only over a secure connection.
Each node has a unique block database, and all of the files are highly connected. So if you copy just a few files from one installation's "blocks" or "chainstate" directories into another installation, this will almost certainly cause the second node to crash or get stuck at some random point in the future. If you want to copy a block database from one installation to another, you have to delete the old database and copy ''all'' of the files at once. Both nodes have to be shut down while copying.
Only the file with the highest number in the "blocks" directory is ever written to. The earlier files will never change. Also, when these blk*.dat files are accessed, they are usually accessed in a highly sequential manner. Therefore, it's possible to symlink the "blocks" directory or some subset of the blk*.dat files individually onto a magnetic storage drive without much loss in performance (see [[Splitting the data directory]]), and if two installations start out with identical block databases (due to the copying described previously), subsequent runs of rsync will be very efficient.


==See Also==
==See Also==
Line 116: Line 87:
* [[Running Bitcoin]]
* [[Running Bitcoin]]
* [[Securing your wallet]]
* [[Securing your wallet]]
* [[Splitting the data directory]]
* [http://bitcoin.stackexchange.com/a/11108/153 What is the database for?] Question on Bitcoin Stack Exchange
* [http://bitcoin.stackexchange.com/a/11108/153 What is the database for?] Question on Bitcoin Stack Exchange


Line 124: Line 96:


[[es:Directorio de datos]]
[[es:Directorio de datos]]
{{Bitcoin Core documentation}}

Latest revision as of 10:34, 22 March 2024

The data directory is 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:

%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 later)

"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

An overview of these is in files.md in the Bitcoin Core documentation.

Personally identifiable data [v0.8 and above]

This section may be of use to you if you wish to send a friend the blockchain, avoiding them a hefty download.

  • wallet.dat
    • Contains addresses and transactions linked to them. Please be sure to make backups of this file. It contains the keys necessary for spending your bitcoins. You should not transfer this file to any third party or they may be able to access your bitcoins.
  • db.log
    • May contain information pertaining to your wallet. It may be safely deleted.
  • debug.log
    • May contain IP addresses and transaction ID's. It may be safely deleted.
  • database/ folder
    • This should only exist when bitcoin-qt is currently running. It contains information (BDB state) relating to your wallet.
  • peers.dat
    • It contains addresses and connection statistics of peers, but does not contain any personally identifiable data. It may be safely deleted.
  • bitcoin.conf
    • May contain your IP or hidden service address, paths on your filesystem, and RPC credentials.
  • settings.json
    • Contains GUI settings with a similar nature to those in bitcoin.conf.
  • .cookie
    • Contains temporary RPC credentials in situations where you haven't specified an explicit username & password. Do not share with others.
  • onion_v3_private_key
    • Contains your hidden service key if you are running Bitcoin Core through a Tor connection. Do not share with others or they will be able to spoof your .onion address. On older versions of Core this file was called onion_v2_private_key.


Other files and folders (blocks, blocks/index, chainstate) may be safely transferred/archived as they contain information pertaining only to the public blockchain.

Transferability

The database files in the "blocks" and "chainstate" directories are cross-platform, and can be copied between different installations. These files, known collectively as a node's "block database", represent all of the information downloaded by a node during the syncing process. In other words, if you copy installation A's block database into installation B, installation B will then have the same syncing percentage as installation A. This is usually far faster than doing the normal initial sync over again. However, when you copy someone's database in this way, you are trusting them absolutely. Bitcoin Core treats its block database files as 100% accurate and trustworthy, whereas during the normal initial sync it treats each block offered by a peer as invalid until proven otherwise. If an attacker is able to modify your block database files, then they can do all sorts of evil things which could cause you to lose bitcoins. Therefore, you should only copy block databases from Bitcoin installations under your personal control, and only over a secure connection.

Each node has a unique block database, and all of the files are highly connected. So if you copy just a few files from one installation's "blocks" or "chainstate" directories into another installation, this will almost certainly cause the second node to crash or get stuck at some random point in the future. If you want to copy a block database from one installation to another, you have to delete the old database and copy all of the files at once. Both nodes have to be shut down while copying.

Only the file with the highest number in the "blocks" directory is ever written to. The earlier files will never change. Also, when these blk*.dat files are accessed, they are usually accessed in a highly sequential manner. Therefore, it's possible to symlink the "blocks" directory or some subset of the blk*.dat files individually onto a magnetic storage drive without much loss in performance (see Splitting the data directory), and if two installations start out with identical block databases (due to the copying described previously), subsequent runs of rsync will be very efficient.

See Also

References