TRANSACTIONS / SERIALIZATION
Transaction Serialization
A Bitcoin transaction is a precisely-encoded binary structure. Every node on the network parses the same bytes identically. Legacy transactions have four top-level sections: version · inputs · outputs · locktime. SegWit transactions (BIP141) insert a
0x00 0x01 marker+flag after the version and append per-input witness stacks before locktime — without changing how the txid is computed.
FORMAT REFERENCE
LEGACY FORMAT
SEGWIT FORMAT (BIP141)
| FIELD | BYTES | ENCODING | NOTES |
|---|---|---|---|
| version | 4 | LE uint32 | 1 = original; 2 = BIP68 relative locktime |
| in_count | varint | 1–9 B | # inputs (≤0xFC → 1 byte; 0xfd → 3 bytes…) |
| prev txid | 32 | LE bytes | previous tx hash stored byte-reversed |
| prev vout | 4 | LE uint32 | output index; 0xffffffff = coinbase |
| scriptSig_len | varint | 0x00 for SegWit inputs | |
| scriptSig | variable | raw | DER sig + pubkey for P2PKH |
| sequence | 4 | LE uint32 | 0xffffffff=final; 0xfffffffe=RBF-opt-in |
| out_count | varint | # outputs | |
| value | 8 | LE int64 | satoshis (100,000,000 sat = 1 BTC) |
| scriptPubKey | variable | raw | script/">locking script (len varint + bytes) |
| locktime | 4 | LE uint32 | 0=none; <500M=block-height/">block height; ≥500M=unix ts |
HEX DISSECTOR
PARSE RAW TRANSACTIONclick any coloured field to inspect
VARINT ENCODING
VARINT ENCODER / DECODER
| VALUE RANGE | STORAGE (bytes) | PREFIX | EXAMPLE |
|---|---|---|---|
| 0–252 | 1 | — | fc = 252 |
| 253–65535 | 3 | 0xfd | fd 0100 = 256 |
| 65536–4294967295 | 5 | 0xfe | fe 00000100 = 65536 |
| 4294967296–2⁶⁴−1 | 9 | 0xff | ff 0000000001000000 = 4G |