Privacy on Bitcoin4.7(140)
Intermediate
Understand and master the principles of privacy protection when using Bitcoin
~/.Bitcoin/, under Windows in %APPDATA%\Bitcoin/, and under macOS in ~/Library/Application Support/Bitcoin/. If you're using a packaged solution (e.g., within a node distribution), this directory may be mounted elsewhere, but its structure remains the same. The important sub-folders and files described below are still located here.blkNNNNN.dat, stored in the blocks/ folder. Each file is filled in sequence until it reaches a maximum size of 128 MiB, at which point Core opens the next file. Inside, each block is serialized in network format, preceded by a magic identifier and a length. This organization enables fast writing to disk and facilitates block service to synchronize peers.blk*.dat containers as soon as the configured space target is reached, while retaining sufficient history to remain consistent with the best-known chain. The index and UTXO set remain normal, enabling the next transactions and blocks to be validated.blk file, a revNNNNN.dat file in blocks/. This file contains the information needed to undo the effect of a block on the UTXO set: for each output consumed by the block, the previous state of the corresponding UTXO is stored (amount, script, height...). In the event of a block abort, the node can quickly reconstitute the previous state without having to rescan the entire chain.blocks/index/ which lists, for each known block, metadata such as Hash, height, validation status, blk file, and offset where it is located. When a peer requests a block, or when an internal component needs to access a specific block, this index provides quick access. Without this index, too many operations would be required.indexes/txindex/, which we've already mentioned, provides a transaction → location mapping table, making it possible to retrieve any confirmed transaction without knowing the block that contains it. This is useful for off-wallet getrawtransaction type RPC queries, but is quite expensive.chainstate/ folder as a compact LevelDB database. Each part associates a key derived from the Hash of the transaction and the output index with a value containing: the amount, the scriptPubKey lock, the height of the creation block, and a coinbase indicator.dbcache parameter can be used to modify the size of this cache: the larger it is, the more memory access the IBD and current validation benefit from, at the cost of higher RAM consumption. When a new block is found by a miner, the node deletes from the UTXO set the outputs spent (or consumed) by the transactions included in the block and adds the newly created outputs.maxmempool parameter: a node with a larger Mempool will be able to hold more transactions than a node with a smaller Mempool (unless the latter becomes empty);OP_RETURN, etc.). If the transaction adheres to these rules, it is stored in memory.maxmempool parameter in the Bitcoin.conf file (more on this in the next chapter). By default, the limit is 300 MB. When it's full, the node dynamically raises its minimum charge threshold and expels the least profitable transactions first (i.e., it retains transactions that should be mined first). Transactions that are too old can also expire after a configured delay.Mempool.dat file when the node is shut down. In addition to the actual Mempool, which remains in memory, Core stores this Mempool.dat file on disk. The next time the node is launched, it reloads this snapshot and deletes anything that is no longer valid for the current Blockchain.blocks/, chainstate/, and indexes/ participate in the proper functioning of the:peers.dat keeps an IP address book of potential peers, fed by initial DNS discovery, network exchanges, and manual additions. When the node starts up, it can draw on this file to establish outgoing connections.anchors.dat saves the addresses of outgoing peers, so that you can try to contact them again quickly the next time you start up.banlist.json contains local bans decided by the operator or by the node (repeated invalid behavior), in order to prevent the node from reconnecting or accepting connections from these specific peers.fee_estimates.dat stores time horizon statistics on observed confirmations, used by the fee estimator to propose fee rates consistent with the delay objectives chosen when creating a transaction.bitcoin.conf contains your node’s configuration parameters. It is in this file that the relay rules can be adjusted. I will discuss this in more detail in the next chapter;settings.json contains additional parameters to Bitcoin.conf.debug.log is the diagnostic text log, which can be used to understand node activity in the event of a bug.bitcoind.pid records the process ID during execution, allowing other applications or scripts to easily identify Bitcoind (Bitcoin Daemon) and interact with it if necessary. It is created when the node starts and deleted when it stops;ip_asn.map is an IP → ASN mapping table (standalone system) used for bucketing and peer diversification (-asmap option).onion_v3_private_key stores the private key of the Tor v3 service when the -listenonion option is enabled, in order to keep a stable onion address between reboots.i2p_private_key stores the I2P private key when -i2psam= is used, to make outgoing and possibly incoming connections on I2P..cookie contains an ephemeral RPC authentication token (created at startup, deleted at shutdown) when cookie authentication is used. This can be used, for example, to connect wallet software..lock is the data directory lock, which prevents multiple instances from writing to the same datadir simultaneously.guisettings.ini.bak is the automatic saving of GUI settings (Bitcoin Qt) when the -resetguisettings option is used.wallets/ is the default directory that hosts one or more wallets;wallets/<name>/wallet.dat is the SQLite database of the wallet (keys, descriptors, transaction metadata, etc.);wallets/<name>/wallet.dat-journal is the SQLite rollback journal.~/.bitcoin/ ├── bitcoin.conf ├── blocks/ │ ├── blk00000.dat │ ├── blk00001.dat │ ├── rev00000.dat │ ├── rev00001.dat │ └── index/ ├── chainstate/ ├── indexes/ │ ├── txindex/ │ ├── blockfilter/ │ │ └── basic/ │ │ ├── db/ │ │ └── fltrNNNNN.dat │ └── coinstats/ │ └── db/ ├── wallets/ │ └── <wallet_name>/ │ ├── wallet.dat │ └── wallet.dat-journal ├── peers.dat ├── anchors.dat ├── banlist.json ├── mempool.dat ├── fee_estimates.dat ├── bitcoind.pid ├── debug.log ├── ip_asn.map ├── onion_v3_private_key ├── i2p_private_key ├── settings.json ├── guisettings.ini.bak ├── .cookie └── .lock
chainstate/.rev*.dat and metadata to the blocks/index/ index. The block is then serialized to the correct blk*.dat file. In the event of a reorganization, the node reads rev*.dat in reverse to cleanly disconnect the abandoned blocks, restore the UTXO set, and then connect the blocks of the new best chain.