Segregated Witness
Segregated Witness (abbreviated as SegWit) is an implemented protocol upgrade intended to provide protection from transaction malleability and increase block capacity. SegWit defines a new structure called a witness that is committed to blocks separately from the transaction merkle tree. This structure contains data required to check transaction validity but is not required to determine transaction effects. In particular, signatures and redeem scripts are moved into this new structure, which does not count towards the traditional 1 MB block size limit. Instead, a new weight parameter is defined, and blocks are allowed to have at most 4 million weight units (WU). A byte in the original 1 MB zone of the block weighs 4 WU, but a byte in a witness structure only weighs 1 WU, allowing blocks that are technically 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 witness structure contains Script versioning, it is also possible to make changes to or introduce new opcodes to SegWit scripts that would have originally required a hardfork to function without SegWit.
Question: "How do I get cheaper transactions?"
One of the features made available by segwit is a larger maximum block size. Since a block can hold more data, transactions that can use that new space may be cheaper than they would if the older and smaller maximum block size was still enforced. To get cheaper transactions, you have to:
- Install a SegWit-supporting wallet.
- Receive money on new SegWit addresses, which start with 3. You must generate new addresses; your old addresses will never be SegWit addresses. Note that not all addresses starting with 3 are SegWit addresses, and it is impossible to tell just from looking at an address whether it is a SegWit address.
- Whenever you spend BTC which you have received via SegWit addresses, you will receive the SegWit discount. If you send a transaction spending some BTC received via non-SegWit addresses and some BTC received via SegWit addresses, you will receive a partial discount. The destination address doesn't matter.
There are no compatibility issues: non-SegWit wallets can send BTC to SegWit addresses, and SegWit wallets can send BTC to non-SegWit addresses.
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 bypassing the blocking miners and activate segregated witness on its own. This required some coordination amongst the economic majority, but was ultimately successful as the miners caving in and activated segregated witness ahead of time which was added to bitcoin soon after 1st August 2017, the BIP 148 flag day.
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