Feedback
Sign in./start

Site navigation

Theme

Learn

  • Roadmaps

Build

  • Projects
  • Developer Tools

Contribute

  • Open Source Projects
  • Issues
  • Reviews
  • First Contribution
  • BountiesSoon
  • Feedback

Prove

  • Builders

Ecosystem

  • Partners
  • Get Funded↗
  • HackathonsSoon
Sign in./start-building

Become an Open Source Builder. Learn. Build. Contribute. Prove.

Feedback welcome — open a GitHub issue.

Learn

RoadmapsStart Building

Build

ProjectsDeveloper Tools

Contribute

Open Source ProjectsIssuesReviewsFirst ContributionSupportFeedback

Prove

Builders Directory

Account

Sign in

Legal

PrivacyTermsCredits

© 2026 Pull // code MIT · curriculum CC BY-SA 4.0

PrivacyTermsCredits

lesson // bitcoin

SegWit & Bech32

Witness data, weight units, and modern address formats.

intermediate5 days

Public lesson — sign in to track progress on this roadmap.

./sign-in

On this page

Learning objectives

  • Explain why SegWit moved signatures to the witness
  • Calculate fees using weight and vbytes
  • Use Bech32 addresses correctly in wallets

study // plan

Lessons are primers. Start with Step 1 (required reading) when present, then follow the numbered steps in the article. Depth comes from primary sources, labs, reflection, and evidence.

Research on Bitcoin Search
BIP141SegWit

Step 1 // Required reading

Complete these before the numbered steps in the lesson body. Links are listed here once — not repeated below.

  • bookMastering Bitcoin

    Ch. 6: Transactions

    Read SegWit / witness structure sections.

Reflection prompts

  1. Explain SegWit & Bech32 to a teammate without jargon - what problem does it solve?
  2. What would break in production if you misunderstood SegWit & Bech32?
  3. Which BIP, book chapter, or Core doc is authoritative here, and what did you verify?

Lab // Native SegWit on regtest

Complete Steps 2–3. Create a Bech32 address on regtest, send to it, and inspect weight / vsize fields on the decoded transaction.

evidence required

  • ·getnewaddress "" "bech32" (or equivalent) and a send txid
  • ·Decoded tx showing vsize/weight (or fee) fields
  • ·One sentence on why weight differs from legacy byte size
  1. 01

    Worked mental model

    Re-read the diagrams in this lesson once out loud in plain language. If you cannot explain the flow to a friend without jargon, pause and revisit the Mastering Bitcoin / Mastering Lightning chapters linked in Resources. Chapter references are intentional, not decorative.

  2. 02

    Hands-on habit

    Every protocol idea should be paired with one local experiment. That habit turns reading into builder instinct.

    1. Reproduce the happy path on regtest (or Polar for Lightning)
    2. Break it on purpose (wrong fee, expired invoice, offline peer)
    3. Write down what error you saw and which layer produced it (wallet, node, mempool, peer)
  3. 03

    Glossary check

    Pick three terms from this lesson and define them in one sentence each without opening notes. Weak definitions mean the lesson is not finished yet.

  4. 04

    Resource order

    Use Resources in order: narrative book chapter first, then BIP/BOLT for precision, then implementation docs for commands. Jumping straight to RPC flags without the mental model creates brittle knowledge.

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…

SegWit stabilizes txids for protocols and introduces weight-based fees.

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.

Prefer native SegWit for new single-sig

Nested SegWit exists for compatibility, but native Bech32 usually saves fees and complexity.

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" true

Note 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 bc1 on 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.

further reading

  • bipBIP-141 Segregated Witness
  • bipBIP-173 Bech32

review // club

Review club

Practice on real Bitcoin OSS changes tied to this chapter. Read the diff, use the checklist, and optionally paste your review comment URL in your lab notes.

  • BIP-141 SegWit specification

    Read BIP-141 and summarize how witness data changed block weight and transaction serialization.

    spec review
    vbyteswitness commitmentsoft fork
    45 min·intermediateopen on GitHub
review checklist
  1. Does the change solve the stated problem?
  2. Are edge cases and rollout behavior covered?
  3. Are tests or test vectors included?
  4. Is the diff minimal and clearly explained?

More repos and GFIs on /discover and /issues.

progress // sign in

Reading is public. Sign in to mark lessons complete, sync across devices, and unlock your roadmap.

./sign-in-to-track

discussion

Discussion

prevBitcoin ScriptnextTaproot & Tapscript

On this page

Press Shift + ? for keyboard shortcuts.

Press R to research on Bitcoin Search.

No questions yet — be the first to ask.