Ultimate SegWit & Lightning Network Guide – The BTC Blog

In this guide, we wish to offer and overview of SegWit and the Lightning Network as complementary solutions to scale the bitcoin blockchain. In addition, we would like to present the BTC.com block explorer as a window into the Lightning Network.

Bitcoin is a revolutionary digital currency that could compete with VISA and MasterCard and eventually replace these giants.

However, to be able to challenge these financial service providers, the bitcoin network would need to scale and increase the number of transactions it can process per second to become a real challenger. To give an idea of the range, VISA processes almost 2000 transactions per second, whereas the bitcoin blockchain can only process between 3 to 7 transactions per second, within a 1 megabyte block limit.

This significant gap has led the bitcoin community to come up with the several Bitcoin Improvement Protocols (BIP) such as BIP141 Segregated Witness (SegWit) and the Lightning Network (LN) as potential answers to scale the bitcoin blockchain.

1. History

If Bitcoin is to replace VISA and MasterCard, how can it compete and scale in order to challenge those financial institutions?

As of 2010 and in 2015 especially, different initiatives to tackle bitcoin’s network scalability issues were heavily discussed within the bitcoin community. Segregated Witness or in short SegWit was first presented by Pieter Wuille in December 2015 at the Scaling Bitcoin workshops in Hong Kong. Later that month, Gregory Maxwell proposed a scaling roadmap, with SegWit featured as a central idea to scale the bitcoin network.

In addition to SegWit, the Lightning Network (LN), a second layer solution that uses payment channels to allow instant transactions and minimal fees for micro-transactions was being discussed as an additional answer to the matter of scalability. From the early stages of development, Joseph Poon and Thaddeus Dryja, urged for a soft fork in their LN white paper to solve the malleability issue and to enable second layer solutions. After some time and much discussion, the community agreed to implement BIP141 and the soft fork was activated on August 24th 2017.

The malleability issue was now solved, paving the way for the LN to develop itself. Several LN development team released their LN implementation in 2018, such as “c-lightning” in January by Blockstream, followed by “LND” in March by Lightning Labs’s and later “Eclair” by ACINQ. These various implementations are BOLT “Basis of Lightning Technology” compliant, a self imposed standard to ensure that all implementations can work with one another. Nodes are free to choose the implementation that suits them best, because if there are different implementations, there is just one LN protocol.

Overall, this has been an exciting period for supporters of off-chain scaling. SegWit combined with second layer solutions might allow the bitcoin blockchain to scale to ensure that Bitcoin can remain a decentralized, censorship resistant cryptocurrency that can challenge the established financial providers such as VISA and MasterCard while staying true to its core values.

2. BIP141 — SegWit

SegWit is a soft fork which changed the transaction format of Bitcoin. Thisbackward compatible upgrade was implemented on the bitcoin network as of August 2017. The goal of this upgrade was to improve the scalability of the bitcoin network.

In the past, a Bitcoin transaction would include transaction data and signature data. However, the signature data was bulky and took up to 65% of the space in the blocks. This would fill blocks with information which wasn’t useful in the long term. In addition, the signature data was vulnerable to manipulation which could cause transaction malleability. Basically, this meant that you could slightly modify the signature without the private key. This also meant that it was harder to build second-layer protocols such as the LN on top of the bitcoin blockchain. This is why the community interested in second layer solutions supported SegWit.

As such, the SegWit soft fork separated the transaction data from the signature data, keeping the signature data in extended blocks called “witness”. This freed up the blocks with more space, allowing miners to include more transactions in a block. The extended blocks (Witness signature data) acts as a side chain running in parallel along the bitcoin main blockchain.

Result:

  • Improved the scalability of the bitcoin network by increasing the number of transactions that a block can take.
  • Removed transaction malleability.

SegWit solved the transaction malleability, thereby enabling the LN, a second layer network consisting of micropayment channels, to hypothetically resolve the scaling problem by enabling virtually unlimited numbers of instant, low-fee transactions to occur off-chain.

3. Lighting Network [LN] ⚡️

In a nutshell, the Lightning Network [LN] allows payments to be securely routed across multiple peer-to-peer payment channels. Nodes on the LN are connected via these payment channels established on the underlying bitcoin blockchain.

3.1 Alice & Bob

Alice and Bob can open a payment channel, to transact a collection of signed IOUs between them. To establish a payment channel they both need to deposit funds in this channel. The deposit has to be more significant than the amount they wish to transact, otherwise the payment will not be able to go through. As such, if Alice wishes to send 1 Bitcoin to Bob, the channel needs to have at least 1 Bitcoin in funding to allow the payment to go through. In this regard, the funding of a payment channel represents the capacity to send funds.

To fund a channel, Alice and Bob have to both send a certain amount of Bitcoin to a multi-signature address. This address is temporary locked away until they choose to close the channel. They will then be able to transact, off-chain without any fees as long as they sign every transaction. Once they decide to close the channel, a single transaction representing the balance between them will be broadcasted on-chain to the bitcoin blockchain.

“Micropayment channels create a relationship between two parties to perpetually update balances, deferring the transaction broadcast to the blockchain in a single transaction netting out the total balance between those two parties.” The Bitcoin Lightning Network

Alice and Bob, create a payment channel to be able to transact off-chain on the LN. source

3.2 Bob the hop

On the LN, all payments channels are routed, as that they are connected to each other. So what happens when Alice wants to transact with Charlie, but she doesn’t have a payment channel with him? Well, Alice doesn’t need to open a channel with Charlie. In fact, since Alice already has an open channel with Bob and Bob has an open channel with Charlie she will be able to send funds to Charlie through Bob, using him as a hop.

The LN uses source routing, as the nodes decide how the transaction should be routed. A node chooses an optimal path from Alice to Charlie to ensure the lowest fees where each hop is encrypted. The LN is based on encrypted source routing, where each layer of the onion is connected but doesn’t know the full routing, it’s a “source based onion routed network. Indeed, a node will only know the previous and next hop, as it has no information on the whole path. Only the 1st node, knows it’s the first node and the last node knows that this is the end destination. In the future, the LN might implement different routing strategies.

3.3 User experience

Today, the user experience is a work in progress for the LN community, as opening a LN isn’t the smoothest crypto on-boarding.

Users should open different channels, with different balances of funding and use these various channels for particular purposes. In the long term, wallets would do all the heavy lifting such as opening and closing channels for the users, broadcasting the final balancing and ensure that channels are funded at all time.

As for merchants, they need to power their own node and to keep their nodes online at all time to be able to receive payments.

Merchants shouldn’t need to run a 24/7 service on their node. Security issue is another concern as well. To onboard more merchants, it’s very important to make it easier for customers to use Lightning Network. BTC.com will be releasing a watch tower service for the Lightning Network. This will reduce the burden to keep watching the blockchain.” Zhong Zhuang — Director of BTC.com

4. BTC.com block explorer, a window into the LN ⚡️

Blockchain technology is often praised for its transparency. How does it actually materialise itself? The transparency of a blockchain stems from the fact that the holdings and transactions of each public address are open to the public.

The BTC.com block explorer is a web tool that enables everyone to search and navigate the blocks of a blockchain. When researching on a block explorer, users can find detailed information about the blocks, addresses and transactions. With the BTC.com block explorer users can search all transactions that are recorded on-chain. They can look up LN transactions that occur on-chain, when a payment channel is opened or closed.

This is an example of a transaction broadcasting the opening or closing of a payment channel on the LN.

5. A bright future for the LN

The Lightning Network, alongside SegWit have been able to offer a viable solution to scale the bitcoin blockchain off-chain. As of today, almost 45% of the network has implemented SegWit, a remarkable steady growth across the ecosystem since it’s implementation in August 2017. In addition, the LN keeps on growing with 3265 public nodes, 11495 channels have been opened and the network has a total capacity of 87.59 Bitcoins.

7. Conclusion

The development of the crypto industry happens in several stages and with no central governance, the industry has been able to create and imagine new solutions for the crypto world of tomorrow.

Since 2015, SegWit and then LN have been in the center of all discussions as the possible panacea to solve the scalability issues of the bitcoin blockchain.

After one year, we can indeed observe some growth in the adoption of SegWit and LN and we look forward to the development of these off-chain scaling solutions.

Source