Open any block explorer and it will show you a transaction with a sender, a recipient, an amount and a fee. Three of those four are not in the data. They are reconstructions the explorer performs for your benefit, and knowing which is which is the difference between reading Bitcoin and reading a rendering of it.
What is actually in the serialised data?
A transaction is five fields, in order: a version number, a list of inputs, a list of outputs, the witness data if present, and a locktime.
Each input names a previous output by its transaction id and index, carries a spending proof, and carries a 4-byte sequence number. Note what an input does not carry: the amount. The value being spent lives in the output being consumed, which the verifier must look up in its own set of unspent outputs. An input is a pointer plus a proof.
Each output is two things only — an amount in satoshis, and a
scriptPubKey that defines the condition under which that amount may later be
spent. There is no address in the data. An address is a human-readable
encoding of a spending condition, and an explorer displays one by recognising
a standard script pattern and reversing the encoding.
The witness, when present, holds the signatures and other unlocking data that older transactions kept in the input itself. The locktime sets the earliest point at which the transaction may be included in a block.
Where is the fee?
Nowhere. The fee is the difference between the sum of the input values and the sum of the output values, and it is never written down. A transaction with inputs totalling 1.0 BTC and outputs totalling 0.9995 BTC pays 0.0005 BTC, because the miner who includes it claims the remainder in the coinbase.
This produces one of the most expensive classes of mistake in Bitcoin. A wallet that builds a transaction and forgets the change output does not create an error — it creates a valid transaction donating the change to the miner. There is no rule against it, nothing to validate against, and no way back.
For the journey this message takes rather than its contents, start at what happens when you send bitcoin?.
Why is size measured three different ways?
Because SegWit changed the accounting without changing the limit’s name.
A transaction has a base size, the bytes excluding witness data, and a total size including it. Weight is defined as three times the base size plus the total size, and a block may contain up to four million weight units. Divide weight by four and you get virtual size in vbytes, the unit fees are quoted in.
The effect is that witness data costs a quarter of what the same bytes cost elsewhere in the transaction. That discount is deliberate: signatures are the part a node can discard after validating, so making them cheaper encourages the transaction shape that is kinder to the UTXO set everyone must store forever.
What does a locking script look like?
Script is a stack language with no loops and no function calls, which is a safety property rather than a limitation: a validator must be able to bound the cost of running a script before it runs it. Its evolution is visible in how much of the condition is left in the open.
A pre-SegWit output paying to a key says, in opcodes, duplicate the supplied public key, hash it, compare it to this 20-byte value, and then check the signature against it. The spender provides the signature and the key, and the key is only revealed at the moment of spending.
The SegWit version of the same thing is shorter: the output is a witness program, a version byte followed by the same 20-byte hash and nothing else. The interpretation lives in the consensus rules rather than in the script, and the unlocking data has moved to the witness.
Taproot takes this to its conclusion. The output is a version byte and a single 32-byte public key. That key can be spent in two ways: by signing with it directly, which costs one 64-byte Schnorr signature, or by revealing one script from a Merkle tree committed to inside the key, along with a proof that it belongs there. The branches never used are never published.
The result is that a two-of-two arrangement, a complex contract with a dozen fallback paths, and a single person paying themselves can all appear on-chain as the same thing: one key, one signature. Privacy here comes from making the common case indistinguishable rather than from hiding anything.
What does a signature actually sign?
Not the transaction. A signature commits to a digest built from selected parts of the transaction, and which parts is chosen by a one-byte flag appended to the signature.
The default, SIGHASH_ALL, commits to every input and every output, so the
signed transaction cannot be altered at all without invalidating it. The
alternatives commit to less: SIGHASH_NONE leaves the outputs free,
SIGHASH_SINGLE commits to one matching output, and ANYONECANPAY releases
the other inputs so that anyone may add their own. These exist for
collaborative constructions, where several parties contribute to one
transaction without each having to approve the final whole.
The digest itself has been revised twice. The original scheme re-hashed large parts of the transaction once per input, so a transaction with many inputs cost quadratically more to verify — a real denial-of-service surface. BIP 143 replaced it for SegWit v0 with a scheme using precomputed subhashes, and crucially made the signature commit to the value of the input being spent, so a hardware wallet can know how much it is authorising without being handed the whole history. Taproot’s digest goes further and commits to the amounts and scripts of every input at once.
Why did the transaction id change meaning?
Before SegWit, the signature sat inside the input, and the transaction id was a hash of everything including that signature. Signatures are not uniquely encoded, so a third party could alter one in a way that kept it valid while changing the id. The transaction still did the same thing under a different name, which broke anything that referenced an unconfirmed transaction by id.
Segregating the witness fixed this by definition. The txid is now computed
over the serialisation without witness data, so it cannot be changed by
anyone who does not control the inputs. A second identifier, the wtxid,
covers the witness as well and is what the Merkle commitment in the coinbase
uses. Layered protocols such as Lightning, which must sign transactions
spending outputs that have not yet confirmed, are only possible because of
this.
What are sequence and locktime for?
Both were in the original design as a half-finished idea and were given real meaning later.
nLockTime makes a transaction invalid before a given point, interpreted as a
block height below 500,000,000 and as a Unix timestamp above it. It only takes
effect if at least one input’s sequence is below the maximum, which is the
historical hook that made the rest possible.
Sequence numbers now do two jobs. Under BIP 68, a sequence value on a version 2 transaction encodes a relative timelock: an input becomes spendable only after a given number of blocks or seconds since the output it spends was confirmed. This is what lets a contract say “if my counterparty disappears, I can reclaim this in two weeks” without naming a date. Separately, a sequence below the maximum has long been the opt-in signal that a transaction may be replaced by a higher-fee version before confirmation.
Check it yourself
Every claim above is inspectable on a laptop, and the decode is the fastest way to make the structure stop being abstract.
# Any confirmed transaction, fully decoded.
bitcoin-cli getrawtransaction <txid> true
# Confirm the fee is arithmetic, not a field: sum the inputs it spends,
# then subtract the outputs it creates.
bitcoin-cli decoderawtransaction "$(bitcoin-cli getrawtransaction <txid>)"
Look for three things. There is no fee key anywhere in the output. The
vin entries carry no amount. And vsize differs from size whenever the
transaction has a witness, by roughly the discount described above.
What remains uncertain
Which replacement policy a transaction will meet. Whether an unconfirmed transaction can be replaced without signalling depends on the policy each node and each miner runs, not on a consensus rule, and that policy has shifted in recent releases. Any statement that a given transaction “cannot be replaced” is a claim about the network’s current configuration rather than about Bitcoin.
How much of the fee market is structurally non-payment traffic. Inscription and data-carrying uses compete for the same weight units as payments. Whether they are a durable source of fee revenue or a passing phase is unresolved, and it matters because projections of the post-subsidy security budget depend on the answer.
Whether the witness discount is correctly priced. The four-to-one ratio was a judgement made in 2017 about the relative cost of witness bytes and UTXO growth. It has never been revisited against measured costs, and no one claims the number is derived rather than chosen.
What standardness rules will accept next year. Much of what a wallet can broadcast is governed by relay policy rather than consensus. Policy is deliberately easier to change than rules, which makes it a poor thing to build a long-lived assumption on.
Sources
- PrimaryBitcoin: A Peer-to-Peer Electronic Cash System ↗
- First-partyBitcoin Core — src/primitives/transaction.h ↗
- PrimaryBIP 141 — Segregated Witness (Consensus layer) ↗
- PrimaryBIP 143 — Transaction Signature Verification for Version 0 Witness Program ↗
- PrimaryBIP 341 — Taproot: SegWit version 1 spending rules ↗
- PrimaryBIP 68 — Relative lock-time using consensus-enforced sequence numbers ↗