
Full recording, about 90 min. Plays from youtube-nocookie.com. Watch on YouTube
You are here: Inside a transaction, byte by byte. Next: Week 3 questions discussed Monday 7 December.
TL;DR
- A payment's life: your wallet builds and signs it, nodes check it and pass it on, it waits in the mempool, a miner puts it in a block. One block is one confirmation; big payments wait for more.
- There is no single mempool. Every node keeps its own waiting room, and invalid transactions (bad signature, coins already spent) never get in.
- There is no fee field. The fee is whatever is left: inputs minus outputs. Forget the change output and the miner keeps it.
- Hands-on: a minimum-fee payment sent live, the Reorg Calculator, and a raw transaction taken apart in the Transaction Decoder. Next week goes down to the bytes.
Before next Monday0 / 6
Mission board0 XP
Week 3: six badges to collect
Four mini-games built from the answers on the call, your homework checklist and a final quiz. Each one lights up a badge. Progress stays on this device and adds XP to your builder passport.
Highlights
Round two of the discussion. Last week everyone got one of six questions about how a transaction lives. This Monday they answered them around the table, like a Socratic seminar in a coffee shop: one person answers, the others argue, correct and add. Then Alex shared the screen and we did the exercises together.
Six questions on the table
1The life of a payment
Three people split question 1 between them. First, the wallet. You need coins before you can spend them, and each coin you hold is a UTXO, like a banknote in a physical wallet. To pay 0.5 BTC from a 1 BTC UTXO you spend the whole note: 0.5 goes to the receiver, a small fee goes to the miner, and the rest comes back to you as change. The wallet signs it and broadcasts it.
Then the network takes over. Peer-to-peer nodes check the transaction (valid signatures, coins not already spent), keep it in their mempool and pass it on. A miner picks it up, and when their block is accepted, that is your first confirmation. Every block on top adds one more. Six is the old rule of thumb for “really final”.
From your phone to the blockchain
The fee is not a field. It is whatever the outputs don’t claim: sum of inputs minus sum of outputs. The miner keeps the difference.
Then a great follow-up: so how do you pay the miner? There is no fee field anywhere in a transaction. If you build one by hand, spend a 1 BTC UTXO, pay 0.5 and forget the change output, the other 0.5 is the fee, and the miner keeps it. This has happened for real. Today’s wallets add the change output for you and warn you about silly fees, and Bitcoin Core refuses to broadcast an absurdly high fee by default. Somebody fixed this for all of us, without knowing who we are.
Mini-game 1 · Change keeper✓ badge earned
Where did the fee go?
You spend one 1 BTC UTXO to pay Alex 0.5 BTC. Set your change and watch the fee. First, try forgetting the change. Then set a sensible fee of 1 to 50 sat/vB.
1.00000000 BTC
2No single mempool
Question 2: the mempool is a waiting room. One answer called it a bus station: transactions wait there until a miner’s block picks them up. But there is no central server, so every node keeps its own. Transactions reach different nodes at different times, and each node has its own size limit and minimum fee, so mempools look alike but are never identical. Miners usually pick the transactions that pay the most per byte.
Then the best question of the night: what about a failed transaction? Can you see why it failed on mempool.space? The group worked it out together, and it is worth being precise:
- Invalid transactions never get in. A bad signature, coins that don’t exist or are already spent in a block, outputs worth more than the inputs: every node rejects these on arrival and doesn’t pass them on. So no explorer ever shows them.
- Conflicts are settled by the next block. Two valid transactions spending the same coin can each sit in different nodes’ mempools (a node keeps only one, unless the second pays a higher fee to replace the first). Once a miner’s block confirms one, the other becomes invalid everywhere and disappears.
- A low fee doesn’t make a transaction invalid. It just waits. If mempools fill up, nodes may drop it, and then the coins simply stay in your wallet. You can also speed it up by paying more (replace-by-fee).
“The mempool is temporary. It’s not a confirmation.”
From the discussion on double spendskeypleb tested it live. They sent a payment from their phone with the lowest fee the wallet allowed and opened it on mempool.space: unconfirmed, right at the back of the queue, paying about two cents while others paid 12 to 20. The mempool was nearly empty that evening, so even the cheapest fee was expected to get in. On a busy day it could wait a long time.
Mini-game 2 · Gatekeeper✓ badge earned
You are a node. Who gets into your mempool?
Seven transactions arrive. Let each one in, or reject it. Get all seven right for the badge.
Your mempool is empty. Here comes the first one.
3Reorgs, and why merchants wait
Question 3: a chain reorganisation. Two miners can find a block at almost the same moment. For a few minutes the network has two tips, and different nodes follow different ones. As soon as the next block lands on one side, everyone switches to the chain with the most proof of work and the other block goes stale. That switch is a reorg. keypleb showed one on Fork Observer, where you can watch these short splits happen.
Then the car question. You sell your car for 1 BTC in a parking lot and the payment lands in block 1000, which then loses a reorg. Is the money gone? One participant explained it well: no. Your transaction goes back to the mempool and is mined again in the new chain’s block 1000 or 1001. The real risk is a buyer who also signed a second, conflicting payment to themselves, and gets that one mined in the winning chain. That is the double spend confirmations protect you from.
Two blocks at once, one winner
999 → 1000aYour car payment is in here. Some nodes follow this tip. Goes stale.
999 → 1000b → 1001The next block lands on this side, so everyone switches. Most work wins.
back to mempoolYour payment is still valid, so it gets mined again in 1001 or 1002.
One participant had done the homework and walked us through the Reorg Calculator. Drag the attacker to 50% of the hashrate and they always win in the end, however long you wait. At 40% even 12 confirmations leave a real chance. At a more realistic share, a handful of blocks makes a reversal vanishingly unlikely. That is why spread-out mining matters, and why big payments wait longer than a coffee.
Mini-game 3 · Six blocks✓ badge earned
How safe is your payment?
This week’s exercise, playable: set the attacker to 10% of the hashrate and check 1, 3 and 6 confirmations. The odds use the formula from section 11 of the whitepaper.
4Why change gets a new output
Question 4. There are no accounts in Bitcoin, so nothing can be partly spent. You spend whole UTXOs and new ones are created, and your change is one of them. Most wallets send it to a fresh address, and someone added the reason: privacy. If change always went back to the same address, anyone could follow your money from payment to payment. Sending change to the same address is allowed, though. It still makes a brand new UTXO; it just leaks more about you.
5Inside a transaction
Alex took question 5 and shared the screen. A transaction is a straight line of fields, one after another. The hard part isn’t the order, it’s that each field has its own size and format. That is exactly what next week’s lessons are about.
A transaction, in order
versionWhich rules this transaction follows. 4 bytes
marker + flag“This is a segwit transaction.” Segwit only, 2 bytes
input countHow many inputs follow. Compact size
inputsEach one: previous txid, output index, scriptSig, sequence. Which coins you spend
output countHow many outputs follow. Compact size
outputsEach one: amount in sats and the locking script. Who can spend next
witnessSignatures and keys for segwit inputs. Segwit only
locktimeNot valid before this block height or time. 4 bytes, usually 0
Question 6: what does an input point to? An earlier transaction’s output, named by its txid and output number. Your spending is someone else’s earlier income. Every node follows that pointer, checks the output exists, hasn’t been spent yet, and that your signature unlocks it. Chain those checks back and every coin traces to the block reward that created it.
6The exercises, live
Exercise 1: decode a raw transaction. Alex pasted raw hex into the Transaction Decoder: one input, two outputs, version 2, locktime 0. One output is the payment, the other is most likely change. Tip from the call: on mempool.space the API gives you any transaction’s raw hex at /api/tx/<txid>/hex.
Exercise 2: flip the txid. The txid you see on an explorer is the raw bytes in reverse order. Inside a transaction, the bytes are stored little-endian; explorers show them flipped. Two hex characters make one byte, so you flip pairs, not single characters.
Mini-game 4 · Byte flipper✓ badge earned
Rebuild the txid the way explorers show it
These are the first 8 bytes of a txid as they appear inside a raw transaction. Tap them in reverse order, last byte first.
Byte by byte: tap the last pair first.
Exercise 3: legacy vs segwit. No time left on the call, so here is the short version. Segwit moved signatures into the witness, and witness bytes count four times less toward a block’s weight limit. So the same simple payment costs fewer virtual bytes, which means a lower fee.
Same payment, 1 input and 2 outputs
Approximate typical sizes. Weight = non-witness bytes × 4 + witness bytes; vbytes = weight ÷ 4.
7The deep end: the BOSS Challenge
For anyone who wants more, keypleb invited everyone to the BOSS Challenge by Chaincode Labs. It runs from 11 January to 19 February 2027 and applications close on 31 December. The first gate is Saving Satoshi, a set of story-driven coding challenges. It is not easy, but Code Orange is a partner and the community will help you through it. Apply for the BOSS Challenge.
Key takeaways
- Everyone checks everything. Every node validates every transaction before it enters its own mempool. Invalid ones never get in.
- The fee is what’s left over. Inputs minus outputs. Your wallet adds change so the miner doesn’t keep it.
- Confirmations are a sliding scale. One block is good, more is safer, and how many you need depends on how much is at stake.
Final level: the quiz
Four questions from the call. Get all four right and the Decoder badge lights up on the mission board.
Test yourself
Resources shared
The course
- Week 2 lesson: Transaction Lifecycle, The Bitcoin Dev Project: from wallet to mempool to block: the background for questions 1 to 3
- Transaction Structure, The Bitcoin Dev Project: every field in order, with the format of each. Alex walked through it for question 5
- Tool: Transaction Decoder, The Bitcoin Dev Project: paste raw transaction hex and see every field. Alex demoed it on the call
- Tool: Reorg Calculator, The Bitcoin Dev Project: how likely an attacker with X% of the hashrate rewrites a payment after N confirmations
- Week 3 lesson: Compact Size, The Bitcoin Dev Project: homework for next Monday: how Bitcoin writes counts and lengths
Reading
- Bitcoin whitepaper, section 11: Calculations, Satoshi Nakamoto, 2008: the maths behind the Reorg Calculator: the odds an attacker catches up from z blocks behind
Tools
- mempool.space: watch the mempool, fee rates and blocks live. keypleb's minimum-fee payment waited at the back of the queue here
- mempool.space API: raw transaction hex: GET /api/tx/
/hex gives you the raw transaction to paste into the decoder - Fork Observer, 0xB10C: watch stale blocks and short chain splits as they happen. Shown on the call for question 3
- Blockstream Explorer: a second block explorer, handy when mempool.space won't load
What comes next
- BOSS Challenge: apply, Chaincode Labs: runs 11 January to 19 February 2027, apply by 31 December. Code Orange is a partner and will help you through it
- Saving Satoshi, Chaincode Labs: story-driven coding challenges, the first step into the BOSS Challenge
Code Orange
- Weekly plan: all 10 weeks: lessons, discussion questions and exercises. Now with a light mode
- Privacy Track: silent payments continue on Tuesday 1 December, hosted by Razor
Also on the call: a light mode for the weekly plan was requested during the session and shipped before it ended. One person found that certificate progress only showed after ticking lessons in two places (the dashboard and the weekly plan); progress is saved per browser, and keypleb is tidying this up. Open question for next time: what really happens to a low-fee transaction when the mempool gets busy?
☰ Decoding Bitcoin playlist: all 3 sessions →
These notes are also on GitHub: code-orange-dev/session-notes. Free to share and reuse (CC0).