Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1# Linearize2Construct a linear, no-fork, best version of the Bitcoin blockchain.4## Step 1: Download hash list6$ ./linearize-hashes.py linearize.cfg > hashlist.txt8Required configuration file settings for linearize-hashes:9* RPC: `datadir` (Required if `rpcuser` and `rpcpassword` are not specified)10* RPC: `rpcuser`, `rpcpassword` (Required if `datadir` is not specified)12Optional config file setting for linearize-hashes:13* RPC: `host` (Default: `127.0.0.1`)14* RPC: `port` (Default: `8332`)15* Blockchain: `min_height`, `max_height`16* `rev_hash_bytes`: If true, the written block hash list will be17byte-reversed. (In other words, the hash returned by getblockhash will have its18bytes reversed.) False by default. Intended for generation of19standalone hash lists but safe to use with linearize-data.py, which will output20the same data no matter which byte format is chosen.22The `linearize-hashes` script requires a connection, local or remote, to a23JSON-RPC server. Running `bitcoind` or `bitcoin-qt -server` will be sufficient.25## Step 2: Copy local block data27$ ./linearize-data.py linearize.cfg29Required configuration file settings:30* `output_file`: The file that will contain the final blockchain.31or32* `output`: Output directory for linearized `blocks/blkNNNNN.dat` output.34Optional config file setting for linearize-data:35* `debug_output`: Some printouts may not always be desired. If true, such output36will be printed.37* `file_timestamp`: Set each file's last-accessed and last-modified times,38respectively, to the current time and to the timestamp of the most recent block39written to the script's blockchain.40* `genesis`: The hash of the genesis block in the blockchain.41* `input`: bitcoind blocks/ directory containing blkNNNNN.dat42* `hashlist`: text file containing list of block hashes created by43linearize-hashes.py.44* `max_out_sz`: Maximum size for files created by the `output_file` option.45(Default: `1000*1000*1000 bytes`)46* `netmagic`: Network magic number.47* `out_of_order_cache_sz`: If out-of-order blocks are being read, the block can48be written to a cache so that the blockchain doesn't have to be sought again.49This option specifies the cache size. (Default: `100*1000*1000 bytes`)50* `rev_hash_bytes`: If true, the block hash list written by linearize-hashes.py51will be byte-reversed when read by linearize-data.py. See the linearize-hashes52entry for more information.53* `split_timestamp`: Split blockchain files when a new month is first seen, in54addition to reaching a maximum file size (`max_out_sz`).
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.