TERM_DEF // TRANSACTION / SEGWIT_TRANSACTION
SEGWIT
TRANSACTION
TRANSACTION
transaction/">SegWit Transaction. A transaction using SegWit serialization (BIP141); separates witnesses from the TXID.
This page sits in the Transaction section — How money moves: inputs, outputs, fees, signatures, sighash flags, and the formats that wrap them. Read on for what it is, why it exists, how it works under the hood, and what to watch out for.
This page sits in the Transaction section — How money moves: inputs, outputs, fees, signatures, sighash flags, and the formats that wrap them. Read on for what it is, why it exists, how it works under the hood, and what to watch out for.
WHAT_SEGWIT_TRANSACTION_IS
SegWit Transaction — at a glance
TRANSACTION
Why it exists
DESIGN
Pre-SegWit signatures were inside scriptSig, which is part of the data hashed into the txid. That made txids malleable (any third party could re-encode a signature). SegWit moves signatures out of the txid hash, fixing malleability and unlocking Lightning.
HOW_IT_WORKS
Mechanism
HOW IT WORKS
A SegWit tx has the legacy fields + a marker (0x00) + a flag (0x01) right after the version, followed by a witness section after the outputs. Legacy nodes that haven't upgraded see a stripped-down tx (no witness) — they still validate the inputs but don't check signatures.
1. Wallet selects UTXOs whose total value covers the spend amount + estimated fee (coin selection).
2. Wallet builds the transaction body: version, inputs (each with prev txid + vout + sequence), outputs (each with value + scriptPubKey), locktime.
3. Wallet computes the sighash for each input (which parts of the tx the signature commits to — controlled by the SIGHASH flag).
4. Wallet signs each input with the right private key. Witness/scriptSig is populated with the resulting signatures + pubkeys.
5. Tx is broadcast to peers. Mempool propagation: tens of seconds globally.
6. A miner includes it in a block. Confirmation count grows by 1 per block; after ~6 the tx is effectively final.
WORKED_EXAMPLE
SegWit Transaction — SERIALIZATION
EXAMPLE
Field Bytes Notes
version 02 00 00 00 (4 bytes)
marker 00 (SegWit indicator, byte 5)
flag 01 (SegWit indicator, byte 6)
input_count 01 (CompactSize)
input
output_count 01
output
witness 02 <72-byte sig> <33-byte pubkey> (per input)
locktime 00 00 00 00
txid = SHA256(SHA256(tx without marker/flag/witness)) ← stable
wtxid = SHA256(SHA256(full tx including witness)) ← malleable but unused for chain identity
KEY_PROPERTIES
WITNESS DISCOUNT
Witness bytes count 1× toward block-weight/">block weight; non-witness bytes count 4×. This is the SegWit "block size increase".
ATOMIC
A transaction is either fully accepted into a block or fully rejected. There is no partial spend.
IMMUTABLE INPUTS
A UTXO can only ever be spent once. After that, it is permanently consumed.
COMMON_PITFALLS
Things that catch people out
PITFALLS
- address-reuse/">Address reuse degrades privacy — every reuse links more of your UTXOs together publicly. Modern wallets generate a fresh address per receive.
- Fee estimation matters: under-pay and your tx sits in the mempool for hours; over-pay and you tip the miner more than necessary. Use a fee estimator.
- "Change outputs" must go back to a fresh address you control. A missing output/">change output sends the difference to the miner as fee — a known footgun.
- RBF (Replace-By-Fee) lets you re-broadcast a tx with a higher fee. Useful for stuck txs but means a 0-confirmation tx is never truly final.
RELATED_CONCEPTS
Other terms from Transaction — click any to read its page:
TERMINOLOGY_INDEX
TERMINOLOGY
SegWit Transaction
A transaction using SegWit serialization (BIP141); separates witnesses from the TXID.
Transaction (Tx)
A signed payload spending one or more UTXOs and creating new ones; every state change in Bitcoin is a tx.
Raw Transaction
The hex-serialized bytes of a transaction, ready to broadcast or analyze.
Transaction ID (TXID)
wTXID (Witness TXID)
HASH256 of the full transaction including witness data; commits to signatures and used in the witness commitment.
Input
A reference to a previous output being spent, plus the data (scriptSig/witness) authorizing the spend.
Output
An (amount, scriptPubKey) pair created by a transaction; spendable later by a tx whose input references it.
UTXO (Unspent Transaction Output)
An output that hasn't been spent yet; your "balance" is the sum of UTXOs you can sign for.