A beginner-friendly introduction to Bitcoin’s SegWit, including what SegWit is, why it’s important, and what it achieves
When Satoshi Nakamoto designed Bitcoin, he stipulated that the capacity of each block should not exceed one million, and the number of transactions that can be recorded in each one million capacity is extremely limited. In the earliest days, the capacity of each block of one million was enough to cope with the transaction volume of the niche market, but when the number of Bitcoin players surged, it became particularly congested.
For example, according to statistics, the Bitcoin network updates a new block every ten minutes. Subject to the one million capacity, the number of transactions contained in each block does not exceed dozens of transactions at most. Currently, Bitcoin can process an average of seven transactions per second. That means under special circumstances, there's a backlog of tens of thousands of transactions on the Bitcoin blockchain, and the transaction fee for Bitcoin transfers is as high as tens of dollars. When the network is congested, Bitcoin transactions can even take several days to be packaged.
Therefore, users in the encryption circle urgently needed an efficient technical solution to solve the problem of slow Bitcoin transaction processing. This solution would help to make everyone's Bitcoin arrive faster and with a lower transaction fee (the fee paid to the miners).The solution arrived in the form of Segregated Witness (SegWit).
Introducing SegWit
SegWit technology was proposed by Bitcoin developer Pieter Wuille and other Bitcoin Core contributors in 2015 as a solution to the problem of transaction processing speed. In 2017, SegWit was officially used in the soft fork on the Bitcoin network, and the information processing capacity of a single block of Bitcoin was also increased by 1.7 times.
At present, the three major currencies — Bitcoin, Litecoin and Bitcoin cash — have all started to adopt SegWit. The benefits of adopting SegWit mainly include expanding block capacity, increasing transaction speed, and optimizing transaction scalability.
The technical principles of SegWit
Let’s take a look at the technical principles and implementation ideas of SegWit.Professional players know that every piece of transaction information in Bitcoin is divided into two parts: basic transaction data and witness data. Transaction data records the account balance, and witness data verifies the user's identity.
Users generally care most about the core information related to assets such as the account balance, and the verification of user identity does not need to occupy too much cost in the transaction. In simple terms, the recipient of the transfer only needs to confirm that the asset is available, and does not need to know the details of the sender.
However, in the Bitcoin transaction structure, witness data — the signature information — takes up a lot of storage space, which in turn delays transfer efficiency and increases packaging costs. SegWit technology helps to extract the witness data from the transaction information and store it separately, which speeds up the transaction.
The main advantages of SegWit
Increased block capacity
According to statistics, signature information can occupy up to 65% of the space in a Bitcoin transaction block. It's possible that after adopting SegWit, the original block storage space will be released, and more transaction information can be processed.
Faster transaction rate
Similar to the idea of Ethereum layer-2, Bitcoin data is processed in layers to achieve the purpose of increasing the transaction rate. After adopting SegWit, the Bitcoin transaction system will concentrate more computing power and larger storage on the processing of transaction information. Compared with the previous burden, the burden is greatly reduced, and the transactions per second (TPS) rate will only increase, in theory. Data shows that after adopting SegWit, the average cost per transaction drops to $1.
Favorable Lightning Network
The Lightning Network is the most discussed Bitcoin layer-2 protocol expansion solution, designed to solve the scalability problem of Bitcoin off-chain.
The Lightning Network attempts to create a new layer of network on the Bitcoin blockchain, and at the same time set up a payment channel. As a result, under any extreme circumstances, large transfer transactions can be completed quickly and smoothly, which can be understood as off-chain data processing. However, SegWit quickly processes the data with the highest priority on the chain.
Relieving pressure for the implementation of the Lightning Network actually indirectly creates conditions for the Lightning Network.
It is worth mentioning that under the technical framework of SegWit, the transaction data and signature data are completely separated. Across the entire transaction processing system, the user's signature data is also excluded, so there's no possibility of transaction information being tampered with. One click eliminates the possibility of wrong information being permanently recorded on-chain. It also has positive benefits for the expansion and application of the transaction information repair program.
Additionally, SegWit is also seen as the first precursor to Bitcoin ordinals, expanding the limit on how much arbitrary data can be placed in a transaction, which allows for inscriptions to be engraved on each satoshi of Bitcoin. In 2021, Taproot created a system that makes it easier to store arbitrary witness data, and continued to expand the data limit placed in a Bitcoin transaction, enabling the birth of the Bitcoin ordinals non-fungible token that exists today.
How SegWit is applied
For ordinary users, there are three main benefits brought by SegWit technology:
Safer: higher security than ordinary addresses
Faster: expandable block capacity and faster transaction checking
Cheaper: transaction fees are lower than ordinary wallet addresses
So, how does this technology apply to ordinary users? Looking at your own wallet, if you use the isolated wallet address to complete the acceptance of Bitcoin transfers, you can actually enjoy the benefits explained above. Data collected at the end of August 2020 showed that the utilization rate of Bitcoin’s SegWit had reached 67%, meaning the current data must have reached a higher level.
At present, the address format of Bitcoin is mainly divided into four types:
Legacy
Legacy (P2PKH) format (addresses starting with 1) — traditional addresses.
Example: 1Fh7ajXabJBpZPZw8bjD3QU4CuQ3pRty9uBitcoin's original address format, which is still in use today.
P2PKH means Pay To PubKey Hash (Pay To Public Key Hash).
Nested
Nested (P2SH) format (some address starting with 3) — multi-signature address.
Example: 3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQXP2SH (Pay-to-Script-Hash), payment script hash, that is, Bitcoin transaction input and output scripts, using redemption scripts and redemption script hashes.
Its address structure is similar to P2PKH, but it supports more complex functions than traditional addresses. P2SH script functions are most commonly used with multi-signature addresses, which can specify multiple digital signatures to authorize transactions. For example, an address starting with 3 is controlled by three people, and any two of them agree to initiate a transfer.
The above two addresses are traditional transaction transfer addresses and do not use segregated witness technology. Two mainstream segregated witness addresses are introduced below.
Nested SegWit (P2SH) format (addresses starting with 3) — segregated witness compatible address.
Example: 3KF9nXowQ4asSGxRRzeiTpDjMuwM2nypANAddresses starting with 3.
Because the P2SH method is used for packaging, the SegWit compatible address also starts with 3, which can be recognized by old nodes.
You don't need to know whether the Bitcoin address starting with 3 is a multi-signature address or a segregated witness compatible address. You only need to know that the address starting with 3 is widely supported, and you can send Bitcoin to addresses starting with 1 and bc1.
Native
Native SegWit (Bech32) format (address starting with bc1) — native segregated witness address.
Example: bc1qf3uwcxaz779nxedw0wry89v9cjh9w2xylnmqc3
The Bech32-encoded address is an address format specially developed for SegWit. Bech32 was defined in BIP173 at the end of 2017. One of the main features of this format is that it is case-insensitive (the address only contains 0-9, az), so it can effectively avoid confusion and be more readable when inputting.
Since fewer characters are required in the address, the address uses Base32 encoding instead of the traditional Base58, making calculations more convenient and efficient. Data can also be stored more tightly in QR codes.
Bech32 provides higher security, better optimized checksum error detection code, and minimizes the chance of invalid addresses. Bech32 addresses are natively compatible with SegWit. No additional space is required to put SegWit addresses into P2SH addresses, so by using Bech32 format addresses, the handling fee will be lower.
Bech32 addresses have several advantages over older Base58 (Base58Check encoding used to encode byte arrays in Bitcoin into human-encodable strings) addresses. With Bech32 addresses, QR codes are smaller, more error-proof, secure, and case-insensitive. They also consist of only lowercase letters, making them easier to read and understand when typing.
Native P2WPKH / Native P2WSH (Bech32) format (address starts with bc1q) — Native segregated witness address.
Native P2WPKH example: bc1qmgjswfb6eXcmuJgLxvMxAo1tth2QCyyPYt8shzNative
P2WSH example: bc1q09zjqeetautmyzrxn9d2pu5c5glv6zcmj3qx5axrltslu90p88pqykxdv4wj
For version 0 segwit addresses, they always start with bc1q. With this generation of Pay-to-Witness-Public-Key-Hash (P2WPKH) address, the length of the P2WPKH address is fixed at 42 characters.
With the Pay-to-Witness-Script-Hash (P2WSH) address, the length of P2WSH address is fixed at 62 characters.P2WPKH is usually used in ordinary addresses, and P2WSH is usually used in multi-signature addresses.
In 2019, it was found that if the last character of a Bech32 address is P, and if one or more Qs are accidentally entered later, it can still pass the checksum verification and will not receive an input error prompt. The wallet software will assume that the address was entered correctly and allow the Bitcoins to be sent to the wrong address, making the Bitcoins unspendable, as explained above.
The good news is that Bech32 is only used for SegWit, and SegWit addresses have a length limit — they can only be 20 bytes or 32 bytes. Fortunately, if you type an extra Q after an address that is 20 or 32 bytes long, the entered address will be invalid because it exceeds the length limit. The wallet will see this problem and refuse to send Bitcoins.
It was originally suggested to introduce a similar address length limit for Taproot, but the solution mentioned below removes this need. A flexible address length is more helpful for us to improve Taproot in the future.
P2TR
P2TR (Bech32m) format (address starts with bc1p) — Taproot address.
Example: bc1pqs7w62shf5ee3qz5jaywle85jmg8suehwhOawnqxevre9k7zvqdz2mOn
To fix the Bech32 bug, a new standard called Bech32m was proposed. Bech32m is actually a very simple change: an extra digit is added to the Bech32 checksum formula to make sure any additional characters will generate an invalid checksum.
This new standard only applies to Taproot addresses and future addresses. Nothing has changed for SegWit addresses as they are already protected with a 20 or 32 byte length limit.
To fix the above shortcomings of Bech32, Bech32m addresses are proposed in BIP0350:
For version 0 native segwit addresses, use previous Bech32
For native segwit addresses with version 1 (or higher), use the new Bech32m
For Bech32m addresses, they always start with bc1p when the version is 1 (i.e. Taproot addresses).
The subtle differences between addresses
Looking more broadly, we can see other subtle differences between different addresses:
SegWit compatible addresses (starting with part 3) save 24% transfer fees compared with traditional addresses (starting with 1)
Native SegWit addresses (starting with bc1) save 35% transfer fees compared to traditional addresses (starting with 1)
The SegWit address (starting with bc1 and part 3) can save up to 70% of the transfer fee than the multi-signature address (beginning with part 3)
Taproot address supports BTC NFT holding and Ordinals NFT, and the transfer fee is similar to the beginning of 3
The final word
SegWit is an important development for Bitcoin towards increasing the number of transactions per block the Bitcoin network could process. Additionally, it addresses a rare exploit relating to transaction malleability and adds greater programmability to Bitcoin, allowing further scaling solutions like Bitcoin’s Lightning Network.
Today, the OKX wallet has already supported users to adopt the isolated witness address including Bitcoin, Litecoin, and Bitcoin Cash when transferring and recharging, optimizing the user experience, reducing the usage fee rate, and increasing the transfer speed. At the same time, the OKX wallet has also fully supported the Taproot address that ordinals BRC-20 and BTC NFT rely on.
© 2024 OKX。 本文可以全文复制或分发,或使用不超过 100 字的摘录,前提是此类使用仅限非商业用途。对全文的复制或分发必须明确注明:“本文版权所有 © 2024 OKX,经许可使用。” 允许的摘录必须标明文章标题并注明出处,例如“文章标题,作者姓名 (如适用) ,© 2024 OKX”。不允许对本文进行任何衍生作品或其他用途。
相关信息:数字资产交易服务由 OKX Australia Pty Ltd (ABN 22 636 269 040) 提供;关于衍生品和杠杆交易的信息由 OKX Australia Financial Pty Ltd (ABN 14 145 724 509,AFSL 379035) 提供,仅适用于《2001年公司法》(Cth) 下定义的大额客户;其他产品和服务由提供这些产品和服务的相关 OKX 实体提供 (请参阅服务条款)。
本文所含信息仅为一般性信息,不应视为投资建议、个人推荐或购买任何加密货币或相关产品的要约或招揽。在做出决策前,您应自行进行研究并寻求专业建议,确保理解相关产品的风险。过去的表现并不代表未来的结果,切勿承担超过您能够承受的损失风险。如需了解更多信息,请阅读我们的服务条款和风险披露和免责声明。
本内容翻译与英文版本不一致时,以英文版本为准。