BitcoinMachine
BEGINNER_DOC_009 // BEGINNERS / TRANSACTIONS
TRANS-
ACTIONS
A Bitcoin transaction is a signed transfer of value between addresses. It destroys existing unspent outputs and creates new ones. Unlike a bank transfer, a transaction has no concept of a "balance" — it references specific previous outputs, consumes them entirely, and creates new outputs from the total. The difference between inputs and outputs is the miner fee.
Version 4 bytes (currently 1 or 2) Marker 1 byte (0x00 — SegWit transactions only) Flag 1 byte (0x01 — SegWit transactions only) Input count varint Inputs[] — TxID 32 bytes (previous transaction hash) Vout 4 bytes (output index in that tx) ScriptSig varint + bytes (unlocking script) Sequence 4 bytes Output count varint Outputs[] — Value 8 bytes (amount in satoshis) ScriptPubKey varint + bytes (locking script) Witness (SegWit only — per-input witness data) Locktime 4 bytes
Unspent Transaction Outputs
UTXO MODEL
Bitcoin does not track account balances. Instead, it tracks individual "coins" called UTXOs. To spend bitcoin, you must reference specific UTXOs as inputs and consume them entirely. Any leftover is sent back to yourself as change.
Example: You have two UTXOs UTXO A: 0.3 BTC (from a previous receive) UTXO B: 0.2 BTC (from a previous receive) You want to send 0.4 BTC to Alice + 0.09 BTC change + 0.01 BTC fee Transaction: Inputs: → UTXO A (0.3 BTC) consumed entirely ✗ → UTXO B (0.2 BTC) consumed entirely ✗ Outputs: ← 0.40 BTC to Alice's address (new UTXO created) ← 0.09 BTC back to your address (change UTXO created) ← 0.01 BTC implicit miner fee (inputs − outputs)
The fee is never explicitly stated in a transaction — it is simply whatever is left over after all inputs minus all outputs.
From Broadcast to Confirmed
LIFECYCLE
Once created and signed, a transaction travels through several stages before it is permanently settled in the blockchain.
1. Created — wallet builds and signs the transaction offline 2. Broadcast — sent to one or more Bitcoin nodes via P2P network 3. Mempool — unconfirmed tx enters the mempool of all nodes 4. Selected — a miner picks it (higher fee = higher priority) 5. Mined — included in a valid block, broadcast to network 6. Confirmed — each subsequent block adds one more confirmation 7. Final — after ~6 confirmations, considered irreversible
Smallest unit 1 satoshi (0.00000001 BTC)
Max block-size/">block size 4,000,000 weight units (~1 MB base)
Typical tx size (P2WPKH) ~140 vbytes (1-in, 2-out)
Fee unit sat/vbyte (satoshis per virtual byte)
Coinbase maturity 100 blocks before spendable
TERMINOLOGY_INDEX
Input
A reference to a previous UTXO being spent, plus an script/">unlocking script (ScriptSig or Witness).
Output
An amount in satoshis locked to a locking script (ScriptPubKey). Becomes a new UTXO.
UTXO
Unspent Transaction Output. The "coin" model Bitcoin uses instead of account balances.
TxID
Transaction ID — the double SHA-256 hash of the serialized transaction. Used to reference a tx.
Vout
Output index within a transaction. Together with TxID, uniquely identifies a UTXO.
Locktime
A field that prevents a transaction from being mined until a specific block height or timestamp.
Sequence
Per-input field used for relative timelocks (BIP68) and signaling RBF (replace-by-fee).