Bitcoin Core Internals
Bitcoin Core is the reference implementation of the Bitcoin protocol. Understanding its internals is the foundation of protocol development.
Overview
Bitcoin Core is a C++ application that has evolved since Satoshi's original codebase. Over the years, it has been significantly refactored for modularity, security, and performance. The project maintains extremely high standards for code quality — changes are reviewed by multiple experienced developers before merging.
Key Subsystems
| Subsystem | Responsibility | Key Files |
|---|---|---|
| Validation | Block and transaction validation | src/validation.cpp |
| Net/Net Processing | P2P networking and message handling | src/net.cpp, src/net_processing.cpp |
| Wallet | Key management, coin selection, signing | src/wallet/ |
| Mempool | Unconfirmed transaction management | src/txmempool.cpp |
| RPC/REST | External API interfaces | src/rpc/ |
| Script | Script interpreter and verification | src/script/ |
| Consensus | Consensus-critical code | src/consensus/ |
| Index | Optional indexes (txindex, blockfilter) | src/index/ |
How It All Fits Together
When a new block arrives:
- Net receives the block from a peer
- Net Processing deserializes and routes it
- Validation checks proof-of-work, transactions, and consensus rules
- UTXO Set (chainstate) is updated
- Mempool removes confirmed transactions
- Wallet scans for relevant transactions
- Indexes are updated if enabled
Getting Started
# Clone the repository
git clone https://github.com/bitcoin/bitcoin.git
cd bitcoin
# Read the build instructions
cat doc/build-unix.md # or doc/build-osx.md
# Build
cmake -B build
cmake --build build
# Run tests
ctest --test-dir build
Topics in This Section
- Code Architecture — Source tree layout, build system, module boundaries
- Consensus — Consensus rules, validation logic, soft fork activation