What is SegWit and the Lightning Network

What is Segregated Witness (SegWit)?

Segregated Witness (SegWit) refers to a change in the transaction format of Bitcoin. Its stated purpose as a protocol upgrade was to protect against transaction malleability and decrease transaction times by increasing block capacity. Transaction malleability refers to the possibility that tiny pieces of transaction information could be changed, invalidating new cryptocurrency blocks.
It was also intended to speed up the validation process by storing more transactions in a block.

Understanding Segregated Witness

The Bitcoin Network consists of thousands of computers that work as validators for the blocks created by miners. These computers are called 'nodes', which each keep a complete record of every transaction. This record is called a 'blockchain'.
The Bitcoin Network faced several problems as it matured. One was that more transactions were occurring, which added more blocks to the chain. Blocks are created every 10 minutes and used to be constrained to a maximum size of one megabyte (MB). Due to this constraint, only a certain number of transactions could be added to a block.
The number of transactions being conducted, represented by the blocks, was weighing down the network and causing delays in processing and verifying transactions. In some cases, it took hours to confirm a transaction was valid. Without SegWit's implementation, Bitcoin transaction validation would have slowed to a crawl as the cryptocurrency grew in popularity and the number of transactions increased.
The SegWit protocol divides the transaction into two segments. The unlocking signature (the 'witness' data) is removed from the original portion, but it remains a part of the blockchain as a separate structure at the end. The original portion holds the sender and receiver data, while the separate structure at the end (the 'witness' structure) contains scripts and signatures.
As a result of this segregation of data, more space is created and more transactions can be added to the blockchain.

Goals of SegWit

To understand the goals behind SegWit's implementation, it's essential to understand what's going on behind the scenes that makes it useful.

The main issue that SegWit addressed

When one user sends another user some Bitcoin, two pieces of information are required: a public address and a private key. A public address is a digital identifier for the entities involved in the transaction. Every user has a public address to receive and send Bitcoin, and the entire network can see these addresses. Private keys cannot be seen — they are used as verification that the public addresses belong to a user.
On a basic level, SegWit is a process that changes the way data are stored, therefore helping the Bitcoin network to run faster.
The process for transferring bitcoin starts when one user broadcasts a request to the network. This request includes the user's public address, the amount of bitcoin being sent, and a transaction fee for the miners.
Next, miners process the transaction; information from both users is encrypted, which means the data is turned into a line of computer code called the transaction ID. At this point, the transaction is queued. Transactions are added to the queue until the block limit is reached and a block is created.
Finally, the block is broadcast to the nodes; if more than half of all nodes agree that the information is valid, the block is confirmed and added to the blockchain. At this point, the bitcoin has successfully been transferred between users.
Over time, the network began to experience a slowdown in the number of transactions it could process as Bitcoin became more popular. Developers traced this issue back to the size limit of the blocks within the blockchain.
SegWit was formulated by Bitcoin developer Pieter Wuille. Wuille is also the co-founder of Blockstream, a software company specializing in digital security for financial services.

How SegWit addressed the issue

SegWit was the solution to a blockchain size limitation problem that reduced Bitcoin transaction speed. Bitcoin developer Dr. Pieter Wuille suggested that to solve this problem, the digital signature of the transaction witness needed to be segregated from the transaction data. Bitcoin transitioned to a block weight limit under SegWit of four million weight units (WU). A block that does not use SegWit holds one million WU, while one that uses SegWit has a limit of four million WU. Because old blocks were limited to one MB, many cryptocurrency fans believe that one MB equals one million WU (the non-SegWit block limit) and then correlate the four million WU limit to an increase of block size to four MB. While there was a block size increase following SegWit's adoption, the limit is not in megabytes.
For example, block 720399 was mined on Jan. 25, 2022. It had a size of 1.558 MB but was 3.993 million WU. Block 720340 was mined 21 minutes later and was 1.457 MB with a weight of 3.993 million WU. Earlier the same day, a block was mined with a size of 1.188 MB, with 3.993 WU. This demonstrates that there is not necessarily a size limit in megabytes, but a limit based on the weight, taking the block's base size and total size into account. This creates more space for data, which increases the speed of transaction validation.
SegWit also paved the way for Bitcoin to enable smart contracts and upgrade to another version, Taproot. Is SegWit secure?
SegWit enhances the security of Bitcoin's blockchain by preventing transaction malleability — the ability to change small pieces of information in a block.

Why was SegWit a good idea?

The cryptocurrency community still debates whether SegWit is good or bad, but security enhancements and decreased transaction times benefit the blockchain, miners and nodes that accept it. SegWit led to the implementation of Taproot, an upgrade to Bitcoin built upon SegWit that allows for even faster validation.

Is SegWit a Soft Fork?

SegWit is a soft fork of the Bitcoin blockchain. Soft forks are changes that do not create a new blockchain, while a hard fork does.
1) Investopedia. By JAKE FRANKENFIELD Updated January 25, 2022. Reviewed by SOMER ANDERSON