What is SegWit? An introduction to Bitcoin’s on-chain scaling approach | Blockchain Glossary| OKX Academy

A beginner-friendly introduction to Bitcoin’s SegWit, including what SegWit is, why it’s important and what it achieves

SegWit is the name of a Bitcoin upgrade implemented via a soft fork in August 2017. It aimed to increase the number of transactions per block the Bitcoin network could process. Additionally, it addressed a rare exploit relating to transaction malleability and added greater programmability to Bitcoin, enabling further scaling solutions like Bitcoin’s Lightning Network.

In this beginner-friendly introduction to SegWit, we explain what SegWit is, its importance and the upgrade’s background. We also assess SegWit’s impact since its adoption.

Table of contents:

What is Bitcoin’s SegWit?

SegWit — short for “segregated witness (consensus layer)” — is a scaling mechanism implemented on the Bitcoin network in August 2017. It aimed to reduce the size of transaction data so that more transactions could be included in each block without raising the block size limit via a hard fork.

In addition to increasing Bitcoin’s transaction throughput, SegWit also addressed a couple of other issues on the network. Firstly, the upgrade mitigates a rare exploit in which an attacker can create a new transaction ID before a transaction is mined. They can then plausibly claim to have never received their funds because the sender will not recognize their transaction due to it appearing under a different ID. Under SegWit, calculating the transaction ID does not require transaction signature data. Therefore, if a bad actor alters signature data, the ID remains the same.

Another improvement SegWit brought to Bitcoin was increased programming flexibility. This effectively enabled Layer-2 scaling solutions like the Lightning Network. The Lightning Network requires more complex transactions that are dependent on one another. Without the transaction malleability fix, transactions dependent on others can become invalidated by changing the signature data and, therefore, the transaction ID. Since SegWit separates transaction signatures from transaction data and computes the ID from the latter, a change to the signature data cannot invalidate future transactions.

The Bitcoin industry did not universally support SegWit. Before its activation, some championed scaling the network by increasing the block size limit via a hard fork. Eventually, this faction would introduce a block size increase. The resulting hard fork created the Bitcoin Cash network and its native crypto asset, BCH.

While not all stakeholders in the Bitcoin network upgraded to SegWit immediately, the fact that it was implemented as a backward-compatible change meant that its own activation did not split the network. As opposed to a hard fork, such a change is known as a soft fork, which does risk splitting a network.

A brief SegWit history

SegWit’s code was published as Bitcoin Improvement Proposal 141 in December 2015. The BIP’s authors were developers Eric Lombrozo, Johnson Lau and Pieter Wuille. It was later introduced into the Bitcoin Core client in October 2016. Yet, few Bitcoin miners approved of the change and did not signal to support SegWit.

A report in Bitcoin Magazine suggests that a faction of miners were opposed to SegWit because they were benefiting from an exploit known as “AsicBoost” that gave them 20% improved efficiency, making them more profitable.

In May 2017, a group of the most powerful Bitcoin miners and companies met and drafted what would later be called the New York Agreement. They agreed to activate SegWit and increase the block size limit as part of the change — an upgrade referred to as “SegWit 2X.”  Unlike the SegWit version implemented in the Core software the previous year, the change was not backward-compatible with previous Bitcoin software versions and risked splitting the network.

The New York Agreement had SegWit 2X’s activation scheduled for November 2017. Yet, many within the Bitcoin community felt that a clandestine meeting of companies did not represent them and perceived SegWit 2X as a threat to crypto’s overall decentralized ethos.

Pseudonymous Bitcoin developer Shaolin Fry came up with a solution known as a user-activated soft fork, or UASF. Essentially, node and wallet operators would activate SegWit and reject non-SegWit blocks. This would pressure miners into activating the upgrade because, without user support, mining for Bitcoin quickly becomes a futile operation.

The UASF wasn’t needed in the end, as the threat of it was enough to convince miners to signal SegWit support. Miners locked in SegWit on Aug. 9, 2017.

Ahead of SegWit’s activation, however, those most committed to scaling Bitcoin via a block size increase went their separate ways. A change to the network’s block size implemented by a group of so-called “big blockers” — i.e., miners that favored scaling via increasing the size of blocks in a way that was not backward compatible — resulted in the hard fork that created Bitcoin Cash.

The period was a tumultuous one for the Bitcoin network, and after the dust surrounding the hard and soft forks settled, BTC price spent the rest of 2017 rallying to a then all-time high of almost $20,000.

Following SegWit’s August 2017 activation, BTC rallied to its 2017 high. Source: CoinGecko

How does SegWit work?

SegWit functions by segregating a transaction’s witness data from the transaction data. In the legacy system, blocks contained transaction inputs (senders), outputs (receivers) and transaction signature data. With SegWit active, blocks are partitioned into a base block of 1 MB and an additional section that stores transaction data. The other section can store up to 3 MB of witness data.

Therefore, contrary to popular belief, SegWit actually is a block size limit increase. However, the increase was implemented in such a way that it did not risk splitting the network. Those that did not want to upgrade their nodes to SegWit can still participate in the Bitcoin network.

In legacy transactions, transaction data and signatures formed a single Merkle tree — i.e., a data structure formed by hashing different pieces of data together — from which a transaction ID was created. This meant that changing the signature data, which is possible before a transaction is mined, resulted in a different transaction ID.

Under SegWit, the transaction ID is not dependent on the signature data. Therefore, even if a malicious entity did manage to change a transaction’s signature, it would not impact any transaction IDs or invalidate any transaction dependent on a previous one.

Although the base block is still 1 MB, it can include the data from more transactions per block because, without the witness data, transactions are up to 65% smaller. This effectively enables miners to include a greater number of transactions in each block, scaling the Bitcoin network to more users.

In addition to increasing Bitcoin’s transaction throughput, SegWit also enables more complex transactions. Previously, transactions dependent on one another could be invalidated by exploiting the transaction malleability bug. With SegWit active, transaction IDs are no longer dependent on data that can be subsequently altered. Therefore, transactions with dependencies on other transactions cannot be invalidated. This enables additional scaling solutions, such as the Lightning Network.

SegWit address format

SegWit transactions use one of two address formats. This makes it very easy to determine if you are sending from a SegWit address or transacting with a wallet supporting SegWit.

Addresses that begin with a “3” are known as Pay to Script Hash, or P2SH, addresses. This is an older address format that is compatible with both legacy (or non-SegWit) and SegWit transactions. Wallets that do not support SegWit can still receive SegWit transactions using this address format. Transaction fees should be somewhat lower than legacy addresses when transacting with P2SH addresses.

Meanwhile, Bech32 addresses — also known as a native SegWit address — begin with “bc1.”  Transactions using Bech32 addresses use less data than their P2SH counterparts. This address format enables even more transactions per block, resulting in even lower transaction fees. However, it requires the wallets used to support SegWit, which requires a software upgrade.

Why is SegWit important?

SegWit addresses the rising transaction costs that Bitcoin developers and industry observers understood would limit the network’s adoption. When Bitcoin blocks are full, transactions wait in what’s known as the mempool.

Transactions remain in the mempool until a miner includes them in a block. The miner selects which transactions to include based on the transaction fee included. Transactions including a very small fee will wait in the mempool for a long time during periods of heavy congestion on the Bitcoin blockchain because miners will favor transactions with higher fee payments — as it results in greater profitability.

With SegWit, miners can include more transactions per block because the data stored in the 1 MB base block is smaller for each one than under the legacy format. This results in a greater block capacity and fewer transactions waiting in the mempool. With fewer transactions waiting, there is a greater chance of having a transaction included in a block with a lower fee. Therefore, the average transaction fee across the network will fall.

Additionally, SegWit enables extra scaling solutions built on layers above the main Bitcoin blockchain. The first and most famous today is the Lightning Network. The Lightning Network enables transactions to occur off-chain in payment channels. Because these transactions no longer need mining into a block immediately, fewer transactions are waiting to be mined, further alleviating the pressure for users to increase transaction fees.

For those that support SegWit, the upgrade is more favorable than increasing the block size limit via a hard fork. Firstly, a soft fork does not risk splitting the network, which could result in confusion among Bitcoin users.

Secondly, the upgrade does not force additional hardware demands on node operators. One of the more important qualities of Bitcoin is that anyone can operate the hardware required to reference the Bitcoin blockchain and confirm the validity of transactions themselves. A block size limit increase would require node operators to use more expensive hardware with additional memory resources, increasing network centralization.

Was SegWit successful?

Because it is an optional, backward-compatible upgrade, SegWit took a while to really impact the network. Although it was activated in August 2017, fees still reached levels that priced out potential Bitcoin use cases. At its 2017 height, the average transaction fee reached more than $55, making small transactions or payments economically infeasible.

The average BTC transaction fee spiked above $55 in 2017 after SegWit’s activation. Source: Glassnode

Although some ecosystem participants implemented the upgrade almost immediately, it took wallet providers and other service providers like exchanges a long time to implement SegWit. By late 2019, only half of all transactions used the new format. Today, more than 80% of transactions use SegWit.

The chart above shows that daily transaction fees paid in BTC have reduced considerably as SegWit has been adopted. Although the number of on-chain transactions processed per day has reached around 7% below the 2017 peak, fees paid have remained a small fraction of the 1,500 BTC paid to the network on Dec. 22, 2017. Total fees paid in a single day have not exceeded 300 BTC during more recent spikes.

In assessing SegWit’s impact, it’s important to remember that the upgrade made the Lightning Network possible. Launched as a beta version in 2018, the Lightning Network has seen tremendous growth. At the beginning of 2021, the scaling solution had a total capacity of just over 1,000 BTC. By April 2022, the network’s total capacity had grown to more than 3,650 BTC.

The Lightning Network’s overall capacity has increased to more than 3,650 BTC since its 2018 launch. Source: Glassnode

The number of Lightning Network channels has also increased over the same period. From 37,100 in early 2021, channels peaked at 86,500 in March 2022. Both metrics show strong growth of Lightning activity, which was only made possible by SegWit.

Evidently, SegWit has been a success in terms of both its impact on network fees and its support of more complex transaction types. In addition to the Lightning Network, more recent Bitcoin network upgrades, such as Taproot, build on SegWit to further optimize the network — and by addressing transaction malleability, the soft fork will enable innovations yet to be developed.


Not an OKX trader? Sign up and join us today.

Source: https://www.okx.com/academy/en/what-is-segregated-witness