Creating a Comprehensive Guide to Bitcoin SegWit Transactions
Written on
Chapter 1: Understanding Bitcoin SegWit
Bitcoin's Segregated Witness (SegWit) is a crucial protocol enhancement that has significantly improved transaction scalability since its introduction in August 2017.
SegWit, an acronym for Segregated Witness, serves as a pivotal upgrade to the Bitcoin network aimed at addressing transaction malleability and enhancing block capacity. While the implementation of SegWit has sparked some debate in the blockchain community, its adoption has recently gained momentum. Notably, the percentage of transactions utilizing SegWit surged from 40% in September 2019 to 60% in the following month.
In this article, we will delve into the mechanics of SegWit, examine its adoption trajectory, and highlight the advantages and disadvantages it introduces to the Bitcoin ecosystem. We will also touch on the controversies surrounding SegWit and compare its wallet address formats with traditional legacy wallets.
How Does SegWit Function?
To grasp how SegWit operates, it helps to contrast SegWit blocks with traditional non-SegWit blocks, also referred to as legacy blocks.
Legacy blocks impose a combined size limit of 1 MB for all transaction data, encompassing inputs, outputs, signatures, and scripts. Both SegWit and legacy blocks require a witness, essentially a digital signature that confirms the ownership of a wallet address and verifies that sufficient funds are available for transactions.
SegWit modifies this structure by storing witness data separately from the transaction Merkle tree. This adjustment allows the block size limit to effectively increase to 4 MB, as the base transaction block retains its 1 MB limit while the extended block can accommodate an additional 3 MB. Consequently, SegWit blocks can process more transactions per block compared to their legacy counterparts.
The Rationale Behind SegWit's Creation
Originally, SegWit was developed to combat a particular limitation of the Bitcoin network: transaction malleability. Every Bitcoin transaction on-chain consists of three components: the receiver (output), the digital signature, and the sender (input). Transaction malleability refers to an attack that targets digital signatures, allowing the signature of an unconfirmed transaction to be altered without modifying the transaction's underlying value.
Pieter Wuille introduced SegWit to counteract this vulnerability.
Understanding Transaction Malleability
Before SegWit's implementation, altering the digital signature of an unconfirmed transaction could create a new, fraudulent transaction ID, increasing the risk of deceitful transactions and undermining the security of BTC payments. This posed a challenge for merchants and could hinder the adoption of Layer 2 scaling solutions such as the Lightning Network.
Block Capacity Constraints
Interestingly, Wuille did not initially intend for SegWit to address Bitcoin's scalability issues; however, this unintended benefit emerged as a result of the protocol's design. By separating witness data from blocks, SegWit can reduce the amount of data stored in each block by up to 65% in some instances. This reduction leads to faster and cheaper Bitcoin transactions, though it does not entirely resolve scalability challenges.
SegWit Activation and Its Controversies
The activation of SegWit has been relatively protracted compared to other blockchain upgrades. Although the technology has existed for several years, legacy blocks continue to make up a significant portion of the Bitcoin network.
SegWit was incorporated into the Bitcoin Core roadmap in December 2015, with code completion occurring less than a year later. However, it wasn’t until August 2017 that it was activated on the Bitcoin network.
The initial activation plan required a supermajority of miners to endorse the upgrade. When this did not materialize, some community members proposed a User Activated Soft Fork (UASF), which would have created a division between SegWit users and those using legacy blocks. Ultimately, miners reached a consensus to activate SegWit just before the UASF was scheduled to occur.
Controversy Surrounding SegWit2x
SegWit was initially part of a two-phase protocol upgrade known as the "New York Agreement," with the second phase termed SegWit2x, aimed at increasing the block size limit from 1 MB to 2 MB. This would have lowered transaction fees while increasing data storage costs for node operators. However, due to disagreements within the Bitcoin community, the activation of SegWit2x was halted on November 8, 2017, just days before its scheduled launch.
Who Influences SegWit Adoption?
SegWit was designed to be compatible with the existing network protocol, necessitating only a soft fork for implementation. Thus, users have the flexibility to choose between legacy and SegWit blocks for their transactions. The pace of SegWit adoption ultimately relies on Bitcoin adopters, including wallet providers, exchanges, and end-users.
Support for SegWit Over Time
The following timeline illustrates when popular Bitcoin wallets and exchanges began supporting SegWit:
- Ledger — August 2017
- Trezor — August 2017
- Bitpanda — November 2017
- BitPay — January 2018
- Coinbase — February 2018
- Gemini — April 2019
- Huobi — August 2019
- KeepKey — August 2019
- Bitfinex — November 2019
- BitMEX — December 2019
Utilizing SegWit: Advantages and Disadvantages
Choosing to adopt SegWit hinges on whether its benefits outweigh potential drawbacks. Here’s a summary of the consensus within the Bitcoin community, although some debates persist.
Advantages
- Reduced Fees: Generally, SegWit transactions tend to be less expensive than those using legacy blocks. A February 2018 analysis indicated that SegWit in P2SH saved 26%, while Native SegWit saved 38% compared to traditional transactions.
- Faster Transactions: SegWit enhances Bitcoin scalability. While legacy blocks can handle approximately 3 transactions per second, SegWit blocks can process around 7 transactions per second. Though this is a modest improvement, it signifies progress.
- Enhanced Security: SegWit effectively eliminates the risk of digital signature alterations for unconfirmed transaction data, contributing to the immutability of network data.
- Interoperability: Users can seamlessly transfer BTC between legacy and SegWit addresses.
Disadvantages
- Limited Adoption: Some exchanges, wallets, and platforms have yet to integrate SegWit.
Common Bitcoin Address Formats Explained
When engaging in BTC transactions, you may come across various address formats. The differences, although seemingly minor, have significant implications for how transactions are processed on the blockchain.
Legacy (P2PKH)
Pay To PubKey Hash (P2PKH) is the original format for BTC transactions, introduced in January 2009. While it is not SegWit-compatible, it can be used to send BTC to SegWit addresses. P2PKH validates spendability by ensuring that a private key matches the corresponding public key hash, which serves to enhance security. P2PKH addresses start with the digit 1.
Nested SegWit (P2SH)
Pay To Script Hash (P2SH), created by developer Gavin Andresen, became a standard script on the Bitcoin network in April 2012. P2SH is not exclusive to SegWit but can support Nested SegWit via Pay to Witness Public Key Hash (P2WPKH). P2SH enhances transaction privacy, reduces sender costs, and decreases the size of the UTXO set, commonly utilized in multisig transactions. P2SH and P2SH-P2WPKH addresses commence with the number 3.
Native SegWit (Bech32)
Introduced in March 2017, Bech32 addresses are unique in that they are case-insensitive, minimizing the likelihood of errors during entry. Unlike previous address formats, Bech32 addresses exist solely on the Bitcoin network, eliminating concerns about mistakenly sending funds to the wrong blockchain. As the name implies, SegWit Native is designed to operate seamlessly with SegWit blocks, with Bech32 addresses beginning with "bc1."
This video provides a tutorial on creating a SegWit Bitcoin wallet using the Electrum Wallet version 3, showcasing the steps and features involved.
In this video, the differences between SegWit and Native SegWit are explored, helping users understand which option to choose for their transactions.