Exhaustive operator and developer reference for Bitcoin Core at commit
1aef4d5. Covers architecture, deployment, configuration, security hardening, operations, internals, and extension points. If you run a node in production, operate mining infrastructure, embed Bitcoin Core into services, or contribute to the codebase — this is your manual.
Table of Contents
- 1. Executive Summary
- 2. Architecture Overview
- 3. Component Inventory
- 4. System Requirements
- 5. Configuration Reference
- 6. Deployment
- 7. Operations
- 8. Security
- 9. Troubleshooting
- 10. Developer Internals
- 11. Quick Reference
1. Executive Summary
Bitcoin Core is the reference implementation of the Bitcoin protocol. It is a full-validating peer-to-peer node, consensus engine, descriptor-based wallet, JSON-RPC/REST API server, ZMQ event publisher, and optional Qt GUI — all in a single C++ codebase of approximately 2,918 source files and 14.8 million characters of code.
Key facts at this commit:
| Attribute | Value |
|---|---|
| Language | C++20 (core), Python (tests/tools), Rust (dev coverage tools) |
| Build system | CMake (minimum 3.22) |
| License | MIT |
| Supported platforms | Linux, macOS, Windows, FreeBSD, OpenBSD, NetBSD |
| Networks | mainnet, testnet3, testnet4, signet, regtest |
| Wallet backend | SQLite (descriptor wallets); legacy BDB wallets read-only/migration only |
| IPC | Cap'n Proto multiprocess (experimental, ENABLE_IPC) |
| Consensus constants | 21M BTC cap, 4 MW block weight, 100-block coinbase maturity |
Note
This guide is derived from direct source-code analysis. Written from the code at the stated commit. Where the code is the only authority, we say so explicitly.
2. Architecture Overview
2.1 Process Model
Bitcoin Core supports two process architectures:
Monolithic (default): A single process (bitcoind or bitcoin-qt) runs the node, wallet, and RPC server in one address space.
Multiprocess (experimental): With ENABLE_IPC=ON, separate executables communicate via Cap'n Proto over Unix sockets:
bitcoin-node ←──IPC──→ bitcoin-wallet
↑ ↑
└────────IPC─────────────┘
↕
bitcoin-gui
The multiprocess architecture is defined in src/init/:
| Executable | Init class | Provides |
|---|---|---|
bitcoind |
(monolithic) | Node + Wallet + RPC in one process |
bitcoin-qt |
BitcoinQtInit |
Monolithic with Qt GUI (no IPC) |
bitcoin-gui |
BitcoinGuiInit |
GUI front-end with IPC to bitcoin-node |
bitcoin-node |
BitcoinNodeInit |
Headless node with IPC server |
bitcoin-wallet |
(wallet init) | Wallet-only process via IPC |
bitcoin |
Wrapper | Subcommand dispatcher (gui, node, rpc) |
Each Init class implements interfaces::Init, which provides factory methods:
virtual std::unique_ptr<Node> makeNode();
virtual std::unique_ptr<Chain> makeChain();
virtual std::unique_ptr<Mining> makeMining();
virtual std::unique_ptr<WalletLoader> makeWalletLoader(Chain& chain);
virtual std::unique_ptr<Echo> makeEcho();
virtual std::unique_ptr<Rpc> makeRpc();
virtual Ipc* ipc();
2.2 Layered Architecture
┌─────────────────────────────────────────────────────┐
│ User Interfaces │
│ Qt GUI │ JSON-RPC │ REST │ ZMQ │
├─────────────────────────────────────────────────────┤
│ Interface Layer │
│ interfaces::Node │ Chain │ Mining │ Wallet │
├─────────────────────────────────────────────────────┤
│ Application Layer │
│ Wallet (src/wallet/) │ Mempool │ Fee Estimator │
├─────────────────────────────────────────────────────┤
│ Validation / Consensus │
│ ChainstateManager │ BlockManager │ UTXO Cache │
├─────────────────────────────────────────────────────┤
│ P2P Network Layer │
│ CConnman │ PeerManager │ AddrMan │
├─────────────────────────────────────────────────────┤
│ Storage Layer │
│ LevelDB (block index) │ Flat files (blocks) │
├─────────────────────────────────────────────────────┤
│ Cryptographic Primitives │
│ secp256k1 │ SHA-256 │ ctaes │ minisketch │
└─────────────────────────────────────────────────────┘
2.3 Data Flow
- Block reception: P2P layer receives block →
ChainstateManagervalidates against consensus rules →BlockManagerwrites to flat file + updates LevelDB index → UTXO set updated → wallet notified viaCValidationInterface - Transaction submission: RPC/wallet creates tx → mempool validates (policy + consensus) → relayed to peers via P2P inventory messages
- RPC request: HTTP server accepts connection →
CRPCTabledispatches to registeredRPCMethodhandler → handler accesses node state via locks → JSON response returned
3. Component Inventory
3.1 Core Libraries
| Component | Location | Files | Purpose |
|---|---|---|---|
| Consensus | src/consensus/ |
10 | Amount types, block weight/sigops limits, merkle trees, validation |
| Script | src/script/ |
22 | Script interpreter, descriptors, miniscript, signing |
| Primitives | src/primitives/ |
— | CBlock, CTransaction, CBlockHeader |
| Crypto | src/crypto/ |
36 | SHA-256, RIPEMD-160, AES-256-CBC, HMAC, siphash, HKDF |
| secp256k1 | src/secp256k1/ |
71 (src) | ECDSA, Schnorr, MuSig2, key recovery, ellswift |
| minisketch | src/minisketch/ |
— | Set reconciliation (Erlay protocol) |
| ctaes | src/crypto/ctaes/ |
— | Constant-time AES (bit-sliced, no lookup tables) |
3.2 Node Components
| Component | Location | Files | Purpose |
|---|---|---|---|
| Node core | src/node/ |
62 | Block storage, chain state, UTXO snapshots, fee estimation |
| Validation | src/ (validation.*) |
— | ChainstateManager, Chainstate, UTXO cache |
| P2P networking | src/ (net., net_processing.) |
— | Connection management, message handling, peer scoring |
| Mempool | src/ (txmempool.*) |
— | Transaction pool with fee-based eviction |
| Policy | src/policy/ |
14 | Fee rates, dust thresholds, RBF, ephemeral dust, package relay |
| RPC | src/rpc/ |
28 | JSON-RPC command registration and dispatch |
| Indexes | src/index/ |
— | Optional: txindex, blockfilterindex, coinstatsindex |
| ZMQ | src/zmq/ |
10 | Pub/sub notifications for blocks and transactions |
3.3 Wallet
| Component | Location | Files | Purpose |
|---|---|---|---|
| Wallet core | src/wallet/ |
43 | Descriptor wallets, coin selection, transaction building |
| Wallet RPC | src/wallet/rpc/ |
— | getbalance, sendtoaddress, listtransactions, etc. |
Important
Legacy BDB wallets are deprecated. New wallets use SQLite exclusively. Legacy wallets can be migrated via
migratewalletRPC. TheDEFAULT_WALLET_TX_VERSIONfollowsCTransaction::CURRENT_VERSION.
3.4 GUI
| Component | Location | Files | Purpose |
|---|---|---|---|
| Qt interface | src/qt/ |
121 | Full desktop GUI: send/receive, address book, console, traffic monitor |
3.5 Utility Binaries
| Binary | Purpose |
|---|---|
bitcoin-cli |
JSON-RPC client for interacting with a running node |
bitcoin-tx |
Offline transaction creation and manipulation |
bitcoin-util |
Key/address utilities |
3.6 Contrib Tools
| Tool | Location | Purpose |
|---|---|---|
| linearize | contrib/linearize/ |
Reconstruct a linear blockchain from block files |
| seeds | contrib/seeds/ |
Generate hard-coded seed node list |
| asmap | contrib/asmap/ |
AS-map utilities for bucketing peers by autonomous system |
| signet | contrib/signet/ |
Signet block signing/mining tools |
| verify-binaries | contrib/verify-binaries/ |
Verify release binary signatures |
| rpcauth | share/rpcauth/ |
Generate rpcauth credentials for bitcoin.conf |
| completions | contrib/completions/ |
Shell completions (bash, fish) |
| qos | contrib/qos/ |
Linux traffic control for bandwidth limiting |
| utxo-tools | contrib/utxo-tools/ |
UTXO set export to SQLite |
| guix | contrib/guix/ |
Deterministic/reproducible builds |
| tracing | contrib/tracing/ |
USDT/eBPF tracing scripts |
4. System Requirements
4.1 Hardware
| Resource | Minimum | Recommended | Notes |
|---|---|---|---|
| Disk (full node) | ~600 GB | 1 TB+ SSD | Blockchain grows ~70 GB/year |
| Disk (pruned) | 550 MiB min (-prune=550) |
2-10 GB | Minimum enforced by MIN_DISK_SPACE_FOR_BLOCK_FILES |
| RAM | 2 GB | 8 GB+ | UTXO cache (-dbcache) significantly impacts IBD speed |
| CPU | Any x86_64/ARM64 | Multi-core | SHA-256 hardware extensions (SHA-NI, ARMv8 crypto) help |
| Network | Broadband | Unmetered | IBD downloads ~600 GB; ongoing ~200 MB/day |
4.2 Software
| Dependency | Minimum Version | Purpose |
|---|---|---|
| CMake | 3.22 | Build system |
| C++ compiler | C++20 support | GCC 11+, Clang 16+, MSVC 2022+ |
| Boost | (multi-index) | Header-only data structures |
| libevent | 2.1+ | HTTP/RPC server event loop |
| SQLite | 3.38+ | Descriptor wallet storage |
| Qt | 5.15 / 6.x | GUI (optional, -DBUILD_GUI=ON) |
| ZeroMQ | 4.x | ZMQ notifications (optional, -DWITH_ZMQ=ON) |
| Cap'n Proto | 0.7+ (1.0+ recommended) | IPC multiprocess (optional, -DENABLE_IPC=ON) |
| BerkeleyDB | 4.8 | Legacy wallet support only (optional) |
| qrencode | — | QR code generation in GUI (optional) |
4.3 Build Presets
From CMakePresets.json:
| Preset | Purpose |
|---|---|
vs2026 |
Windows Visual Studio build |
libfuzzer |
Fuzz testing with libFuzzer |
dev-mode |
Developer mode with extra warnings/checks |
5. Configuration Reference
5.1 Configuration Files
Bitcoin Core reads configuration from these sources (highest priority first):
- Command-line arguments (
-option=value) settings.json(data directory, written by RPCsetban, wallet settings)bitcoin.conf(data directory, user-edited)
The config file location defaults to:
| OS | Path |
|---|---|
| Linux | ~/.bitcoin/bitcoin.conf |
| macOS | ~/Library/Application Support/Bitcoin/bitcoin.conf |
| Windows | %APPDATA%\Bitcoin\bitcoin.conf |
Section syntax for network-specific overrides:
# Global
server=1
[test]
rpcport=18332
[signet]
rpcport=38332
[regtest]
rpcport=18443
[testnet4]
rpcport=48332
Valid section names: main, test, signet, regtest, testnet4.
Negation syntax: Any boolean option can be negated with no prefix: -nowalletbroadcast, -nolisten. Double negation (-nofoo=0) is supported but discouraged.
5.2 Network Options
| Option | Default | Description |
|---|---|---|
-listen |
1 |
Accept incoming connections |
-port |
8333 (mainnet) |
P2P listen port |
-bind=<addr> |
All interfaces | Bind to specific address |
-externalip=<ip> |
— | Advertise this IP to peers |
-maxconnections |
125 |
Maximum total connections |
-maxuploadtarget=<MiB> |
0 (unlimited) |
Daily upload limit; pruned serving stops when reached |
-addnode=<ip> |
— | Add a persistent peer |
-connect=<ip> |
— | Connect ONLY to these peers |
-seednode=<ip> |
— | Connect to seed, then disconnect |
-dns |
1 |
Allow DNS lookups for -addnode and -seednode |
-dnsseed |
1 |
Use DNS seeds for initial peer discovery |
-onlynet=<net> |
All | Restrict to: ipv4, ipv6, onion, i2p, cjdns |
-proxy=<ip:port> |
— | SOCKS5 proxy for all connections |
-onion=<ip:port> |
— | Separate SOCKS5 proxy for Tor |
-i2psam=<ip:port> |
— | I2P SAM proxy address |
-torcontrol=<ip:port> |
127.0.0.1:9051 |
Tor control port for hidden service |
-torpassword=<pass> |
— | Tor control authentication |
-asmap=<file> |
— | AS-map file for peer bucketing (Erebus attack mitigation) |
-bantime |
86400 (24h) |
Default ban duration in seconds |
-whitelist=<spec> |
— | Whitelist peers (e.g., noban@192.168.1.0/24) |
5.3 RPC/REST Options
| Option | Default | Description |
|---|---|---|
-server |
0 (1 for bitcoind) |
Enable JSON-RPC server |
-rpcuser=<user> |
— | RPC username (deprecated; use -rpcauth) |
-rpcpassword=<pw> |
— | RPC password (deprecated; use -rpcauth) |
-rpcauth=<creds> |
— | Hashed credentials (user:salt$hash); generate with rpcauth.py |
-rpcport |
8332 (mainnet) |
RPC listen port |
-rpcbind=<addr> |
127.0.0.1 |
RPC bind address |
-rpcallowip=<subnet> |
127.0.0.1 |
Allow RPC from this subnet |
-rpccookiefile=<path> |
<datadir>/.cookie |
Cookie auth file path |
-rpcthreads |
4 |
Number of RPC worker threads |
-rest |
0 |
Enable unauthenticated REST interface |
-rpcservertimeout |
30 |
RPC server timeout in seconds |
Warning
Never expose
-rpcbindto untrusted networks without proper-rpcallowiprestrictions and strong-rpcauthcredentials. The RPC interface provides full node control including wallet access.
5.4 Wallet Options
| Option | Default | Description |
|---|---|---|
-wallet=<name> |
— | Load named wallet on startup |
-walletdir=<dir> |
<datadir>/wallets |
Wallet directory |
-disablewallet |
0 |
Disable wallet subsystem entirely |
-walletbroadcast |
1 |
Broadcast wallet transactions |
-walletrbf |
1 |
Enable opt-in RBF for new transactions |
-avoidpartialspends |
false |
Avoid partial spends (group outputs by address) |
-spendzeroconfchange |
1 |
Allow spending unconfirmed change |
-mintxfee=<amt> |
0.00001 |
Minimum fee rate (BTC/kvB) |
-maxtxfee=<amt> |
0.1 |
Maximum total fee |
-paytxfee=<amt> |
0 (auto) |
Target fee rate |
-txconfirmtarget=<n> |
6 |
Target confirmation blocks for fee estimation |
-fallbackfee=<amt> |
0 |
Fallback fee when estimation unavailable |
5.5 Block Storage & Pruning
| Option | Default | Description |
|---|---|---|
-datadir=<dir> |
OS-specific | Data directory |
-prune=<MiB> |
0 (no pruning) |
Prune block files to this size; 1 = manual pruning |
-blocksxor |
true |
XOR-obfuscate block files on disk |
-fastprune |
false |
Use smaller block files (testing only) |
-dbcache=<MiB> |
450 |
UTXO database cache size |
-txindex |
0 |
Maintain full transaction index |
-blockfilterindex |
— | Enable BIP 157 compact block filter index |
-coinstatsindex |
0 |
Enable coin statistics index |
-reindex |
0 |
Rebuild block index from block files |
-reindex-chainstate |
0 |
Rebuild chainstate from block data |
-assumevalid=<hash> |
Compiled default | Skip script validation before this block |
-checkblocks=<n> |
6 |
Blocks to verify on startup |
-checklevel=<n> |
3 |
Verification thoroughness (0-4) |
5.6 Mempool Options
| Option | Default | Description |
|---|---|---|
-maxmempool=<MiB> |
300 |
Maximum mempool size |
-mempoolexpiry=<hours> |
336 (14 days) |
Evict transactions older than this |
-minrelaytxfee=<amt> |
0.00001 |
Minimum relay fee rate (BTC/kvB) |
-dustrelayfee=<amt> |
0.00003 |
Dust threshold fee rate |
-bytespersigop |
20 |
Weight units per sigop |
-datacarrier |
1 |
Relay OP_RETURN transactions |
-datacarriersize |
83 |
Maximum OP_RETURN data size |
-permitbaremultisig |
1 |
Relay bare multisig |
-acceptnonstdtxn |
0 (mainnet) |
Accept non-standard transactions |
-maxorphantx |
100 |
Maximum orphan transactions in memory |
-incrementalrelayfee |
0.00001 |
Minimum fee bump for RBF |
5.7 Mining Options
| Option | Default | Description |
|---|---|---|
-blockmaxweight=<n> |
3996000 |
Maximum block weight to mine |
-blockmintxfee=<amt> |
0.00001 |
Minimum fee rate for inclusion |
5.8 ZMQ Options
| Option | Default | Description |
|---|---|---|
-zmqpubhashtx=<addr> |
— | Publish transaction hashes |
-zmqpubhashblock=<addr> |
— | Publish block hashes |
-zmqpubrawtx=<addr> |
— | Publish raw transactions |
-zmqpubrawblock=<addr> |
— | Publish raw blocks |
-zmqpubsequence=<addr> |
— | Publish mempool sequence numbers |
-zmqpubhashblockhwm=<n> |
1000 |
High-water mark (send queue depth) |
5.9 Debug & Logging
| Option | Default | Description |
|---|---|---|
-debug=<category> |
— | Enable debug logging for category |
-debuglogfile=<file> |
debug.log |
Log file path; empty = no file logging |
-loglevel=<level> |
info |
Log level: trace, debug, info, warning, error |
-logtimestamps |
1 |
Prefix log entries with timestamps |
-logthreadnames |
0 |
Log thread names |
-logsourcelocations |
0 |
Log source file and line |
-shrinkdebugfile |
1 |
Shrink debug.log on startup |
-printtoconsole |
0 |
Print to stdout instead of log file |
5.10 Consensus/Network Selection
| Option | Description |
|---|---|
-chain=<name> |
Select chain: main, test, signet, regtest, testnet4 |
-testnet |
Shorthand for -chain=test |
-testnet4 |
Shorthand for -chain=testnet4 |
-signet |
Shorthand for -chain=signet |
-regtest |
Shorthand for -chain=regtest |
-signetchallenge=<hex> |
Custom signet challenge script |
-signetseednode=<host> |
Custom signet seed node |
6. Deployment
6.1 Building from Source
# Clone
git clone https://github.com/bitcoin/bitcoin.git
cd bitcoin
# Configure
cmake -B build -DCMAKE_BUILD_TYPE=Release
# Optional features
cmake -B build \
-DBUILD_GUI=ON \
-DWITH_ZMQ=ON \
-DENABLE_IPC=OFF \
-DWITH_SQLITE=ON
# Build
cmake --build build -j$(nproc)
# Install
cmake --install build
Windows (MSVC):
cmake --preset vs2026
cmake --build build --config Release
vcpkg dependencies (from vcpkg.json):
boost-multi-indexlibevent- Optional features:
qt,tests,wallet,zeromq,qrencode
6.2 Reproducible Builds
Bitcoin Core uses Guix for deterministic, reproducible builds:
contrib/guix/guix-build
contrib/guix/guix-attest
contrib/guix/guix-verify
6.3 Init System Integration
Example systemd unit (doc/init.md conventions):
[Unit]
Description=Bitcoin Core Daemon
After=network-online.target
Wants=network-online.target
[Service]
Type=forking
ExecStart=/usr/local/bin/bitcoind -daemon -conf=/etc/bitcoin/bitcoin.conf -datadir=/var/lib/bitcoind
ExecStop=/usr/local/bin/bitcoin-cli stop
User=bitcoin
Group=bitcoin
RuntimeDirectory=bitcoind
StateDirectory=bitcoind
# Hardening
PrivateTmp=true
ProtectSystem=full
NoNewPrivileges=true
MemoryDenyWriteExecute=true
[Install]
WantedBy=multi-user.target
6.4 Docker
Note
Bitcoin Core does not ship an official Docker image. When containerizing, ensure the data directory is on a persistent volume and the container runs as a non-root user.
6.5 Tor Hidden Service
# bitcoin.conf
proxy=127.0.0.1:9050
listen=1
bind=127.0.0.1
onlynet=onion
torcontrol=127.0.0.1:9051
torpassword=<your_hashed_password>
Bitcoin Core will automatically create a v3 Tor hidden service when torcontrol is configured.
6.6 I2P
# bitcoin.conf
i2psam=127.0.0.1:7656
Requires a running I2P SAM bridge. Bitcoin Core creates a persistent I2P destination stored in <datadir>/i2p_private_key.
6.7 CJDNS
# bitcoin.conf
cjdnsreachable=1
Requires the host to have a CJDNS interface configured. Peers with fc00::/8 addresses will be treated as CJDNS.
7. Operations
7.1 Initial Block Download (IBD)
IBD downloads and validates the entire blockchain history. Optimization strategies:
| Technique | Setting | Impact |
|---|---|---|
| Increase UTXO cache | -dbcache=4096 |
Major IBD speedup (uses RAM for UTXO lookups) |
| Use assumevalid | Default (on) | Skips script validation before a known-good block |
| Use assumeutxo snapshot | loadtxoutset RPC |
Jump-start with a UTXO snapshot, validate in background |
| Disable wallet | -disablewallet |
Avoids wallet scan overhead during IBD |
| Direct peer | -connect=<fast_peer> |
Avoid slow seed discovery |
Tip
Setting
-dbcacheto half your available RAM during IBD can reduce sync time from days to hours. Reduce it after sync completes.
7.2 Pruning
Automatic pruning: -prune=<MiB> (minimum 550 MiB). Old block files are deleted when total exceeds the target.
Manual pruning: -prune=1. Use pruneblockchain <height> RPC to prune on demand.
Caution
Pruned nodes cannot serve historical blocks to peers, cannot run
-txindex, and cannot rescan the wallet for transactions before the pruned height. Backup wallet files before enabling pruning.
7.3 UTXO Snapshots (AssumeUTXO)
# On a fully-synced node: create snapshot
bitcoin-cli dumptxoutset /path/to/utxo.dat
# On a new node: load snapshot to start immediately
bitcoin-cli loadtxoutset /path/to/utxo.dat
The node begins operating from the snapshot height immediately while validating the full history in the background. Once background validation completes, the snapshot chainstate is promoted.
7.4 Backup & Recovery
Critical files to back up:
| File/Directory | Contains |
|---|---|
wallets/ |
Wallet databases (descriptor wallets) |
bitcoin.conf |
Node configuration |
settings.json |
Runtime settings (bans, wallet config) |
peers.dat |
Known peer addresses |
banlist.json |
Ban list |
anchors.dat |
Block-relay-only peer anchors (written on shutdown) |
Wallet backup:
bitcoin-cli backupwallet /path/to/backup.dat
Warning
Descriptor wallets derive keys from descriptors, so a backup taken at wallet creation time covers all future addresses. However, labels and metadata added later require fresh backups.
7.5 Monitoring
RPC health checks:
# Node status
bitcoin-cli getblockchaininfo
bitcoin-cli getnetworkinfo
bitcoin-cli getpeerinfo
# Mempool
bitcoin-cli getmempoolinfo
# Uptime and RPC info
bitcoin-cli uptime
bitcoin-cli getrpcinfo
ZMQ streaming for real-time monitoring:
# Subscribe to new blocks
zmqsub tcp://127.0.0.1:28332 hashblock
# Subscribe to new transactions
zmqsub tcp://127.0.0.1:28332 hashtx
Log categories for targeted debug output:
net, tor, mempool, http, bench, zmq, walletdb, rpc, estimatefee,
addrman, selectcoins, reindex, cmpctblock, rand, prune, proxy,
mempoolrej, libevent, coindb, qt, leveldb, validation, i2p, ipc,
lock, blockstorage, txreconciliation, scan, txpackages
7.6 Performance Tuning
| Goal | Settings |
|---|---|
| Minimize memory | -dbcache=100 -maxmempool=50 -maxconnections=20 |
| Maximize IBD speed | -dbcache=4096 -maxconnections=10 -disablewallet |
| Low-bandwidth relay | -maxuploadtarget=1024 -blocksonly |
| Block relay only | -blocksonly (no mempool relay, saves bandwidth) |
7.7 RPC Interface
Authentication methods (choose one):
- Cookie auth (default): Auto-generated
.cookiefile in data directory rpcauth: Generate withshare/rpcauth/rpcauth.py:
python3 share/rpcauth/rpcauth.py myuser
# Output: rpcauth=myuser:salt$hash
# Add to bitcoin.conf
RPC command categories (from src/rpc/):
| Category | Key Commands |
|---|---|
| Blockchain | getblockchaininfo, getblock, getblockcount, getbestblockhash, gettxout, verifychain |
| Mining | getblocktemplate, submitblock, getmininginfo, generateblock (regtest) |
| Mempool | getmempoolinfo, getrawmempool, getmempoolentry, testmempoolaccept, submitpackage |
| Network | getnetworkinfo, getpeerinfo, addnode, disconnectnode, setban, getaddednodeinfo |
| Wallet | getbalance, sendtoaddress, getnewaddress, listtransactions, createwallet, migratewallet |
| Raw tx | createrawtransaction, signrawtransactionwithkey, sendrawtransaction, decodepsbt |
| Util | validateaddress, createmultisig, deriveaddresses, getdescriptorinfo |
| Control | help, stop, uptime, getrpcinfo, logging |
7.8 REST Interface
When -rest=1:
| Endpoint | Description |
|---|---|
GET /rest/block/<hash>.json |
Block data |
GET /rest/tx/<txid>.json |
Transaction data |
GET /rest/headers/<count>/<hash>.json |
Block headers |
GET /rest/chaininfo.json |
Blockchain info |
GET /rest/mempool/info.json |
Mempool info |
GET /rest/mempool/contents.json |
Mempool contents |
GET /rest/blockhashbyheight/<height>.json |
Block hash by height |
Formats: .json, .bin, .hex
8. Security
8.1 Threat Model
Bitcoin Core operates in an adversarial environment where peers may be malicious. The security architecture defends against:
- Consensus attacks: Every block and transaction is fully validated against consensus rules
- Eclipse attacks: Diversified peer selection via AddrMan bucketing, AS-map support (
-asmap) - Sybil attacks: Connection limits, peer scoring, eviction logic
- DoS attacks: Resource limits (mempool size, orphan limits, ban scoring), rate limiting
- Timing attacks: Constant-time cryptographic operations (ctaes, secp256k1)
8.2 Cryptographic Security
| Algorithm | Implementation | Properties |
|---|---|---|
| ECDSA/Schnorr (secp256k1) | Embedded libsecp256k1 |
Constant-time, no data-dependent branches, formally verified field arithmetic |
| AES-256-CBC | Embedded ctaes |
Constant-time bit-sliced (no lookup tables), ~15 MB/s |
| SHA-256d | src/crypto/sha256.* |
Hardware-accelerated (SHA-NI, ARMv8), auto-detected at runtime |
| HMAC-SHA-512 | src/crypto/hmac_sha512.* |
Used for BIP 32 key derivation |
| SipHash | src/crypto/siphash.* |
Hash table collision resistance |
8.3 Wallet Security
- Encryption: Wallet database encrypted with AES-256-CBC; master key derived from passphrase via key stretching
- Key derivation: BIP 32/44/49/84/86 hierarchical deterministic derivation from descriptors
- Address types: Legacy (P2PKH), P2SH-SegWit (P2SH-P2WPKH), Native SegWit (P2WPKH), Taproot (P2TR)
- Signing: Supports PSBT (BIP 174/370) for offline/multisig signing workflows
- Coin control:
CCoinControlallows manual UTXO selection with input weight, sequence, and script overrides
8.4 Network Security
- RPC: Bind to localhost by default; cookie auth or hashed password auth
- P2P: No authentication (public network); peer reputation via misbehavior scoring
- Block storage XOR: Blocks are XOR-obfuscated on disk (
-blocksxor=truedefault) to prevent antivirus false positives; this is NOT encryption - Ban list:
banlist.jsonpersists bans across restarts
Caution
The XOR obfuscation of block files (
-blocksxor) is not a security feature. It exists solely to prevent antivirus software from flagging block data that coincidentally matches malware signatures. Do not rely on it for data confidentiality.
8.5 Hardening Checklist
- [ ] Run as dedicated non-root user
- [ ] Use
-rpcauthinstead of-rpcuser/-rpcpassword - [ ] Keep
-rpcbind=127.0.0.1unless remote access is required - [ ] Set
-rpcallowipto restrict RPC access by subnet - [ ] Use Tor/I2P to hide node IP from peers
- [ ] Enable
-asmapfor eclipse attack resistance - [ ] Use systemd hardening directives (
PrivateTmp,ProtectSystem,NoNewPrivileges,MemoryDenyWriteExecute) - [ ] Encrypt wallet with
encryptwalletRPC - [ ] Back up wallet before any upgrade or migration
- [ ] Monitor
debug.logforWARNINGandERRORentries
9. Troubleshooting
9.1 Startup Issues
| Symptom | Cause | Fix |
|---|---|---|
| "Error: Cannot obtain a lock on data directory" | Another instance running | Stop existing bitcoind or check for stale .lock file |
| "Error: Invalid network magic number" | Corrupted peers.dat |
Delete peers.dat; recreated automatically |
| "Invalid or corrupt peers.dat" | Version mismatch or corruption | Rename/delete peers.dat, restart |
| "Prune configured below the minimum of 550 MiB" | -prune=<N> too small |
Use -prune=550 or higher |
| "Prune cannot be configured with a negative value" | Negative -prune |
Use positive value or 0 (disable) |
| "Negating of -X is meaningless" | Option doesn't support negation | Remove no prefix; check option docs |
| Slow startup | Large debug.log, large UTXO set |
-shrinkdebugfile=1, increase -dbcache |
9.2 Sync Issues
| Symptom | Cause | Fix |
|---|---|---|
| Sync stalls at specific height | Bad peer, disk full | Check disk space; try -connect=<known_good_peer> |
| "Block validation failed" | Data corruption | -reindex to rebuild from block files |
| Extremely slow IBD | Low -dbcache |
Increase -dbcache to 2048+ during IBD |
| Memory exhaustion during IBD | -dbcache too high |
Reduce -dbcache to fit available RAM |
9.3 Wallet Issues
| Symptom | Cause | Fix |
|---|---|---|
| "Wallet file verification failed" | Corrupt wallet DB | Restore from backup |
| Missing transactions | Wallet created after transactions | rescanblockchain RPC |
| "Fee estimation disabled" | Node recently started, no data | Wait for blocks or set -fallbackfee |
| Legacy wallet warnings | Using deprecated BDB wallet | migratewallet to convert to descriptor wallet |
9.4 Network Issues
| Symptom | Cause | Fix |
|---|---|---|
| 0 connections | Firewall blocking port 8333 | Open port 8333 (TCP) or use -port=<alt> |
| Only outbound connections | NAT/firewall | Port-forward 8333 or use UPnP/NAT-PMP |
| Tor connection failures | SOCKS5 proxy not running | Verify Tor is running on configured port |
| "Banned" peers | Misbehavior threshold exceeded | setban <ip> remove to unban |
9.5 RPC Issues
| Symptom | Cause | Fix |
|---|---|---|
| "Could not connect to the server" | RPC server not running | Add server=1 to bitcoin.conf |
| "Unauthorized" (401) | Wrong credentials | Check cookie file permissions or -rpcauth value |
| Timeout on large queries | Default 30s timeout | Increase -rpcservertimeout or paginate queries |
10. Developer Internals
10.1 Repository Structure
bitcoin/
├── cmake/ CMake modules and scripts
│ ├── module/ Feature detection modules
│ └── script/ Build helper scripts
├── contrib/ Tools, scripts, packaging
│ ├── completions/ Shell completions (bash, fish)
│ ├── devtools/ Developer tools (clang-tidy, coverage)
│ ├── guix/ Deterministic build infrastructure
│ ├── linearize/ Blockchain linearization
│ ├── seeds/ Seed node list generation
│ ├── signet/ Signet tools
│ ├── tracing/ USDT/eBPF tracing scripts
│ └── verify-binaries/ Release verification
├── doc/ Documentation
│ ├── design/ Internal design documents
│ ├── man/ Man pages
│ ├── policy/ Transaction relay policy docs
│ └── release-notes/ Per-version release notes
├── share/ Shared resources
│ ├── examples/ Example bitcoin.conf
│ ├── qt/ Qt resources
│ └── rpcauth/ RPC authentication helper
├── src/ All C++ source code
│ ├── bench/ Benchmarks
│ ├── common/ Shared utilities (args, settings)
│ ├── compat/ Platform compatibility
│ ├── consensus/ Consensus-critical code
│ ├── crypto/ Cryptographic primitives
│ ├── index/ Optional indexes
│ ├── init/ Process initialization (per-binary)
│ ├── interfaces/ Abstract interfaces (IPC boundary)
│ ├── ipc/ IPC infrastructure (Cap'n Proto)
│ ├── kernel/ Consensus kernel library
│ ├── logging/ Logging infrastructure
│ ├── node/ Node-specific logic
│ ├── policy/ Transaction relay policy
│ ├── primitives/ Core data types (block, tx)
│ ├── qt/ Qt GUI
│ ├── rpc/ JSON-RPC handlers
│ ├── script/ Script engine, descriptors
│ ├── secp256k1/ Embedded libsecp256k1
│ ├── support/ Allocators, cleanse
│ ├── test/ Unit tests
│ ├── util/ General utilities
│ ├── wallet/ Wallet implementation
│ └── zmq/ ZMQ notification publisher
└── test/
├── functional/ Python functional tests (268 files)
├── fuzz/ Fuzz test corpus/seeds
└── lint/ Linting tools (Rust)
10.2 Module Reference
Consensus (src/consensus/)
The consensus module defines Bitcoin's protocol constants:
static constexpr CAmount COIN = 100'000'000; // satoshis per BTC
static constexpr CAmount MAX_MONEY = 21'000'000 * COIN; // 2.1 quadrillion sats
static const unsigned int MAX_BLOCK_WEIGHT = 4'000'000; // 4 MW (BIP 141)
static const unsigned int MAX_BLOCK_SERIALIZED_SIZE = 4'000'000;
static const int64_t MAX_BLOCK_SIGOPS_COST = 80'000;
static const int COINBASE_MATURITY = 100;
static const int WITNESS_SCALE_FACTOR = 4;
static constexpr int64_t MAX_TIMEWARP = 600; // BIP 94
Important
MAX_MONEYis a sanity check, not the actual supply. The actual circulating supply is less than 21M BTC due to provably lost coins and rounding in subsidy halvings.
Block Storage (src/node/blockstorage.cpp)
Blocks are stored in flat files (blk?????.dat) with undo data in rev?????.dat. The block index lives in LevelDB with these key prefixes:
| Key | Code | Purpose |
|---|---|---|
'b' + block_hash |
DB_BLOCK_INDEX |
Block metadata (height, file position, status) |
'f' + file_number |
DB_BLOCK_FILES |
Block file info (block count, size, height range) |
'l' |
DB_LAST_BLOCK |
Last block file number |
'F' + flag_name |
DB_FLAG |
Boolean flags |
'R' |
DB_REINDEX_FLAG |
Reindex in progress |
Block comparison for chain selection uses CBlockIndexWorkComparator: most total work first, then earliest sequence ID.
Mempool Policy (src/policy/)
The policy layer enforces standardness rules stricter than consensus:
- Fee rates:
CFeeRatetracks fees per virtual byte (sat/vB), internally stored asFeePerVSize - Dust: Outputs below the dust threshold (based on
-dustrelayfee) are non-standard - Ephemeral dust (new): Zero-fee transactions may create dust outputs, but a child transaction must spend ALL dust outputs from its parent. Enforced by
PreCheckEphemeralTx()andCheckEphemeralSpends() - RBF: BIP 125 opt-in replace-by-fee with incremental fee requirements
- Package relay: CPFP and package RBF for mempool submissions (
submitpackageRPC)
Serialization
Bitcoin Core uses a custom serialization framework (src/serialize.h) with:
- Network-specific magic bytes for message framing
- Hash-verified serialization (
HashedSourceWriter/HashVerifier) for data integrity - Atomic file writes via temp file + rename pattern (
SerializeFileDB) - Version-aware deserialization for backward compatibility
Address Manager (src/addrdb.*, src/addrman.*)
- Peers stored in
peers.datwith network-magic-prefixed serialization and checksum verification AddrManuses bucketed storage with configurable consistency checks (-checkaddrman)anchors.datstores block-relay-only peer addresses on shutdown for eclipse attack resistance- Ban list stored in
banlist.json(JSON format, migrated frombanlist.datin v22)
10.3 Code Patterns
Locking
Bitcoin Core uses annotated mutexes with Clang thread-safety analysis:
LOCK(cs_main); // Acquire lock
LOCK2(cs_main, cs_wallet); // Acquire two locks
AssertLockHeld(cs_main); // Assert lock is held
AssertLockNotHeld(cs_main); // Assert lock is NOT held (perf)
EXCLUSIVE_LOCKS_REQUIRED(::cs_main); // Function annotation
WITH_LOCK(cs_main, return active_chain.Height()); // Inline lock
Error Handling
// Result type for fallible operations
util::Result<std::unique_ptr<AddrMan>> LoadAddrman(...);
// Bilingual strings for user-facing errors
return util::Error{strprintf(_("message %s"), arg)};
// RPC errors
throw JSONRPCError(RPC_INVALID_PARAMETER, "message");
RPC Registration
Commands are registered as RPCMethod objects:
static RPCMethod getblockcount()
{
return RPCMethod{
"getblockcount",
"Returns the height of the most-work fully-validated chain.\n",
{}, // Parameters
RPCResult{...}, // Result type
RPCExamples{...}, // CLI/RPC examples
[](const RPCMethod& self, const JSONRPCRequest& request) -> UniValue {
// Handler body
},
};
}
Interface Pattern
The interfaces:: namespace defines abstract boundaries between components:
class Init {
virtual std::unique_ptr<Node> makeNode();
virtual std::unique_ptr<Chain> makeChain();
virtual std::unique_ptr<Mining> makeMining();
virtual std::unique_ptr<WalletLoader> makeWalletLoader(Chain& chain);
virtual std::unique_ptr<Echo> makeEcho();
virtual std::unique_ptr<Rpc> makeRpc();
virtual Ipc* ipc();
};
This enables the multiprocess architecture: each binary implements the interfaces it provides and consumes the rest via IPC.
10.4 Testing Strategy
| Test Type | Location | Count | Framework |
|---|---|---|---|
| Unit tests | src/test/ |
~hundreds | Boost.Test |
| Functional tests | test/functional/ |
268 files | Python (custom TestFramework) |
| Fuzz tests | src/test/fuzz/ |
~hundreds | libFuzzer / AFL |
| Benchmarks | src/bench/ |
— | nanobench |
| Linting | test/lint/ |
— | Rust-based lint runner |
| Wallet tests | src/wallet/test/ |
— | Boost.Test |
| Qt tests | src/qt/test/ |
— | Qt Test |
Running tests:
# Unit tests
cmake --build build --target test_bitcoin && ./build/src/test/test_bitcoin
# Functional tests
python3 test/functional/test_runner.py
# Specific functional test
python3 test/functional/wallet_basic.py
# Fuzz tests (requires libfuzzer preset)
cmake --preset libfuzzer
cmake --build build_fuzz
FUZZ=process_message ./build_fuzz/src/test/fuzz/fuzz
Functional test framework (test/functional/test_framework/):
BitcoinTestFramework: Base class for all functional tests- Manages multiple
bitcoindnodes in regtest mode - Provides helpers for mining, wallet operations, P2P message construction
- Supports mock time, custom network topologies, crash recovery testing
10.5 Contributing
Code standards:
- C++20 with
-Wall -Wextraequivalent warnings - Custom clang-tidy checks (
contrib/devtools/bitcoin-tidy/): nontrivial thread-local validation - IWYU (Include What You Use) enforcement
- Python functional tests follow PEP 8
- All changes require review before merge
Deterministic testing tools:
contrib/devtools/deterministic-unittest-coverage/(Rust): Ensures deterministic unit test execution for reproducible coveragecontrib/devtools/deterministic-fuzz-coverage/(Rust): Same for fuzz corpus
Static analysis annotations:
CHECK_NONFATAL(): Assertion that throws instead of aborting (for recoverable invariant violations)Assume(): Weaker assertion for optimizer hints (debug-only check)NONFATAL_UNREACHABLE(): Marks unreachable code paths
11. Quick Reference
11.1 Port Numbers
| Network | P2P | RPC | Default data directory |
|---|---|---|---|
| mainnet | 8333 | 8332 | ~/.bitcoin/ |
| testnet3 | 18333 | 18332 | ~/.bitcoin/testnet3/ |
| testnet4 | 48333 | 48332 | ~/.bitcoin/testnet4/ |
| signet | 38333 | 38332 | ~/.bitcoin/signet/ |
| regtest | 18444 | 18443 | ~/.bitcoin/regtest/ |
11.2 Data Directory Layout
<datadir>/
├── bitcoin.conf Configuration file
├── settings.json Runtime settings
├── debug.log Log file
├── .cookie RPC cookie auth
├── peers.dat Known peer addresses
├── banlist.json Banned peers
├── anchors.dat Block-relay-only anchors
├── fee_estimates.dat Fee estimator state
├── mempool.dat Mempool persistence
├── blocks/
│ ├── blk?????.dat Raw block data
│ ├── rev?????.dat Undo data
│ └── index/ LevelDB block index
├── chainstate/ LevelDB UTXO set
├── indexes/
│ ├── txindex/ Transaction index (if -txindex)
│ ├── blockfilter/ Block filter index
│ └── coinstatsindex/ Coin stats index
└── wallets/
└── <wallet_name>/ SQLite wallet files
11.3 Key RPC Quick Reference
# Node info
bitcoin-cli getblockchaininfo
bitcoin-cli getnetworkinfo
bitcoin-cli getpeerinfo
# Block operations
bitcoin-cli getblock $(bitcoin-cli getbestblockhash) 2
bitcoin-cli getblockcount
# Mempool
bitcoin-cli getmempoolinfo
bitcoin-cli getrawmempool true
# Wallet
bitcoin-cli createwallet "mywallet"
bitcoin-cli -rpcwallet=mywallet getnewaddress "" bech32m
bitcoin-cli -rpcwallet=mywallet getbalance
bitcoin-cli -rpcwallet=mywallet sendtoaddress <addr> <amount>
# Transaction
bitcoin-cli getrawtransaction <txid> true
bitcoin-cli testmempoolaccept '["<hex>"]'
# Maintenance
bitcoin-cli stop
bitcoin-cli logging '["net","mempool"]'
11.4 Consensus Constants Quick Reference
| Constant | Value | Defined in |
|---|---|---|
COIN |
100,000,000 sat | consensus/amount.h |
MAX_MONEY |
2,100,000,000,000,000 sat | consensus/amount.h |
MAX_BLOCK_WEIGHT |
4,000,000 WU | consensus/consensus.h |
MAX_BLOCK_SERIALIZED_SIZE |
4,000,000 bytes | consensus/consensus.h |
MAX_BLOCK_SIGOPS_COST |
80,000 | consensus/consensus.h |
COINBASE_MATURITY |
100 blocks | consensus/consensus.h |
WITNESS_SCALE_FACTOR |
4 | consensus/consensus.h |
MAX_TIMEWARP |
600 seconds | consensus/consensus.h |
MIN_TRANSACTION_WEIGHT |
240 WU | consensus/consensus.h |
Note
Negative knowledge — what does NOT exist in the code at this commit:
- No built-in mining pool or stratum server implementation
- No built-in block explorer or web interface
- No official Docker image or Kubernetes manifests
- No gRPC interface (only JSON-RPC, REST, ZMQ)
- No native TLS/SSL for RPC (use a reverse proxy for remote access)
- No automatic wallet backup scheduling
- No built-in transaction fee prediction API beyond fee estimation RPC
- No Lightning Network or Layer 2 protocol support (separate projects)
- No GUI-only configuration options — all GUI settings map to CLI flags
- No Prometheus/metrics endpoint (monitor via RPC polling or ZMQ)