— —
Follow on X
LESSONS

How Lightning works

Two parties lock bitcoin in a shared output and update who owns what by signing new balances. Payments hop across channels using HTLCs, so no hop can steal.

6 MIN READ
Open on-chain, update off-chain, route through others, close on-chain.
LEVEL · Intermediate
IN THIS LESSON · 2 OF 8
BY THE END YOU WILL BE ABLE TO ANSWER
  • What touches the blockchain in a channel's life?
  • What stops an intermediate node stealing a routed payment?
  • How does Alice pay Carol when she has no channel with her?
  • Alice and Bob open a channel with 100,000 sats from Alice. Alice pays Bob 30,000. How many sats can Alice still send?

Then prove it: a 3-question quiz · a challenge. The lesson marks itself complete at 100%.

After this lesson you can: describe a payment channel in plain words.

A channel

Alice and Bob create a channel by funding a 2-of-2 multisig output on-chain. Say each puts in 0.5 BTC. They then hold a signed transaction that would pay out the current balances if broadcast. To pay Bob 0.1, Alice signs a new version: 0.4 to her, 0.6 to him. They can do this thousands of times, instantly, with no blockchain involvement. The chain only sees the open and, eventually, the close.

Diagram of a Lightning channel: an on-chain open, instant off-chain balance updates, and an on-chain close.
A channel’s life: one transaction to open, any number of instant updates, one transaction to close.

Keeping it honest

Three steps: an old state is broadcast, the other party uses the revocation secret, the cheater loses everything.
Why nobody broadcasts an old state.

A Lightning Channel allows users to transact off of the Bitcoin blockchain.
A channel: two parties, one shared output, many off-chain updates.Image: River Learn

What stops Alice broadcasting an old state where she had more? Each new state comes with a secret that lets the other party claim all the funds if an old state is ever broadcast. Cheating costs everything, so nobody cheats. A watchtower can watch the chain on your behalf while you are offline.

Routing

Alice has no channel with Carol, but Bob has one with each. Alice pays Carol through Bob. A hashed timelock contract (HTLC) makes this safe: Carol creates a secret and gives Alice its hash; each hop forwards a conditional payment that can only be claimed by revealing the secret, within a time limit. When Carol reveals it to claim from Bob, Bob can claim from Alice. Either every hop completes or none does. Bob earns a tiny routing fee.

Animated payment hopping from Alice through Bob to Carol.
Alice pays Carol through Bob. Each hop can only claim by revealing the secret, which lets the previous hop claim too.

Invoices and addresses

Table of invoices, Lightning addresses and BOLT 12 offers: reusable or not, and what they look like.
Three ways to ask for a payment.

To get paid you issue an invoice (lnbc...), a one-time request containing the amount and the payment hash. Lightning addresses (you@domain) and BOLT 12 offers let you publish something reusable.

The limits

A channel can only move what is in it; large payments may need several routes (multipath). To receive, you need inbound liquidity on your side. The receiver's node must be online. These are the practical frictions the next lessons address.

Bitcoin Lightning Network: Everything You Need to Know · ExplainerWatch on YouTube ↗
MINI CHALLENGEChannel balance

Alice and Bob open a channel with 100,000 sats from Alice. Alice pays Bob 30,000. How many sats can Alice still send?

sats
CHECK YOURSELF
1/3 What touches the blockchain in a channel's life?
2/3 What stops an intermediate node stealing a routed payment?
3/3 How does Alice pay Carol when she has no channel with her?
pick an answer for each question

SOURCES

  1. The Bitcoin Lightning Network (Poon and Dryja, 2016)
Progress is saved in this browser only.