The Scenario
Alice wants to send 0.05 BTC to Bob. She opens her Bitcoin Core wallet, enters Bob's address (bc1q...), sets the amount, and clicks Send. Here's everything that happens under the hood.
Each step below references the chapter where that concept is covered in depth. This chapter assumes you've read the preceding chapters; it's the grand finale that connects everything.
Step 1: Creating the Transaction
Covered in Chapter 9: The Wallet
When Alice clicks Send, the wallet's CreateTransaction function takes over:
- Decode Bob's address: The
bc1q...address is decoded (Bech32) into a scriptPubKey:OP_0 <20-byte-hash>, a P2WPKH output (Chapter 5). - Find Alice's coins: the wallet scans its tracked UTXOs. Alice has three: 0.02 BTC, 0.04 BTC, and 0.1 BTC.
- Run coin selection: Branch and Bound, CoinGrinder, Knapsack, and SRD all run. BnB can't find an exact match, so the wallet chooses the 0.02 + 0.04 = 0.06 BTC combination (two inputs).
- Build outputs: Two outputs are created:
- 0.05 BTC → Bob's scriptPubKey
- 0.0099 BTC → Alice's change address (a fresh address from her key pool)
- Calculate fee: with two P2WPKH inputs and two outputs, the estimated virtual size is ~208 vbytes. At ~48 sat/vB, the fee is ~10,000 sats (0.0001 BTC). The math: 0.06 − 0.05 − 0.0001 = 0.0099 change.
Step 2: Signing
Covered in Chapter 3: Cryptography and Chapter 4: Script
For each of Alice's two inputs:
- Compute the sighash: hash the transaction with BIP 143 (SegWit) serialization, committing to the input being signed, all outputs, and the spent amount.
- Sign with ECDSA: use the private key corresponding to the input's scriptPubKey. The result is a DER-encoded signature + SIGHASH_ALL byte.
- Place in witness: since these are P2WPKH inputs, the signature and public key go into the witness field (not scriptSig).
Step 3: Submitting to the Node
Covered in Chapter 6: Validation & Mempool
The signed transaction is submitted via the sendrawtransaction RPC (or internally from the wallet). It's serialized into raw bytes and passed to the validation layer - the exact same path that peer-received transactions take.
Step 4: Mempool Validation
Covered in Chapter 6
AcceptToMemoryPool runs the full gauntlet of checks:
Step 5: Relay Across the Network
Covered in Chapter 8: P2P Networking
Once in Alice's mempool, the transaction is announced to peers:
- Queue INV messages: Alice's node schedules INV(wtxid) messages to each connected peer
- Poisson delay: each INV is delayed by a random interval (average 2s outbound, 5s inbound) to prevent timing analysis
- Peer requests: peers that don't have the tx respond with GETDATA
- Send TX: Alice's node sends the full serialized transaction
- Propagation: each receiving peer validates (identical ATMP flow) and relays further
- Network-wide: within ~5-15 seconds, the transaction reaches most of the ~15,000 reachable nodes
Step 6: Mining into a Block
Covered in Chapter 7: Consensus & Mining
The transaction sits in mempools worldwide until a miner includes it in a block:
- Block template: the miner calls
getblocktemplate(or equivalent). The algorithm sorts mempool transactions by ancestor fee rate and packs them into a block, respecting the 4 MWU weight limit. - Alice's tx is selected: at ~48 sat/vB, it's well above the mempool minimum and gets included.
- Coinbase transaction: the miner creates a coinbase tx claiming the block subsidy (3.125 BTC at current halving) + all transaction fees in the block.
- Merkle root: all transaction txids are hashed into a Merkle tree. The root goes into the block header.
- Mining loop: the miner increments the nonce (and extranonce) hashing the 80-byte header with SHA-256d until the hash is below the target. At current difficulty, this takes ~10 minutes on average globally.
- Block found!: the miner broadcasts the new block.
Step 7: Block Propagation
Covered in Chapter 8
The new block propagates using compact block relay (BIP 152):
- The miner's node sends
CMPCTBLOCKto its high-bandwidth peers (just the header + short tx IDs) - Receiving nodes reconstruct the full block from their mempools, Alice's tx is already there!
- If any transactions are missing, they're requested via
GETBLOCKTXN/BLOCKTXN - The block reaches most nodes within 1-3 seconds
Step 8: Block Validation
Covered in Chapter 7
Each receiving node fully validates the block via ProcessNewBlock:
Step 9: Confirmation
The transaction now has 1 confirmation. Here's what happens on both sides:
Bob's Node
- Bob's wallet's
IsMinecheck matches the output paying him; it recognizes the scriptPubKey - A
CWalletTxis created with the transaction details - Bob's balance increases by 0.05 BTC (shown as "pending" until 1-6 confirmations)
- Bob's wallet UI shows the incoming payment
Alice's Node
- The transaction is removed from her mempool (it's now in a block)
- Her CWalletTx is updated to show 1 confirmation
- Her two spent UTXOs are marked as spent
- Her change output (0.0099 BTC) appears as a new available UTXO
Deeper Confirmations
Each subsequent block adds another confirmation. The transaction becomes exponentially harder to reverse:
End-to-End Summary
Here's the entire lifecycle in one view. Use the interactive animation below to step through each stage:
Or see it all at once:
No central authority was involved. Alice's node talked to Bob's node (indirectly, through the peer-to-peer network). A random miner proved they did real computational work to add the block. Every node independently verified every step. And Bob now has 0.05 BTC that only he can spend.