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

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

What is the Lightning Network?

The Lightning Network is a “second-layer solution” built on top of the Bitcoin network, meaning that it is built separately to the Bitcoin network but interacts with it. It’s made up of a system of channels that allow people or companies to move money between one another without needing to use the blockchain to verify the transaction.

It bears similarities to the current settlement system used by companies like Visa and Mastercard. When you pay for something it’s not instantly settled. Instead, there’s a quick verification of funds from the buyer and the request from the seller—giving the green light for a transaction to take place. The settlement of the funds happens later—in some cases days or weeks later.

The Lightning Network is run by a network of nodes that process payments, and transactions are commonly made using QR codes—instead of complex public keys. The bottom line is that it allows for faster payments, with lower fees.

History of Lightning Network?

The Lightning Network has its origins in musings by Satoshi Nakamoto, the pseudonymous creator of Bitcoin, but was formalized by researchers Joseph Poon and Thaddeus Dryja who published a whitepaper for the Lightning Network on January 14, 2016.

Lightning Labs, a blockchain engineering lab, helped to launch a beta version of the Lightning Network in March, 2018—alongside a host of individuals and other companies including ACINQ and Blockstream. It was funded via a $2.5 million seed investment round, which included notable investor Twitter CEO Jack Dorsey (who has recently been getting more involved). The Lightning Network was the first attempt at **a second-layer solution**, but others followed.

Why is the Lightning Network necessary?

Bitcoin's current Limitations

There are two limitations we need to explain when it comes to blockchain before we can explore how people are trying to fix it.

The first is speed. In a blockchain, blocks are essentially groups of transactions collected together. As part of a blockchain’s design, there are only so many transactions that can be included in a block. If your transaction doesn’t make it into the current block, it joins a queue. That queue can take anywhere from a few minutes to potentially a day or more to process, depending on how many other transactions are queued in the mempool. That limits the blockchain’s use as a medium to process quick transactions, like buying a cup of coffee. No one wants to wait around for the network to verify you’ve got the cash.

The second limitation is cost. Bitcoin’s network, and others, are built upon a consensus protocol called proof of work. This is where miners expend energy trying to solve a difficult puzzle. To help offset the cost of equipment and energy used in that calculation, miners charge transaction fees.

When the system is small, and the number of transactions that need verifying are few and far between, the network works well and transaction costs are low. As the network grows, however, so does the cost of transaction fees, since there is limited space in each newly mined block. As a result, only the highest fee transactions are processed highly during times of high load.

Bitcoin's scalability challenge became apparent towards the end of 2017 when millions of people jumped on the Bitcoin bandwagon and it struggled to cope with the number of transactions. At its peak in December 2017, the average cost to process one transaction on the Bitcoin blockchain—whether it was for $1 or $1,000—was $37. That makes Bitcoin un-economical as a form of currency, since the transaction fee would be higher than the actual payment for many small transactions. That’s where the Lightning Network comes in.

The Necessity of using Lightning Network

There are several benefits to using the Lightning Network. We’ll look at some of the main ones below.

Scalability

Bitcoin blocks are created approximately every ten minutes, and can only hold so many transactions. Miners care, first and foremost, about getting paid, so they’ll include transactions with higher fees first.

When there aren’t many users trying to send funds at the same time, this isn’t really an issue. But when everyone’s broadcasting transactions at the same time, the average fee can rise significantly. On a few occasions, it has exceeded $5. At the height of the 2017 bull market, it exceeded $50. That might seem insignificant for transactions moving thousands of dollars worth of Bitcoin, but for smaller payments, it’s not sustainable.

With the Lightning Network, you still pay two fees – one to open your channel, and another to close it. Once opened the channel, you can make thousands of transactions for free in it, as well as your counterparty. If finished, you just need to publish the final state to the blockchain.

In the grand scheme, if more users rely on off-chain solutions like the Lightning Network, block space will be used more efficiently. Low-value, high-frequency transfers could be carried out in payment channels, while block space is used for larger transactions and channel opening/closing. This would make the system accessible to a vastly wider user base, allowing it to scale in the long run.

Micropayments

There’s a minimum amount of Bitcoin you can send in a transaction – approximately 0.00000546 BTC. At the time of writing, that’s equal to about four cents. It’s a small amount, but the Lightning Network allows you to push the limits to transact the smallest unit currently available – 0.00000001 BTC, or one satoshi.

Lightning is a lot more appealing for micropayments. The fees on regular transactions make it impractical to send tiny amounts on the main chain. Within a channel, however, you’re free to send a fraction of a fraction of a Bitcoin for free.

Micropayments are suited to plenty of use cases. Some speculate that they could be a viable replacement for subscription-based models, where users instead pay tiny amounts each time they use a service.

Privacy

A secondary benefit of the Lightning Network is that it can offer usersa high degree of confidentiality. Parties do not need to make their channels known to the broader network. While you may be able to look at the blockchain and say this transaction opened a channel, you won’t necessarily be able to tell what’s going on inside it. If the participants choose to make their channel private, only they will know what transactions are taking place.

How does the Lightning Network work?

We’ve explained how the Lightning Network relies on channels between nodes at a high-level. Let’s now take a look under the hood.

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.

13106b4e204eb3bd81f9d50015171cd0.webp

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.

How does the Lightning Network prevent cheating?

You might have identified an attack vector here. If A currently has a 1 BTC balance, what’s to stop him from broadcasting an older transaction where he had more? He’s already got the half-signed transaction from B, he just needs to add his signature and broadcast it, right?

Nothing’s stopping him from doing that – except for the fact that he could lose his entire balance. Let’s say he goes through with it and broadcasts an old transaction that pays one coin to B and five to that multisig address we mentioned earlier.

B receives his coin immediately. A, on the other hand, must wait until the timelock expires to spend from the multisig address. Remember the other condition we mentioned that would allow B to spend those same funds immediately? He needs a secret that she didn’t have then. He does now – as soon as the second round of transactions were created, A gave that secret away.

While A sits, unable to do anything as he waits for the timelock to expire, B can move those funds. This punishment-based mechanism means that participants are unlikely to even attempt to cheat because the peer will get access to their coins.

Routing payments

We touched on this earlier – channels can be connected. The Lightning Network wouldn’t be that useful for payments otherwise. Are you really going to lock up $500 in a channel with a coffee shop just so you can get your daily fix for the next few months?

You don’t have to do that. If B opens a channel with A and A already has one with C, A can route payments between the two. This can work across multiple “hops”, meaning that B can effectively pay anyone to whom a path exists.

For their role in routing, the intermediaries might take a small fee (though there’s no obligation to). The Lightning Network is still very new, so a fee market has yet to materialize. What many expect to see are fees based on liquidity provided.

On the base chain, the fee is based solely on the space your transaction takes up in a block – the value being transmitted doesn’t matter – $1 and $10,000,000 payments cost the same. In contrast, there’s no such a thing as block space within the Lightning Network.

Instead, there’s the idea of local and remote balances. The local balance is the amount that you can “push” to the other end of the channel, whereas the remote balance is that which your counterparty can push to you.

Limitations of the Lightning Network

It would be fantastic if the Lightning Network proved to be the solution to all of Bitcoin’s scalability troubles. Unfortunately, it has its own shortcomings that may get in the way.

Usability

Bitcoin isn’t the most intuitive system for beginners – addresses, fees, etc. can be confusing to familiarize yourself with. But wallets can abstract away the complicated stuff to give users something that vaguely resembles existing payment systems. You can get someone to download a smartphone wallet, send them coins, and they’re good to go.

For now, that isn’t possible with the Lightning Network. Options are limited when it comes to smartphone apps – generally, Lightning nodes require access to a Bitcoin node to be fully usable.

After a client has been set up, users also need to start opening channels before they can make payments. This can be a time-consuming process, and it could be overwhelming when a newcomer is introduced to concepts like inbound/outbound capacity.

That said, improvements are constantly being made to reduce the barriers to entry, and to provide users with a more streamlined experience.

Liquidity

One of the biggest criticisms of the Lightning Network is that your ability to transact is constrained. You can’t spend more than you have locked into a channel. If you spend all of your funds so that the remote balance has all of the channel’s funds, you’ll have to close the channel. Alternatively, you can wait until someone pays you through it, but that’s not ideal. Your paths can also be limited by the channel’s total capacity.

Centralized hubs

Because of the issue mentioned in the previous section, there’s some concern that the network will facilitate the creation of massive “hubs.” That is, large, heavily-connected entities with a lot of liquidity. Any significant payments would need to be routed through some of these entities.

Obviously, that wouldn’t be a great situation. It would weaken the system, as these entities going offline would majorly disrupt relationships between peers. There’s also an increased risk of censorship since there are only a few points through which transactions are flowing.

The current state of the Lightning Network

As of April 2020, the Lightning Network looks healthy. It boasts upwards of 12,000 online nodes, 30,000+ active channels, and just over 920 BTC in capacity.

There are a handful of different node implementations – Blockstream’s c-lightning, Lightning Labs’ Lightning Network Daemon, and ACINQ’s Eclair are some of the most popular. For users that are less technically-inclined, many companies offer plug-and-play nodes. The only thing you have to do with these is power up the device and you’re ready to get started with the Lightning Network.

The future of the Lightning Network

The popularity of cryptocurrencies and transacting on them has, within just a few short years, put increasing stress on the blockchains they’re built on.

While there have been smaller changes—and some cases forks—to help the networks better cope with demand, the Lightning Network, if successful could help open the door to widespread adoption of cryptocurrencies and their applications.

In August 2020, the Lightning Network was updated to include support for the Wumbo function. In the early days of Lightning, the developers limited how much Bitcoin could be kept inside a Lightning payment channel to 0.1677 BTC; Wumbo channels enable nodes to service larger transactions and higher volumes. Crypto exchange Bitfinex is among those who've announced support for Wumbo channels.

The Lightning Network is spreading beyond Bitcoin, too. Blockstream has created its own implementation of the Lightning Network called c-Lightning which is built in the C programming language, familiar to most developers. Litecoin has its own version, too—the Litecoin Lightning Network—which is small compared to the Bitcoin version, but is slowly growing.

aef911df-4aa6-49af-b156-670a2164a40c.png

Closing thoughts

Since its mainnet launch in 2018, the Lightning Network has seen impressive growth, in spite of many considering it to still be in beta.

There are still some usability obstacles to overcome, as it currently requires some degree of technical proficiency to operate a Lightning node. But with the amount of development taking place, we may well see the barriers to entry reduced over time.

If the issues can be resolved, the Lightning Network could become an integral part of the Bitcoin ecosystem, greatly boosting scalability and transaction speeds.