src/consensus/ directory is treated with extreme caution.grep is your friend.doc/developer-notes.md, doc/productivity.md, and CONTRIBUTING.libsecp256k1.
bitcoind & initsrc/bitcoind.cpp — The main daemon loop.src/init.cpp — Handling arguments, thread management, and sanity checks.src/kernel/chainparams.cpp — Hardcoded constants for Mainnet, Testnet, and Regtest.
genesis.hashMerkleRoot and nDefaultPort.CTransactionsrc/primitives/transaction.h
COutPoint: A reference to a specific output (TXID + Index).CTxIn: The “Input” containing the OutPoint and scriptSig.CTxOut: The “Output” containing the value (satoshis) and scriptPubKey.src/script/src/script/script.h — The stack-based, non-Turing complete engine.interpreter.cpp: The EvalScript function — the massive switch statement for Opcodes (OP_CHECKSIG, OP_DUP, etc.).src/serialize.h — The custom macros used to pack data for disk and wire.src/primitives/block.hnVersion, hashPrevBlock, hashMerkleRoot, nTime, nBits (difficulty), nNonce.src/consensus/merkle.cpp — How thousands of transactions are condensed into a single hash.src/pow.cpp
CheckProofOfWork(): The core validation.CalculateNextWorkRequired(): The 2,016-block adjustment logic (the “Difficulty Adjustment”).src/validation.cppAcceptToMemoryPool: Logic for entering the mempool.CheckBlock: Context-free checks (Is the block size okay? Is PoW valid?).ConnectBlock: Context-heavy (Do the inputs exist? Are signatures valid?).src/coins.hCCoinsViewCache: A high-performance, in-memory cache of the unspent outputs.DeploymentEnabled checks for new rules (like Taproot or SegWit).src/net.cppCNode object — representing a peer.SocketHandler, DNSAddressSeed, and OpenConnections.src/net_processing.cppProcessMessage(): The massive dispatcher.VERSION and VERACK exchange logic.src/txmempool.cppsrc/node/miner.cppBlockAssembler::CreateNewBlock: The algorithm that picks transactions from the mempool to build a candidate block.doc/developer-notes.md for contributing guidelines.git grep to follow variable names.| File Path | Role | Key Functions / Classes |
|---|---|---|
src/validation.cpp |
Most important file in the repo: block and transaction validation logic. | AcceptToMemoryPool(), CheckBlock(), ConnectBlock() |
src/net_processing.cpp |
Bridges the P2P network and the validation engine. Decides what to do with messages from peers. | ProcessMessage(), SendMessages() |
src/script/interpreter.cpp |
Executes the Bitcoin Script for every transaction input. | EvalScript(), VerifyScript() |
src/primitives/transaction.h |
Defines the basic structure of a transaction: inputs, outputs, and outpoints. | CTransaction, CTxIn, CTxOut |
src/primitives/block.h |
Defines the 80-byte block header and the full block structure. | CBlockHeader, CBlock |
src/coins.h |
Manages the UTXO set, specifically the in-memory cache. | CCoinsViewCache, Coin |
src/txmempool.cpp |
Manages transactions validated but not yet in a block. | CTxMemPool, addUnchecked() |
src/net.cpp |
Low-level P2P networking: sockets, connection limits, and bans. | CConnman, ThreadMessageHandler() |
src/node/miner.cpp |
Selecting transactions from the mempool to build a new block. | BlockAssembler, CreateNewBlock() |
src/init.cpp |
The Ignition. Startup sequence, background threads, and graceful shutdowns. | AppInitMain(), Shutdown() |
src/consensus/ is high-risk. Changes here can cause a hard fork. Everything else (like src/policy/) is technically optional for a node but recommended for network health.READWRITE(obj), you’re looking at Bitcoin’s custom serialization — how objects are turned into bytes for the disk or the wire.AcceptToMemoryPool in validation.cpp.src/pow.cpp, the Proof of Work boils down to a simple comparison of the block’s double-SHA256 hash against a target value derived from the “bits” field.