Bitcoin Payments: What Is the Lightning Network?

The Lightning Network, and how to use it to pay with Bitcoin, is explained in this in-depth beginner’s guide.

Jan 15, 2024
|

What Is Lightning Net Otp

Key Takeaways:

  • First introduced in 2016, the Lightning Network is a Layer-2 payment protocol built on top of the Bitcoin blockchain. It enables near-instant payments by using Bitcoin’s native smart contract functionality.
  • The Lightning Network is composed of multiple bi-directional payment channels that handle transactions parallel to the main blockchain.
  • It aims to address Bitcoin’s scaling issues, such as long block creation time, limited throughput, and high transaction fees.

Check out Crypto.com’s new BTC to USD Converter.

Purchase Coffee With Bitcoin? Bitcoin’s Scalability Problem

Satoshi Nakamoto’s Bitcoin white paper, published in 2008, envisioned a ‘peer-to-peer electronic cash system’ — a decentralised and trustless digital payment system. However, for Bitcoin to fully achieve this vision, there are some drawbacks and limitations it needs to overcome.

Imagine someone trying to buy a cup of coffee using Bitcoin during rush hour while stuck in a long queue. This practical example instantly creates two issues:

First, it can take anywhere between 10 minutes to an hour just to purchase and confirm that the payment went through (depending on how many confirmations the coffee shop requires).

Second, the transaction fee could be close to or even higher than the cost of the coffee itself. There’s no way to guarantee quick and cheap processing of transactions like this with Bitcoin, and this type of uncertainty can make it a less-than-attractive option as a payment method. 

Bitcoin’s limitations as a payment system include: 

Relatively long block creation time. 

For a transaction to be added to a block on the blockchain, it must be validated through the mining process. Miner validation is key to the decentralised and secure nature of Bitcoin, but this also means that transactions are not instantaneous, and they take a considerable amount of time to be confirmed as successful. In fact, a new block gets mined in around 10 minutes (on average, at the time of writing). 

Limited throughput capacity. 

To compare, a major payment giant like Visa can support around 24,000 transactions per second (tps) on its network, while the Bitcoin blockchain can only handle up to 7 tps (at the time of writing). As a payment network, Bitcoin’s throughput is far too low to handle such large amounts of transactions, which can be a significant hindrance to widespread usage. 

Disproportionately high transaction fees for small payments. 

Bitcoin transaction fees peaked at over US$60 in April 2021. While this might not seem like a significant amount to some, if merchants decide to accept Bitcoin as payment, transaction costs will have to be significantly lower to be considered sustainable, especially for small purchases.

This is what the Lightning Network was made for: It enables Bitcoin to operate more like ‘digital cash’ as was originally envisioned. By allowing transactions — like small payments to buy a cup of coffee — to bypass the mainnet, the Lightning Network can process near-instant, high-volume transactions in its network at scale, while still taking advantage of the decentralised and secure nature of the Bitcoin network.

Read more about Bitcoin’s scalability problem and the state of Lightning Network in Crypto.com Research’s in-depth, detailed report

What Is the Bitcoin Lightning Network?

Simply put, the Lightning Network is a Layer-2 payment protocol built on top of the Bitcoin blockchain that enables near-instant payments for participants via payment channels. 

Lightning Network was designed as a scalability solution to Bitcoin: In an effort to reduce Bitcoin network congestion, it uses payment channels to handle Bitcoin micropayments off-chain. These payment channels are what make up the layer. 

A payment channel is an off-chain network that runs parallel to the main blockchain. The idea is to establish a channel between two parties who want to make a transaction, where the transaction made in that payment channel basically bypasses the main blockchain. This enables multiple transactions to be conducted without having the global consensus and confirmation on the mainnet (like the Bitcoin network). As a result, transactions are almost instant, and the fees are extremely low. 

Users in a payment channel can make any number of transactions, and these channels can operate for as long as required. The only times a payment channel touches the mainnet are upon opening and terminating it. When a channel is closed down, the participants’ latest ‘state’ — an off-chain transaction that serves as a ‘sign-off’ from both parties agreeing that the information in the channel is correct — is consolidated into a single transaction, which is then broadcast to the mainnet.

Learn more about scaling blockchain solutions.

A Brief History of Bitcoin and Lightning Network

2016: The concept of the Lightning Network was first proposed by Joseph Poon and Thaddeus Dryja, who founded Lightning Labs to develop the network. 

2017: Segregated Witness (SegWit), a protocol upgrade for Bitcoin, was launched and considered a key milestone in fully enabling the Lightning Network as a Layer-2 solution. The year also saw the first Lightning payment on Litecoin, which demonstrates its potential outside of the Bitcoin network.

2018: After going through a beta testing phase, the Lightning Network eventually went live on the Bitcoin mainnet. 

How Does the Lightning Network Work?

The Lightning Network relies on a network of nodes in order to run, and there are about 16,000 active Lightning nodes at the time of writing. Lightning’s main difference with Bitcoin is that global consensus is not required, and the nodes transact with each other privately instead. To execute transfers and payments in the network, Lightning nodes use channels.

Step 1: Opening a Lightning channel

Let’s say Alice wants to pay Bob with Bitcoin. ​​To establish a payment channel, Alice or Bob (or both) must deposit Bitcoin into a 2-of-2 multi-signature (multisig) wallet. This creates an on-chain ‘funding transaction’ that is recorded on the mainnet; funds are locked up in this jointly owned multisig address. The amount contributed by both parties is shown on the opening channel ‘state’. They can then immediately trade once this initial opening transaction has been confirmed. 

Step 2: Transacting in the Lightning channel

Now that there is funding available, Alice can send the payment to Bob. The Lightning Network uses bi-directional payment channels to facilitate transfers, which means Bob can also send funds to Alice in the same channel if he wants to.

All transactions between Alice and Bob are executed by smart contracts and made off-chain, with low fees, as long as each signs every transaction (otherwise, the transaction may fail to go through). It is designed so that each party holds a private key, and redistributing funds in the channel can be done only if both parties are confirmed. For every transaction made, the channel’s balance also updates off-chain. 

Using the example above, both Alice and Bob deposited 1 Bitcoin each upon opening a channel. There were three transactions that occurred off-chain: 1) Alice transfers 0.25 BTC to Bob, 2) Alice transfers another 0.25 BTC to Bob, and 3) Bob sends 1 BTC back to Alice. Upon closing the channel, the closing transaction takes account of these prior transactions and is updated with each party’s outstanding balance: 1.5 BTC for Alice, and 0.5 BTC for Bob.

Step 3: Closing the Lightning channel

Like the initial funding transaction to open a channel, closing a Lightning channel is also an on-chain transaction. One party can initiate to close the channel, but both parties have to agree on this, after which funds are sent back to their respective wallets. Once the channel has been successfully closed, a single transaction, which represents the balance between parties, is broadcast on-chain. 

Routing and Multi-Party Transactions

The Lightning Network’s multisig and smart contract design ensures that the network runs independently without counterparty risk, which comes in handy for multi-party transactions. For example, Alice can open a channel with Bob, who happens to have a channel with Carol, who also has one with Dave. What if Alice wants to send funds to Dave, but they are not directly connected? In this case, the payment will be routed through Bob and Carol, using them as ‘hops’.

As long as two parties already have their own payment channel set up, they can let the network decide how the payment will be routed to the recipient. Lightning Network employs a combination of source routing and onion routing protocols to make this possible. Source routing enables the nodes to have full control over their payment route; onion routing allows a node to choose an optimal path to ensure the shortest route and lower fees where each hop is encrypted. 

Hashed Timelock Contracts

This is all securely carried out with the help of a hashed timelock contract (HTLC). In simple terms, an HTLC serves as a smart contract that enables the recipient to receive the funds once certain conditions are met within a time period (or block height). To see this in play, let’s use Alice as an example and see how a transaction with Dave is made (see diagram below). In this scenario, Alice wants to send 1 BTC to Dave, with a 10-block refund timeout. Alice’s node decides the most optimal path and calculates the fees (e.g., 0.002 BTC fee to send 1 BTC).

How Payment Routing Works Infographics

Multi-Party Transactions: An Example

1. Dave creates a ‘secret’ (R) that only he himself knows, and executes a hash function on it to generate a hash (H), which is then sent to Alice.

2. Alice sets up an HTLC, which should meet predefined conditions to release the funds. In this case, Alice promises to pay Bob 1.002 BTC if he successfully provides the secret (R) within the next 10 blocks. If not, the payment is transferred back to Alice. 

3. Bob doesn’t know the secret (R) to claim the 1.002 BTC locked by Alice, so he sets up an HTLC to commit 1.001 BTC to someone on the route (in this case, Carol) who knows the secret to solve the hash ‘H’. In this HTLC, Carol gets paid 1.001 BTC if she provides (R) within the following nine blocks; otherwise, the funds are sent back to Bob.

4. In the same fashion, Carol creates an HTLC with Dave, wherein he gets paid 1 BTC if he provides (R) within the following eight blocks; otherwise, the funds are sent back to Carol. 

5. At this point, Dave knows the secret ‘R’ to solve the Hash ‘H’, so he can then unlock the HTLC to get the 1 BTC payment from Carol. As soon as Dave uses the secret to receive the funds, the secret then becomes available to Carol, as well.

6. Carol, having received the secret, unlocks the 1.001 BTC sent by Bob and, by doing so, reveals to him the secret. 

7. Finally, Bob uses the secret to obtain 1.002 BTC from the channel between him and Alice.

Why Hashed Timelock Contracts Are Crucial

HTLCs are key to running the Lightning Network as they 1) enable a trustless system in the network by ensuring certain conditions in a transaction are met, and 2) safely facilitate ‘multi-hop’ transactions. For Alice, this means that she doesn’t have to trust Bob and Carol as intermediaries — the protocol does the work on her behalf, ensuring that Dave safely receives the tokens; otherwise, the tokens automatically are refunded to her.

Conclusion: The State of the Lightning Network Today

The Lightning Network has proven to be promising to date. However, it’s not perfect.

Here are its main issues and drawbacks: 

Issues around payment routing may be affected by the reliability and availability of nodes (e.g., when the routing node does not have enough open channels to other good routing nodes for reliable routing). There is also unattributed payment routing failure, where parties may end up using faulty nodes without even being aware there’s a problem with them.

Not enough route liquidity, or lack of funds, from the channels in a route can cause payments in that channel to fail. This especially can be the case for larger transactions.

Critical vulnerabilities and other security threats exist, such as zombie attacks or griefing attacks, where a malicious group congests a network and renders some nodes unusable, which locks in funds from all channels connected to it. Additionally, amongst others, there is the potential for a double-spend attack (a poorly configured watchtower in the network can allow malicious actors to spend the same funds multiple times).

Despite the Lightning Network’s flaws, it is worth noting that developments and implementation in the past few years have been ongoing. At the beginning of 2023, MicroStrategy announced its plans to develop Lightning Network solutions. More recently, digital payments company Strike rolled out its Lightning Network-powered remittance services in the Philippines. 

The Lightning Network continues to grow, with hundreds of companies, projects, and apps making up its ecosystem and millions of dollars in capital allocated in the space. As most developments in the Bitcoin space come in via the Lightning Network, it would not be surprising to continue seeing it progress in the years ahead, and for industry players to keep pushing the technology forward. 

Due Diligence and Do Your Own Research

All examples listed in this article are for informational purposes only. You should not construe any such information or other material as legal, tax, investment, financial, cybersecurity, or other advice. Nothing contained herein shall constitute a solicitation, recommendation, endorsement, or offer by Crypto.com to invest, buy, or sell any coins, tokens, or other crypto assets. Returns on the buying and selling of crypto assets may be subject to tax, including capital gains tax, in your jurisdiction. 

Past performance is not a guarantee or predictor of future performance. The value of crypto assets can increase or decrease, and you could lose all or a substantial amount of your purchase price. When assessing a crypto asset, it’s essential for you to do your research and due diligence to make the best possible judgement, as any purchases shall be your sole responsibility.

Tags

bitcoin

Share with Friends

Ready to start your crypto journey?

Get your step-by-step guide to setting up an account with Crypto.com

By clicking the Get Started button you acknowledge having read the Privacy Notice of Crypto.com where we explain how we use and protect your personal data.
Mobile phone screen displaying total balance with Crypto.com App

Common Keywords: 

Ethereum / Dogecoin / Dapp / Tokens