Please note, this is a STATIC archive of website cointelegraph.com from 17 Oct 2021, cach3.com does not collect or store any user information, there is no "phishing" involved.

What is the Lightning Network in Bitcoin and how does it work?

What is the Lightning Network in Bitcoin and how does it work?

The Lightning Network is a second layer added to Bitcoin’s (BTC) blockchain that allows off-chain transactions, i.e. transactions between parties not on the blockchain network. Multiple payment channels between parties or Bitcoin users make up the second layer. A Lightning Network channel is a two-party transaction method in which parties can make or receive payments from each other. Layer two enhances the scalability of blockchain applications by managing transactions outside the blockchain mainnet (layer one), while still benefiting from the mainnet’s powerful decentralized security paradigm. 

Scalability is a significant barrier that restricts the widespread adoption of cryptocurrencies. If scaled properly, a blockchain network can handle millions to billions of transactions per second (TPS). In this context, the Lightning Network charges low fees by transacting and settling off-chain, allowing for new use cases like instant micropayments that can solve the traditional “can you buy coffee with crypto” conundrum, speeding up the processing times and reducing the expenses (energy costs) associated with Bitcoin’s blockchain.

However, while the intent is there, the Lightning Network still struggles to solve the issue and even introduces various problems like low routing fees and malicious attacks. For example, there’s a small fee required to both open and close a payment channel. On top of these small fees are routing fees that go toward nodes that are validating transactions. 

Now, the question arises: If the routing fee is so low, why would a node want to validate said transaction?

The clear answer is that miners do not often validate smaller transactions, as they will earn lower fees for validating insignificant transactions. As a result, traders pay a routing fee and may have to wait long before the transaction is validated. Regarding malicious attacks, a bad actor could start various payment channels and close them all at once. Those channels then need to be validated which get in the way of legitimate ones, congesting the network. During congestion, the attacker could pull funds before legitimate parties become aware of the situation. 

History of Lightning Network

The Lightning Network was proposed in 2015 by two researchers, Thaddeus Dryja and Joseph Poon, in a paper titled “The Bitcoin Lightning Network.” Their writings were based on previous discussions of payment channels made by Satoshi Nakamoto, the anonymous creator of Bitcoin. Nakamoto described payment channels to fellow developer Mike Hearn, who published the conversations in 2013. 

The paper’s abstract describes an off-chain protocol made up of payment channels. Within payment channels, two untrusted parties can transfer value without congesting the mainnet, as the channels exist off-chain. Off-chain channels are designed to solve Bitcoin’s scalability problem. Dryja and Poon then detailed that Visa peaked at 47,000 TPS during the holidays in 2013. For Bitcoin to come anywhere close to Visa’s TPS, it would have to manage eight gigabytes worth of transactions per block, which is nowhere near the capabilities of the current blockchain. Initially, Bitcoin could only handle seven transactions a second, assuming those transactions were around 300 bytes each. Plus, Bitcoin’s blocks only had a one-megabyte transaction limit at the time, so there was certainly no room for anywhere near 47,000 Bitcoin transactions to fit in one block. Lightning Network’s off-chain payment channels were created to address Bitcoin’s lack of scalability, as the channels allow for various, smaller transactions to exist without congesting the network.

In 2016, Dryja and Poon founded Lightning Labs (with a few other contributors), a company dedicated to developing the Lightning Network. Despite various team member changes over time, Lightning Labs worked to make the protocol compatible with the core Bitcoin network. A breakthrough became possible after Bitcoin’s SegWit-based soft fork in 2017, which freed up space for more transactions to fit in each block and removed a longstanding Bitcoin bug called transaction malleability. The bug enabled users to fake transactions, lie to the network and keep Bitcoin in their wallets.

Due to pre-launch testing, developers could build apps on the Lightning Network right away. Apps included simple use cases such as wallets and gambling platforms, which harnessed the power of the Lightning Network’s microtransactions.

In 2018, Lightning Labs finally launched a beta version of its Lightning Network implementation into the Bitcoin mainnet. At this time, public figures like Twitter founder Jack Dorsey began their involvement with the project. For instance, Dorsey hired a group of developers to focus exclusively on Lightning Network development by paying them in Bitcoin. He also plans to implement the Lightning Network into Twitter in the future.

How does the Lightning Network work?

This protocol enables the creation of a peer-to-peer payment channel between two parties, like between a customer and a coffee shop. Once established, the channel allows them to send an unlimited amount of transactions that are nearly instant as well as inexpensive. It acts as its own little ledger for users to pay for even smaller goods and services such as coffee without affecting the Bitcoin network. 

To create a payment channel, the payer must lock a certain amount of Bitcoin into the network. Once the Bitcoin is locked in, the recipient can invoice amounts of it as they see fit. If the customer wants to keep the channel open, they can choose to add Bitcoin consistently.

By using a Lightning Network channel, both parties can transact with each other. When contrasted to ordinary transactions on the Bitcoin blockchain, some transactions are handled differently. For instance, when two parties open and close a channel, they are only updated on the main blockchain. 

The two parties can transfer funds between themselves indefinitely without telling the main blockchain. Because all transactions within a blockchain do not need to be approved by all nodes, this strategy substantially speeds up transaction times. Lightning Network nodes capable of routing transactions are formed by combining individual payment channels between the concerned parties. Therefore, the Lightning Network is the outcome of many payment systems being linked together.

Eventually, when the two parties decide to finish transacting, they can close the channel. All of the channel’s information is then consolidated into one transaction, which is sent to the Bitcoin mainnet for recording. Consolidation ensures that dozens of small transactions spam the network at once, simplifying them into one transaction that takes less time and effort for nodes to validate. Without payment channels, smaller transactions get in the way of bigger ones, congesting the network and adding more for nodes to validate.

For example, let’s say Mike goes to a local coffee shop every day and wants to pay in Bitcoin. He could choose to make a small transaction for each coffee cup, but due to Bitcoin’s scalability issues, the transaction can take over an hour to validate. Mike will also have to pay the Bitcoin network’s high fees, even though he’s making a tiny transaction. Small transactions work with traditional payment methods like a card because companies such as Visa have the infrastructure to process more than 24,000 TPS. In contrast, Bitcoin, on a regular day, can validate seven TPS.

Lightning network transactions between Mike and a local coffee shop

With the Lightning Network, Mike can open up a payment channel with the coffee shop. Each coffee purchase is recorded within that channel, and the shop still gets paid. The transaction is cheap or possibly even free, as well as instant. Then, when the Bitcoin that started the channel is spent, Mike can choose to close the channel or refill it. When a channel is closed, all of its transactions will then be recorded to the main Bitcoin blockchain.

The Lightning Network creates a smart contract between two parties. The agreement rules are coded into the contract upon creation and cannot be broken. Smart contract code also ensures that contract fulfillment is automatic, as contracts are initially made with preset requirements that all participating parties agree with. Once those requirements are met, like when a customer pays the correct amount for a coffee, the contract automatically fulfills without third-party involvement. The Lightning Network anonymizes transactions within a payment channel once validated. All anyone can see is the total transfer of value, not the individual transactions within it.

It is entirely possible to conduct transactions without any restrictions outside of the blockchain. Off-chain transactions can be trusted to enforce the blockchain, considering they end up on the mainnet once payment channels are closed. The mainnet is the arbiter of all transactions. While off-chain protocols have their own ledger, that ledger always integrates back into the mainchain, which is core to the Lightning Network’s design. Only if there is a mainchain to build off, off-chain protocols can exist.

Pros of Lightning Network

The obvious pros of the Lightning Network are faster and cheaper transactions, enabling micropayments in a way that was never possible before. Without the Lightning Network, users would have to pay high fees for a simple transaction and then wait an hour or more for it to validate. Longer wait times occur for smaller transactions, as miners choose to validate larger transactions because they earn larger rewards for doing so. 

The Lightning Network is connected to the Bitcoin blockchain, existing as a layer on top of it. The connection means that the Lightning Network still benefits from Bitcoin’s security protocols. Users can then choose the main blockchain for bigger transactions and swap to the Lightning Network’s off-chain for smaller ones without worrying about safety. The Lightning Network payment channels also provide private transactions, as onlookers cannot take a peek at every individual transaction, instead only the overall package.

Cryptocurrency enthusiasts have also been testing atomic swaps, which is the act of swapping one cryptocurrency to another without using a third party, or an exchange. Atomic Swaps are more useful than an exchange, as they offer near-instant swapping with little to no fees or wallet transfers.

Cons of Lightning Network

One has to acquire a wallet compatible with the Lightning Network to actually take advantage of it. While finding a wallet that works with the Lightning Network is easy, a user needs to fund it from a traditional Bitcoin wallet. The initial transaction from the traditional to the Lightning Network wallet costs a fee, so users are losing some Bitcoin to interact with the protocol. After funds are in the Lightning Network wallet, users must lock up their Bitcoin to create a payment channel. 

Sending Bitcoin between wallets can be annoying and expensive, which is off-putting to newer users. That said, some wallets can manage both on and off-chain payments without paying fees, and the convenience is likely to improve over time. 

If either participant in the payment channel decides to pull some funds, they have to actively close a channel and receive that Bitcoin back before using the funds. It’s not possible to pull out a little bit of money and leave the channel open, for example. Even closing or opening a payment channel requires both participating parties to make an initial transaction called a routing fee. While opening a channel is simple in concept, all of these extra payments make the process more expensive than many potential users will care for.

One of the greatest problems with the Lightning Network, however, is offline transaction scams. If one participant in a payment channel chooses to close it while the other party is offline, the former can steal the funds. When the latter party finally comes online, it’s too late to do anything. The scammer can just remain offline with no way to contact them.

Also, the Lightning Network does suffer from bugs such as stuck payments, which are outgoing transactions that don’t see verification. The Bitcoin network will refund a stuck payment, but it can take days to acquire, as valid transactions see more priority than stuck ones when it comes to verification. 

Finally, even if the Lightning Network works out all of its issues, there is still the case of regulators. Regulators may struggle to understand Lightning Network enough to enact proper legislation. If regulators struggle, mainstream crypto users might struggle to use the Lightning Network as well. Even if regulators do understand the protocol, they might not allow the Lightning Network due to its anonymity. Anonymous transactions might scare legislators off, considering they can only see a finalized transaction after a user closes their payment channel, not the individual transactions made within a channel. 

The future of Lightning Network

Fortunately for the Lightning Network, however, adoption is on the rise. According to DappRadar, there is over $110 million in Bitcoin locked into the Lightning Network. These could be people paying for goods and services, utilizing apps, gambling and more.

Some apps are vital to network usage, such as Lightning Network compatible wallets. Considering that the Lightning Network is a separate protocol from Bitcoin’s mainnet, it requires a different type of wallet so users can create payment channels. Traders cannot utilize the Lightning Network without optimized wallets. If Lightning Network adoption continues to grow, the industry can expect more wallet developers to integrate Lightning Network support. Dedicated users can also become a node, speeding up Lightning Network transaction times. 

It’s also worth noting that development on Lightning has expanded to work as a layer-two solution on various projects. Cryptocurrency exchanges are also starting to support the protocol, bringing the Lightning Network to as many traders as possible. Exchanges that integrate the Lightning Network allow traders to withdraw smaller amounts of Bitcoin cheaply and instantly (even when Bitcoin is congested). Without the Lightning Network, users may suffer from high transaction fees and wait times due to Bitcoin’s traditional technology.

Watchtowers, a third-party protection service made up of various specialized nodes, have also been introduced to the Lightning Network. Some nodes go offline from time to time, leaving their payment channels open to offline transaction scams. Instead of leaving their channel unattended, a participant can pay a small fee to a watchtower and provide a signifier related to the channel transaction. The watchtower utilizes the signifier to identify the user’s channel among all of the rest and keeps an eye on it.

If the watchtower senses malicious activity, like the opposing party attempting to close the payment channel, it will automatically freeze the funds and refund them back to the offline user. The watchtower will also penalize the malicious party by removing their funds from the channel.