Skip to main content

SegWit | Bitcoin Glossary | Mapping Bitcoin

SegWit

Protocolo

Also known as: Segregated Witness, BIP141

Segregated Witness, a soft fork upgrade activated in 2017 that separates (segregates) signature data (witness) from transaction data. SegWit fixes transaction malleability, enables the Lightning Network, increases effective block capacity, and reduces fees for compliant transactions.

Overview

Segregated Witness (SegWit), activated on August 24, 2017, is one of the most significant upgrades to the Bitcoin protocol. It restructures how transaction data is organized by moving the signature (witness) data into a separate structure. This seemingly simple change solved several long-standing problems: it fixed transaction malleability, enabled the Lightning Network, increased effective block capacity, and introduced a fee discount for witness data.

How SegWit Restructures Transactions

Pre-SegWit Transaction:           SegWit Transaction:
┌─────────────────────────┐       ┌─────────────────────────┐
│ Version                 │       │ Version                 │
├─────────────────────────┤       ├─────────────────────────┤
│ Inputs:                 │       │ Marker + Flag (0x0001)  │
│  ┌────────────────────┐ │       ├─────────────────────────┤
│  │ Previous TXID      │ │       │ Inputs:                 │
│  │ ScriptSig          │ │       │  ┌────────────────────┐ │
│  │  (signatures HERE) │ │       │  │ Previous TXID      │ │
│  └────────────────────┘ │       │  │ ScriptSig (empty)  │ │
├─────────────────────────┤       │  └────────────────────┘ │
│ Outputs                 │       ├─────────────────────────┤
├─────────────────────────┤       │ Outputs                 │
│ Locktime                │       ├─────────────────────────┤
└─────────────────────────┘       │ Witness:                │
                                  │  (signatures HERE)      │
 TXID covers entire               ├─────────────────────────┤
 transaction including            │ Locktime                │
 signatures                       └─────────────────────────┘

                                   TXID covers everything
                                   EXCEPT witness data

Problems Solved by SegWit

Transaction Malleability Fix

Before SegWit, the transaction ID (TXID) was calculated over the entire transaction, including signatures. Since signatures could be slightly modified without invalidating them (malleated), the TXID could change after broadcast. SegWit excludes witness data from the TXID calculation, making TXIDs immutable. This was a prerequisite for the Lightning Network, which relies on chains of pre-signed transactions referencing stable TXIDs.

Increased Block Capacity

SegWit introduced "block weight" (maximum 4 million weight units) to replace the old 1 MB block size limit. Non-witness data counts at 4 weight units per byte, while witness data counts at 1 weight unit per byte. In practice, this allows blocks to contain roughly 1.7-2.1 MB of total data, depending on the transaction mix.

Witness Discount

The witness discount incentivizes SegWit adoption by counting witness bytes at one-quarter the weight. This results in lower fees for P2WPKH and P2TR transactions compared to legacy P2PKH transactions, benefiting users who upgrade.

SegWit Versions

SegWit introduced a versioning system for future upgrades:

  • Witness v0P2WPKH and P2WSH outputs using Bech32 addresses (bc1q...)
  • Witness v1P2TR (Taproot) outputs using Bech32m addresses (bc1p...)
  • Witness v2-16 — Reserved for future upgrades, deployable via soft fork

Backward Compatibility

SegWit was deployed as a soft fork, meaning non-upgraded nodes still accept SegWit blocks as valid (they see the witness outputs as "anyone can spend" but never attempt to spend them). This backward compatibility avoided a contentious chain split and allowed gradual adoption.

Common Misconception

SegWit is sometimes described as simply a "block size increase," but this undersells its significance. The malleability fix was arguably more important, as it enabled an entire ecosystem of layer-2 protocols. The capacity increase was a welcome side effect of the new weight-based accounting system.