Bitcoin users often ask, what is Segwit? Segwit is an upgrade to the Bitcoin network introduced in August 2017. This post explains exactly what Segwit is, why it’s needed and how it can help in scaling Bitcoin to mass adoption.
What Is SegWit? Watch This Video to Learn About Segregated Witness
What is Segwit Summary
Segwit is an upgrade to the Bitcoin protocol that separates the digital signature (also known as “the witness”) from the transaction. This creates a fix to several issues with the Bitcoin protocol and also allows for more transactions to fit within a 1mb block.
That’s Segwit in a nutshell. If you want a more detailed explanation, keep on reading. Here’s what I’ll cover:
Key Takeaways
- SegWit (Segregated Witness) is a Bitcoin upgrade introduced in August 2017 to improve scalability and fix transaction malleability.
- It separates the digital signature from the transaction, allowing more transactions to fit within a block.
- SegWit enables second-layer solutions like the Lightning Network and helps reduce fees.
- It is a soft fork, meaning it remains compatible with older Bitcoin transactions.
- SegWit transactions are faster and more cost-efficient than legacy transactions.
What Is Segregated Witness (SegWit)
Segwit, short for Segregated Witness, is an upgrade to the Bitcoin network that aims to solve several issues. It was first introduced by Developer Pieter Wiulle at the Scaling Bitcoin conference in December 2015.
Understanding Segregated Witness (SegWit)
Segregated Witness, or SegWit, is a Bitcoin upgrade introduced in 2017 to improve transaction speed and security. It works by separating digital signatures from the main transaction data, making transactions smaller and allowing more of them to fit into each block.
Before SegWit, Bitcoin transactions included digital signatures inside the main block, taking up a lot of space. By moving these signatures, called witness data, outside the main block, SegWit frees up room for more transactions. Thus reducing congestion and lowering fees.
Another major benefit of SegWit is that it fixes transaction malleability, a problem that allowed transaction IDs to be changed before confirmation. This fix made second-layer solutions like the Lightning Network possible, enabling faster and cheaper Bitcoin payments.
Bitcoin’s Scalability Issue
Bitcoin transactions are written on an immutable ledger known as the Blockchain. It’s called “blockchain” because transactions are bundled together into blocks that are chained from one to the other in order to determine their order.
These blocks of transactions are limited in capacity up to 1mb. As a result, a Bitcoin block is able to accommodate around 2700 transactions on average.
This creates a problem when a lot of people are trying to send Bitcoins (like during price rallies), since a long queue is formed of transactions waiting to enter the blockchain.
While Visa routinely processes around 1,700 transactions per second, Bitcoin can process only about 5, making it unscalable for mass adoption. In order for Bitcoin to truly become usable on a worldwide scale, it needs to find a way to increase its transaction capacity.
Transaction Malleability Issue
Another issue Bitcoin has is transaction malleability.
Every Bitcoin transaction has 3 parts: who sent it (also known as input), who receives it (output), and a digital signature that verifies the sender is eligible to send the coins.
It turns out that Bitcoin’s code allows digital signatures to be altered when a transaction is still unconfirmed.
The signature alteration is done in a way that if you run a mathematical check on it, it is still valid by the network. However, when you run a hashing algorithm on it, it gives a different result.
Let me explain with an example:
For the sake of simplicity, let’s say that the signature value was “3”, but instead of “3,” I changed it to “03” or “3+7-7”. Mathematically, it’s still the same value, so it’s a valid signature, but if I hash these different versions, I will get different results since hashing depends on how you write the value and not the value itself.
Since the hash is the transaction’s identifier in the blockchain, this means I can effectively change any transaction ID to a different ID, and it will still be valid.
Creating a new transaction ID for an existing transaction can be problematic for a number of reasons:
- If you want to build second-layer solutions on top of the Bitcoin network, like the Lightning Network, you need to make sure no one can alter the first layer since it relies on it.
- Altering TX IDs can cause issues if you’re spending or accepting unconfirmed funds.
To simplify things, let’s use an example of how someone can exploit the transaction malleability issue:
Alice pays Bob in transaction X, which is unconfirmed. Bob uses that unconfirmed payment to pay for a product online from Charlie (transaction Y). Charlie did not wait for any confirmation on transaction Y and sent Bob his product.
Bob maliciously malleates Alice’s payment through some technical tinkering, and her transaction gets confirmed with a different TX ID.
Transaction Y is now invalid since it relies on the original TX ID of transaction X, that no longer exists. Charlie has not been paid and has already delivered the goods.
Additional Issues
While the two issues I’ve mentioned above are the most burning ones, Segwit addresses a variety of other technical issues that don’t always affect the end user directly.
Here’s a complete list of the issues Segwit solves:
- Linear scaling of sig hash operations
- Signing of input values
- Increased security for multisig via pay-to-script-hash (P2SH)
- Reducing UTXO growth
- Script versioning
- Efficiency gains when not verifying signatures
- Block capacity/size increase
- Moving towards a single combined block limit
A complete explanation of all of these issues can be found here.
How Segwit Works
Segwit is a Block Size Increase
Segregated Witness is a proposed change to how blocks are structured. Non-segwit blocks, also known as legacy blocks, have a total of 1mb space for all of the block data (inputs, outputs, signatures, etc.).
Segwit blocks, on the other hand, are, in fact, larger blocks (up to 4mb) that consist of a base transaction block and an extended block. So contrary to popular opinion, Segwit, just like Bitcoin Cash, is indeed a block size increase.
Segwit blocks move the digital signature and other data (known as “the witness”) outside of the base transaction block. The witness data will still be transmitted, but it is placed inside the extended block.
The base transaction block includes the information about the sender and the receiver. The witness data is left blank and, therefore, doesn’t take up any space. This allows for more transactions to fit inside the 1mb block.
The extended block (the additional 3mb) includes all of the witness data that isn’t mandatory in the base transaction block.
The new block format Segwit introduces achieves two major goals:
- It moves the digital signature outside of the base transaction block. This way, if someone changes the signature on the transaction, it will not affect the transaction ID. This, in effect, solves the transaction malleability issue.
- It shrinks down the base transaction data. Since the witness data takes up to 65% of the transaction size, moving it outside of the base transaction block allows more transactions to fit inside a 1mb block.
Segwit is a Soft Fork
If Segwit is, in fact, a block size increase, you may be wondering why not just increase the block size to 4mb?
The reason is that developers wanted to avoid creating a hard fork in the Bitcoin network. Bitcoin’s protocol specifically states that blocks can’t exceed 1mb block. So, developers had to find a solution that will be accepted by both legacy and Segwit blocks.
A solution of a 1mb block with an “extension” of another 3mb is something that is still acceptable under the existing protocol.
Legacy nodes receive only the 1mb base transaction block without the extended block. They still consider them valid. Segwit nodes receive both the base and extended block (up to 4mb in total) and can validate the transactions in full.
While in theory, Segwit transactions can create a block up to 4mb in size, in practice, the average block size that includes Segwit transactions is around 2mb.
This backward compatibility is also known as a soft fork. This approach is much less risky since it doesn’t require nodes to update their software to support Segwit. It means that even if it takes years for all of the nodes to upgrade, the network will still function.
Calculating Block Weight
While legacy blocks are measured in size, Segwit blocks are measured in weight. Block Weight is a new concept introduced in Segwit, and it’s calculated on a per-transaction basis.
Each transaction has a “weight,” which is defined this way:
Base Tx size *3 + Full Tx size
Legacy transactions can’t strip away the witness data, so their weight will always be 4 times the TX size. For example, a legacy TX of 1000 bytes will have a weight of 1000*3 + 1000 = 4000.
Segwit transaction weights, on the other hand, are going to be less than 4 times the TX size. For example, a 1200-byte Segwit transaction comprised out of 400 bytes of witness data will have a weight of (1200-400)*3 + 1200 = 3600.
In short, the larger the witness data, the lighter the tx weight will be. This incentivizes miners to prefer lighter Segwit transactions over heavier ones since they can fit more of them inside a block.
Segwit vs. Legacy
Today, almost 70% of all Bitcoin transactions mined are Segwit transactions. When comparing legacy transactions to Segwit transactions, you can see the following differences:
- The max block size of a legacy transaction is 1mb, whereas segwit transactions have up to a 4mb block size. Here’s an example of a Segwit block that is over 2mb.
- Legacy transactions are still prone to malleability attacks.
- Legacy transactions are larger in size and, therefore, require higher network fees to get confirmed faster.
- Segwit addresses start with a “3,” while legacy addresses start with a “1”.
Pros and Cons of SegWit
Pros
- Lower transaction fees as smaller transactions reduce costs.
- Faster transactions by allowing more to fit in each block.
- Fixes transaction malleability to prevent ID changes.
- Supports the Lightning Network for quick and cheap payments.
- Backward compatible with older Bitcoin wallets and transactions.
Cons
- Not fully adopted as some wallets and exchanges still use legacy transactions.
- More complex for users needing to switch to SegWit-compatible wallets.
- Limited to Bitcoin and does not apply to other cryptocurrencies.
Best Segwit Wallets
Thanks to its advantages, more and more wallets support Segwit. Here are the top Segwit wallets around.
It’s important to note that if you have a legacy wallet and want to move to a Segwit wallet, you will need to create a brand new Segwit wallet and move all of your funds to its address. There’s no way to just upgrade your existing wallet.
Ledger
Ledger is a hardware wallet that allows you to sign transactions offline, therefore allowing greater security for your funds (since your private key has no access to the Internet). There are two main models – the Ledger Nano S and the Ledger Nano X.
Both models support both Segwit and legacy transactions. The Nano X is the newer model that supports a wider variety of coins and is also mobile-compatible.
TREZOR
TREZOR is another popular hardware wallet. The two TREZOR models are the TREZOR One and TREZOR Model T. Both wallets support Segwit and legacy transactions.
The TREZOR Model T is the newer model, which also has a touchscreen.
Exodus
Exodus is a free software wallet that is excellent for beginners due to its intuitive design. The wallet supports over 100 crypto assets and is available for desktop and mobile. Exodus supports both legacy and Segwit transactions. You can read my complete Exodus review here.
Electrum
Electrum is an open-source Bitcoin-only desktop wallet that supports both legacy and Segwit transactions.
The wallet is a bit hard to manage if you’re just starting out with cryptocurrencies but it offers a wide variety of options for controlling fees, managing funds, and signing transactions. You can read my complete Electrum review here.
Coinomi
Coinomi is a very popular multi-currency multi-platform wallet that supports over 1,170 crypto assets and is available for desktop and mobile. Coinomi supports both legacy and Segwit transactions.
If you’re looking for a mobile segwit wallet, this is probably the best choice overall. You can read my Coinomi review here.
Frequently Asked Questions
When was Segwit Activated?
What is SegWit2x?
Is Segwit backward compatible?
What is the Lightning Network?
Conclusion
Segwit is the first out of many upgrades that will gradually allow Bitcoin to scale for mass adoption. It’s a fundamental change that will allow further developments down the road.
Segregating the digital signature, or the witness, from the transaction block achieves several advantages, such as a smaller transaction size, malleability fixes, and more. As more and more wallets adopt Segwit, it will soon become the standard for any Bitcoin transaction.
What is SegWit?
What Does SegWit Mean in Crypto?
What Are the Benefits of SegWit?
Does Blockchain Support SegWit?
Can I Send BTC to a SegWit Address?
How Do I Know if My Bitcoin Address Is SegWit?
What is Bitcoin Native SegWit?
What is a SegWit Address?
In This Article
Free Bitcoin Crash Course
- Enjoyed by over 100,000 students.
- One email a day, 7 days in a row.
- Short and educational, guaranteed!
Why you can trust 99Bitcoins
Established in 2013, 99Bitcoin’s team members have been crypto experts since Bitcoin’s Early days.
Weekly Research
100k+Monthly readers
Expert contributors
2000+Crypto Projects Reviewed