Segregated Witness (SegWit) moved signature data out of the legacy transaction identifier path. That fixed transaction malleability for modern outputs and changed how block capacity and fees are measured.
Complete Step 1 // Required reading in the study plan above, then continue here.
Step 2 — Core idea: witness, weight, Bech32
Almost all modern wallets use SegWit or Taproot. If you still price fees in “raw bytes only,” fee estimates and size math will be wrong.
Analogy: A court filing where signatures sit in an envelope marked “witnesses.” The case ID no longer changes if someone fiddles with signature formatting, and the court weights witness pages differently when measuring stack size.
What changed:
- txid no longer includes witness data (wtxid does)
- Block limits use weight: witness bytes count less than non-witness bytes
- vbytes ≈ weight / 4 for fee rates (sat/vB)
const vbytes = weight / 4;
const fee = Math.ceil(satPerVb * vbytes);Weight units:
- Non-witness byte: 4 weight units
- Witness byte: 1 weight unit
- Block weight limit: 4,000,000 units
Loading diagram…
Before SegWit, third parties could tweak signatures and change txids in some cases. Second-layer protocols that pre-signed dependent transactions suffered. SegWit removed witness data from txid calculation, enabling safer Lightning-style designs.
Native SegWit v0 addresses use Bech32 (bc1q...). Nested SegWit wraps witness programs inside P2SH (3...) for old wallet compatibility. New systems should default to native SegWit or Taproot.
Done when: You can explain why txid is stable under SegWit and compute fee from sat/vB × vbytes.
Step 3 — Try it on regtest (lab)
ADDR=$(bitcoin-cli -regtest getnewaddress "" "bech32")
bitcoin-cli -regtest generatetoaddress 101 "$(bitcoin-cli -regtest getnewaddress)"
TXID=$(bitcoin-cli -regtest sendtoaddress "$ADDR" 0.1)
bitcoin-cli -regtest getrawtransaction "$TXID" trueNote vsize / weight-related fields. One sentence: why comparing “byte size” across legacy and SegWit without weight misleads.
Common mistakes
- Comparing byte size across legacy and SegWit without weight
- Sending to
bc1on the wrong network HRP - Forgetting older receivers that cannot parse Bech32 (rare now, still possible)
Done when: Lab evidence (bech32 address + decoded send + weight sentence) is complete.
Next lesson
Taproot & Tapscript — SegWit v1 with Schnorr and script trees.