The Lightning Network is a network of payment channels built on Bitcoin. Two parties lock bitcoin in a 2-of-2 funding output on chain, then pay each other off chain by exchanging new signed commitment transactions that split the balance differently. Each update revokes the previous state by handing over a secret, so broadcasting an old state lets the other side take the whole channel. Payments reach people you don't share a channel with by hopping across several channels using HTLCs (hash time-locked contracts) tied to one payment hash: either every hop settles when the recipient reveals the preimage, or every hop times out and refunds. Only opening and closing a channel touch the blockchain.
What is a payment channel?
A channel starts with a funding transaction: an ordinary Bitcoin transaction that pays into an output only both parties can spend together. Classic channels use a P2WSH 2-of-2 multisig script; newer "simple taproot channels" use a single MuSig2 key, which looks like any other Taproot output on chain.
Before the funding transaction is broadcast, the parties sign a first commitment transaction that spends it back to the funder. Without that, the funder's coins could be held hostage by an unresponsive peer. Once the funding transaction confirms, the channel has a fixed capacity, split into a local balance (what you can send) and a remote balance (what you can receive).
Payments don't move coins on chain. They change which commitment transaction would pay whom if the channel were closed now. Because those transactions are fully signed and valid, either side can enforce the latest balance at any time without the other's cooperation. That's a different scaling approach from rollups, which post compressed batches to a base layer: an ordinary Lightning payment never appears on chain at all.
How do commitment transactions update the balance?
Each side holds its own version of the current commitment transaction, signed by the other party. The versions are deliberately asymmetric. In the version you hold:
| Output | Pays | Spendable |
|---|---|---|
to_remote | Your peer's balance | By your peer, almost immediately |
to_local | Your balance | By you after a relative delay (to_self_delay, enforced with OP_CHECKSEQUENCEVERIFY), or by your peer at once with the revocation key |
| HTLC outputs | In-flight payments | By the payee with the preimage, or by the payer after a timeout |
| Anchor outputs | 330 sats each | For fee bumping with CPFP |
To make a payment, the peers exchange commitment_signed and revoke_and_ack messages (defined in BOLT 2). Each revoke_and_ack reveals the per-commitment secret for the state being replaced. With that secret, the other side can compute the revocation key for the old to_local output.
What happens if someone cheats?
Suppose Alice's balance has dropped from 0.8 BTC to 0.2 BTC, and she broadcasts an old commitment where she had 0.8. Her to_local output is locked for to_self_delay blocks. During that window, Bob uses the revocation secret Alice gave him to sweep the entire channel, her old balance included, with a justice transaction. Cheating doesn't just fail; it costs the cheater everything in the channel.
That security model has two consequences:
- Someone must watch the chain. Bob's node, or a watchtower he has given encrypted penalty data to, must notice the old state and respond before the delay expires. The delay is negotiated per channel and is commonly somewhere between about 144 blocks (a day) and 2,016 blocks (two weeks).
- Never restore an old channel database. If you restore a node from a stale backup and it broadcasts what it thinks is the current state, your node is the cheater and you lose the channel. Implementations provide static channel backups that only let you ask peers to force-close, which is the safe recovery path. This is separate from your on-chain wallet's seed phrase, which doesn't contain channel state.
How do payments route through other channels?
You rarely have a channel to the person you're paying. If Alice has a channel to Bob and Bob has one to Carol, Alice can pay Carol through Bob without trusting him, using an HTLC at each hop:
- Carol picks a random 32-byte preimage and puts its SHA-256 payment hash in an invoice.
- Alice adds an HTLC to her channel with Bob: "100,011 sats to Bob if he shows the preimage of this hash before block N + 80, otherwise back to Alice."
- Bob adds an HTLC to his channel with Carol: "100,000 sats to Carol if she shows the preimage before block N + 40." He keeps 11 sats as his fee.
- Carol reveals the preimage to Bob to claim her HTLC. Bob now knows it and uses it to claim his HTLC from Alice.
Bob can't take Alice's money without the preimage, and he only learns it by paying Carol. The timeouts decrease along the route (each node's cltv_expiry_delta is its safety margin), so Bob always has time to claim upstream after paying downstream. The preimage doubles as proof of payment.
Routing details worth knowing:
- Fees are set per channel as a base fee plus a proportional rate in parts per million. A 1 sat base fee plus 100 ppm on 100,000 sats is 1 + 10 = 11 sats.
- Onion routing (BOLT 4) wraps the route in layers, so each hop learns only the previous and next node, not the sender or final recipient.
- The sender finds the path. Nodes gossip channel existence and fee policies, but not balances, so a route can fail for lack of liquidity. Wallets retry other routes and split large payments into several parts (multi-path payments).
How do I open a channel and pay an invoice?
With LND's lncli on a node with an on-chain balance:
# Connect to a peer and open a 1,000,000 sat channel
lncli connect [email protected]:9735
lncli openchannel --node_key 03abc...def --local_amt 1000000 --sat_per_vbyte 5
lncli pendingchannels # wait for the funding tx to confirm
# Receive: create a BOLT 11 invoice for 25,000 sats
lncli addinvoice --amt 25000 --memo "test payment"
# Send: inspect, then pay an invoice
lncli decodepayreq lnbc250u1p...
lncli payinvoice lnbc250u1p...
# Cooperative close (funding txid and output index)
lncli closechannel <funding_txid> 0
A BOLT 11 invoice encodes the amount (lnbc250u is 250 micro-BTC, 25,000 sats), payment hash, expiry and route hints, and it's meant to be paid once. BOLT 12 offers, merged into the specification in 2024, are reusable payment codes: the payer fetches a fresh invoice over the Lightning network itself, and the recipient can hide its node behind blinded paths. Support varies by implementation and wallet, so check before depending on it.
How do channels close?
- Cooperative close. Both peers sign a closing transaction paying each their current balance. There's no delay, and it costs one ordinary transaction.
- Force close. One side broadcasts its latest commitment transaction. Its own
to_localoutput waits out the delay, and any pending HTLCs are resolved on chain with their own transactions. If fees have spiked, the commitment is bumped through its anchor output with CPFP, the technique explained in how RBF and CPFP work.
Force closes are expensive and slow, which is why mobile wallets and services try hard to close cooperatively.
Why can't I receive payments on a new channel?
A channel you open starts with all its capacity on your side, so you can send but not receive. Receiving needs inbound liquidity: someone else's balance in a channel towards you. You get it by spending through the channel, asking a peer to open a channel to you, buying one from a Lightning Service Provider (LSP), or using dual-funded channels where both sides contribute. Splicing lets you add or remove funds without closing; it was merged into the BOLT specification in 2026 after implementations had shipped it, but check that both peers support it.
What developers should know
- Lightning needs an online node. A receiver must be online to reveal the preimage, and someone must watch for revoked states. Use watchtowers, or an LSP-backed wallet if you can't run infrastructure.
- Budget for on-chain fees. Opens, closes and force closes are normal Bitcoin transactions competing in the mempool. Small channels can be uneconomic to close when fees are high.
- Small payments become fees. HTLCs below the dust limit aren't given their own output; they're "trimmed" into fees on a force close. There's also a cap of 483 pending HTLCs per direction per channel.
- Fee bumping is improving. Bitcoin Core 28 introduced TRUC (version 3) transactions and pay-to-anchor outputs (BIP 433), which let channels use zero-fee commitments with a single shared anchor. Implementations are adopting this channel type at different speeds.
- Pick the right confirmation depth for opens. A channel is only as safe as its funding transaction; see how many confirmations to wait for. Zero-conf channels trust the funder not to double-spend.
- Future upgrades need consensus changes. Replacing HTLCs with PTLCs (point time-locked contracts) uses Schnorr signatures that Taproot already enables. LN-Symmetry ("eltoo"), which removes the penalty mechanism, needs a soft fork such as
SIGHASH_ANYPREVOUT(BIP 118), which hasn't activated.
Summary
| Concept | What it does |
|---|---|
| Funding transaction | Locks channel capacity in a 2-of-2 (or MuSig2) output on chain |
| Commitment transaction | Signed, unbroadcast transaction that encodes the current balance |
| Revocation secret | Invalidates old states; cheating forfeits the whole channel |
to_self_delay | Window in which a cheat can be punished |
| HTLC | Payment locked to a hash and a timeout, enabling trustless multi-hop routing |
| Onion routing | Each hop sees only its neighbours |
| BOLT 11 / BOLT 12 | Single-use invoices / reusable offers |
| Inbound liquidity | Remote balance you need before you can receive |
Get the weekly commit
New blockchain deep dives every week.