Segregated Witness
Segregated Witness (abbreviated as SegWit) is an implemented protocol upgrade intended to provide protection from transaction malleability and increase block capacity. SegWit separates the witness from the list of inputs. The witness contains data required to check transaction validity but is not required to determine transaction effects. Additionally, a new weight parameter is defined, and blocks are allowed to have at most 4 million weight units (WU). Non-witness and pre-segwit witness bytes weigh 4 WU, but each byte of Segwit witness data only weighs 1 WU, allowing blocks that are larger than 1 MB without a hardforking change.
After the successful activations of OP_CLTV and OP_CSV, SegWit was the last protocol change needed to make the Lightning Network safe to deploy on the Bitcoin network.
Because the new witness field contains Script versioning, it is also possible to make changes to or introduce new opcodes to SegWit scripts that would have originally required additional complexity to function without SegWit.
History and Activation
During 2016 and 2017 activation of segregated witness was blocked by miners for political reasons by exploiting a flaw in the BIP 9 activation mechanism. On a technical level, the consensus rules of bitcoin are controlled by the economic majority not the miners, so the deadlock was possible to solve by creating a user activated soft fork BIP 148 where the economic majority would bypass the blocking miners and activate segregated witness on their own. This required some coordination amongst the economic majority, but was ultimately successful, activating Segwit on Bitcoin soon after 1st August 2017.[1]
Nested SegWit
Nested SegWit is a Segregated Witness output wrapped in a P2SH script so that senders who only understand Base58 P2SH addresses can still pay a SegWit receiver. The two common forms are P2SH-P2WPKH (a version-0 public-key-hash witness program inside P2SH) and P2SH-P2WSH (a version-0 script-hash witness program inside P2SH). On mainnet the address is a Base58Check P2SH string beginning with 3. Nested outputs are larger than native witness outputs and were a compatibility step after the SegWit soft fork.
See Also
- BIP 141 Segregated Witness (Consensus layer)
- BIP 143 Transaction Signature Verification for Version 0 Witness Program
- BIP 144 Segregated Witness (Peer Services)
- BIP 145 getblocktemplate Updates for Segregated Witness
- BIP 147 Dealing with dummy stack element malleability
- BIP 173 Base32 address format for native v0-16 witness outputs
- Segregated Witness Benefits
- Segregated Witness Wallet Developer Guide
- Wikipedia: SegWit
