Bitcoin Core v0.1 code walkthrough — Forensicxs's 31,794-line analysis

Figures: Satoshi Nakamoto

On August 6, 2024, the cybersecurity researcher known as Forensicxs published “Bitcoin Core v0.1: a code walkthrough” — a comprehensive analysis of Satoshi Nakamoto’s original Bitcoin source code released on January 9, 2009.

Scope: Forensicxs analyzed the Bitcoin v0.1 codebase as 31,794 lines across 31 files, written in C++ and released under the MIT X11 license. Note that this archive’s own source-code analysis treats the v0.1 C++/header line count from the local primary source as approximately 19,901 lines, growing to 31,909 lines by v0.3.19. The 31,794 figure is therefore Forensicxs’s count for that article and not this archive’s reference value (the difference reflects which files / blank lines / comments / wxWidgets headers each count includes).

Key findings:

  • Code distribution: The wxWidgets GUI implementation accounted for approximately 18,000 lines (the largest single component). Blockchain operations, database management, networking, and scripting comprised the remaining ~13,000 lines.

  • Architecture: The analysis organized the codebase into the following categories:

    • Cryptography: Base58 address encoding, elliptic curve key management (secp256k1), SHA hashing
    • Blockchain: Transaction validation, block processing, difficulty adjustment (every 2,016 blocks), mining with initial reward of 50 BTC halving every 210,000 blocks
    • Networking: Peer-to-peer communication, IRC-based node discovery, message handling
    • Wallet: Transaction management, coin selection, balance calculations
    • Script system: A Forth-based stack language with opcodes for programmable transaction conditions
  • Technical parameters hardcoded in v0.1: Coinbase maturity of 100 blocks; difficulty adjustment constrained to 25%–400% range; 10-minute target block interval.

The line count of 31,794 is consistent with the “roughly 31,000 lines” described by Joshua Davis in The New Yorker’s October 2011 profile, which featured Dan Kaminsky’s analysis of the same codebase.