Blockchain technology · · 5 min read
What is the Lightning Network and how does it speed up Bitcoin?
The Lightning Network is a second-layer (layer 2) network built on Bitcoin that uses payment channels between two parties to make many payments in seconds and at low cost, without writing each one to the blockchain. Only the opening and closing of a channel are recorded on-chain; every payment in between runs on updated balance records signed by both parties.
The idea was introduced in a 2015 paper by Joseph Poon and Thaddeus Dryja. The goal was to make small, frequent payments practical without changing Bitcoin's limited block space.
Why was it needed?
On Bitcoin, a new block is produced roughly every 10 minutes on average, and each block has limited space. Transactions waiting to get into a block queue up in a waiting area called the mempool, and when demand rises, so do fees. This design provides a secure foundation for storing value and making large transfers. But waiting several minutes for a coffee payment, without knowing the fee in advance, is not practical.
Lightning's approach is to use the blockchain as a referee rather than writing every payment to it. As long as the parties agree, payments stay off-chain. If a dispute arises, the latest valid state is brought to the chain and the rules are enforced there.
How does a payment channel work?
A payment channel goes through three stages:
- Opening: Two parties lock bitcoin into a 2-of-2 multisignature (multisig) address that cannot be spent without both signatures. This is an on-chain transaction.
- Payments inside the channel: With each payment, the parties sign a commitment transaction showing the new split of the locked amount. These transactions are not broadcast; each party keeps them. Once a new state is signed, the previous one is treated as invalid.
- Closing: The parties close the channel together with a transaction that writes the final balances on-chain. If one side won't cooperate, the other can close the channel alone by broadcasting the latest commitment transaction. In that case, the party who closes unilaterally can access their own share only after a set waiting period.
A hypothetical example: Alice opens a 1,000,000-satoshi channel with Bob's coffee shop (1 bitcoin equals 100 million satoshis). She pays 20,000 satoshis for a coffee every day. After thirty days, 600,000 satoshis have moved to Bob and 400,000 remain with Alice. Only two transactions are written to the chain for those thirty payments: the opening and the closing. Because Lightning can track amounts down to a thousandth of a satoshi, very small payments (micropayments) are possible too.
What if Alice broadcasts an old state that favors her? The system includes a penalty mechanism for this. Each time a new state is signed, the parties hand each other a revocation key for the previous state. If an old state is broadcast, the other party can use that key to take all the funds in the channel before the waiting period ends. That makes cheating economically pointless. For this to work, though, the other party must be online during that period or use a watchtower service that monitors the chain on their behalf.
No direct channel? Routing
Lightning's strength is that not everyone needs a channel with everyone else. If Alice has no channel with Carol, but Bob has channels with both Alice and Carol, the payment can be routed through Bob.
What makes this safe is the hash time-locked contract (HTLC). Roughly, the flow looks like this:
- Carol generates a secret number and gives Alice its hash inside a payment request (invoice).
- Alice pays Bob on the condition "the payment is yours if you reveal the secret". Bob pays Carol under the same condition.
- To receive her money, Carol reveals the secret to Bob. Bob then uses it to collect what Alice owes him.
- If the secret isn't revealed within a set time, the conditional payments expire and the amounts return to their owners.
This way, Bob, the intermediary, cannot hold on to the money: either the whole payment goes through or none of it does. Bob usually earns a small routing fee for the service.
Limits and risks
Lightning doesn't replace on-chain Bitcoin. It's a tool designed for specific jobs, with its own trade-offs:
| Topic | On-chain Bitcoin | Lightning |
|---|---|---|
| Speed | Wait for a block to confirm | Payment usually within seconds |
| Fee | Varies with demand for block space | Usually very low for small payments |
| Large amounts | Well suited | Limited by channel capacity and pathfinding |
| Being online | Not required | Monitoring needed for channel security |
| Record | Every transaction on-chain | Only opening and closing on-chain |
- Liquidity management: You can only send up to the balance on your side of a channel and receive up to the balance on the other side. Someone who wants to receive payments needs inbound liquidity.
- On-chain fees: Opening and closing a channel are on-chain transactions, so this cost is noticeable when on-chain fees are high.
- Hot wallet: Managing channel funds requires the keys to sit on an internet-connected device. That's why Lightning is mostly used for everyday spending balances.
- Custodial wallets: Some wallets make things easier by managing channels on the user's behalf. In that case a company controls the funds, which creates counterparty risk.
Key takeaways
- The Lightning Network is a second layer on Bitcoin that works through payment channels; only a channel's opening and closing are written to the chain.
- Every payment inside a channel is a new balance state signed by both parties, and broadcasting an old state is penalized.
- Thanks to HTLCs, payments can be routed across multiple channels without trusting the intermediary.
- In exchange for speed and low fees, Lightning comes with limits such as liquidity management, the need to stay online and hot wallet risk.