The whole codebase on one screen
Each tile is a source file, sized by line count. Almost half is the Windows interface. The ideas that matter fit in two files.
A coin is a chain of signatures
There are no balances in the code. A CTransaction spends earlier outputs (vin) and creates new ones (vout). Each input points back at one output by its transaction hash and index: a COutPoint.
Hover any input to see the output it spends.
The genesis block, rebuilt byte by byte
A block's identity is the hash of just its 80-byte header. The page below rebuilds block 0 from the values hard-coded in main.cpp and hashes it with SHA-256 twice, as CBlock::GetHash() does.
The first transaction in a block (the coinbase) has no real input, so its scriptSig can hold anything. Satoshi put a newspaper headline there, which proves the block was not mined before 3 January 2009.
Edit it and watch the change ripple up into the block hash.
Mining is guessing a number
BitcoinMiner() hashes the header, checks the result against a target, adds one to nNonce, and repeats. The first hash at or below the target wins the block. Your browser is running that loop below.
One hash that commits to every transaction
BuildMerkleTree() hashes transactions in pairs, then pairs of pairs, until one hash is left: the Merkle root in the header. Change any transaction and the root changes, so the proof of work changes too.
Click a transaction to tamper with it. Red marks every hash that changes. With an odd count the last hash is paired with itself (dashed), which is what min(i+1, nSize-1) does.
Script: a tiny stack machine guards every coin
An output doesn't name an owner. It holds a small program, scriptPubKey. To spend it you supply scriptSig, and VerifySignature() runs the two joined together. If the stack ends with true, the spend is valid.
Ten minutes, enforced by arithmetic
Every 2,016 blocks, GetNextWorkRequired() checks how long those blocks actually took and scales the target so the next 2,016 take two weeks. One adjustment is capped at 4× either way.
The halving is one bit-shift
The four-year cycle on the dashboard starts here. The block reward is 50 coins shifted right by one bit for every 210,000 blocks mined. That one line caps supply just under 21 million.
When two miners disagree, the longer chain wins
Two blocks can be found at nearly the same time, splitting the network. AddToBlockIndex() settles it: when a block arrives that makes a branch longer than the current best, the node switches to that branch with Reorganize().
In v0.1 "longer" means more blocks (nHeight). Later versions compare total work instead, so a branch of easier blocks can't win just by being longer.