Four fields decide everything
I spent an evening last week staring at raw transaction hex on a block explorer, zooming in until the browser stopped letting me, and the thing that struck me was not the cryptography. It was how boring the layout is. A Bitcoin transaction is a sequence of length-prefixed fields, written little-endian, with no compression, no cleverness, and no room for interpretation. You could parse it with a while loop and forty lines of Python.
That boringness is the design. Every byte in that string is answering one of exactly three questions: which coins are being spent, where the new ones go, and when this becomes valid. If a field does not answer one of those, it is not there.
So let me take one apart. Not conceptually — literally, in order, the way the parser sees it.

The Container
4 bytes version usually 0x00000002
varint input count how many coins are being spent
... inputs
varint output count
... outputs
4 bytes nLockTime
version is almost always 2 these days. That is not cosmetic: version 2 is what enables the OP_CHECKSEQUENCEVERIFY relative timelock, and a transaction that wants to use script-level time locks has to declare it up front. Version 1 still exists and still validates; it simply cannot do things version 2 can.
The counts are varints, which is why small transactions look like they have almost no overhead: one byte for “2 inputs”, one byte for “2 outputs”.
Inside an Input
An input is the smallest possible statement of “I am spending that specific coin”:
36 bytes prevout 32-byte txid + 4-byte vout index
varint scriptSig length
N bytes scriptSig unlocking script (often empty in SegWit)
4 bytes nSequence
The 36-byte outpoint is worth pausing on. Bitcoin does not spend “from an address” and does not spend “a balance”. It names one specific output of one specific earlier transaction by its hash and its position in that transaction’s output list. That is the whole of it. This is why the UTXO model piece insists your balance is not a number — the number is a sum your wallet computed; the chain only knows outpoints.
scriptSig is where the two eras of Bitcoin visibly split. In a legacy P2PKH spend, this field carries your signature and your public key, and it is part of the block’s base data. In a SegWit spend, this field is empty — the signature has moved out to a separate witness structure that is not counted at full weight. That single move is why the same payment got cheaper without changing the 1 MB block size people kept arguing about.
nSequence is the field everybody ignores and shouldn’t:
0xffffffff — nSequence value that means “final” — it disables nLockTime and opts out of replacement
sequence = 0xffffffff → final, no RBF · sequence < 0xfffffffe → opt-in to BIP-125 replacement
That is it. Two values out of four billion do all the work in practice. If you have ever wondered how a wallet “speeds up” a stuck transaction, this byte is the answer: the original transaction signaled replaceability with a sequence number below 0xfffffffe, so a new version can reuse the same outpoints at a higher fee.
Inside an Output
8 bytes value amount in satoshi
varint scriptPubKey length
N bytes scriptPubKey the locking condition
Eight bytes for the amount. That is 18,446,744,073,709,551,615 satoshi of headroom, and the entire supply of bitcoin is 2,100,000,000,000,000 satoshi — less than 0.012% of what the field can express. There is no overflow risk here by luck; the field is simply absurdly oversized for the job.
The scriptPubKey is the lock. For a modern single-key wallet it is 22 bytes (OP_0 plus a 20-byte hash), for Taproot it is 34 bytes (OP_1 plus a 32-byte x-only key), for an OP_RETURN output it is a provably unspendable data carrier and the value is zero.

Why the Same Payment Costs Three Different Amounts
Here is where the byte layout stops being trivia. A transaction’s cost is not measured in bytes. It is measured in weight, and weight treats the two halves of the transaction differently:
weight = base_size × 4 + witness_size × 1 · vsize = ceil(weight / 4) · block cap = 4,000,000 WU
So witness data is discounted to a quarter. A signature that would have cost 72 bytes of block space now costs 18 virtual bytes. And the practical consequence, for the same one-input two-output payment:
| Spend type | What the input looks like | Rough input vsize |
|---|---|---|
P2PKH (legacy, 1...) | sig + pubkey in scriptSig | ~148 vB |
P2WPKH (SegWit v0, bc1q...) | empty scriptSig, sig + pubkey in witness | ~68 vB |
P2TR key-path (bc1p...) | empty scriptSig, one 64-byte signature | ~57.5 vB |
Read that table again with fee rates attached. At 20 sat/vB, the legacy input costs about 2,960 satoshi and the Taproot input about 1,150. The format you receive to is a fee decision made months before you pay the fee. That is why the previous piece on address formats argued you should stop receiving to 1... addresses — the bill is deferred, not avoided.

Locktime, and the Two Clocks
The last four bytes decide when the transaction is allowed to exist.
nLockTime below 500,000,000 is read as a block height. At or above it, it is read as a Unix timestamp. That threshold is not arbitrary — it is LOCKTIME_THRESHOLD, and it means a locktime of 500,000,000 is the first value interpreted as a date (November 1985, which is why nobody accidentally sets it).
And a locktime does nothing on its own. It only takes effect if at least one input’s nSequence is not final. This is the interaction that trips people up: you cannot have a timelocked transaction and a replaceable one using the same bytes in the same way, and a wallet that sets locktime while leaving every sequence at 0xffffffff has written a field that the consensus rules will ignore.
What I Actually Take From This
The transaction format is 2009 engineering that has survived four major soft forks because it was explicit about every field. There is no extension mechanism inside the encoding, no optional headers, no versioned sub-structures. When Bitcoin needed new capability, it put it in a place the old format could not see — the witness — and then re-weighted the accounting around it.
That is a very different design philosophy from “we’ll add a flags field and figure it out later.” It costs flexibility up front. It buys you a format that two independent implementations can parse identically fifteen years later, which is the only property that actually matters for a settlement layer.
So, for what it’s worth:
- If you are debugging a stuck transaction, look at
nSequencefirst. Not the fee, not the mempool depth. A final sequence means no replacement is possible, and everything else follows from that. - If you are estimating cost, estimate in weight, not bytes. The witness discount is a 4x factor and it dominates every other consideration at today’s fee levels.
- If a tool shows you an “amount sent” without showing the change output, it is guessing. The chain has outputs, not transfers; a payment and its change are the same kind of thing in the same list.
(The End)


