IndexCrypto
Educational only. Not financial, tax or legal advice, and nothing here is a recommendation to buy anything.

How the Lightning Network Routes Payments

How the Lightning Network works: on-chain channel opens, HTLC-routed payments, inbound and outbound liquidity, force-closes, watchtowers and wallet custody.

A Lightning payment does not touch the base chain. It settles inside a payment channel — a two-party arrangement funded by one on-chain transaction — and the base chain only sees the channel when it is opened and when it is closed. Everything between those two events is a series of signed balance updates that the two parties could, if they chose, submit to the chain. Understanding the Lightning Network means understanding what those updates are, how a payment crosses several channels it does not own, and what happens when one side stops cooperating.

What a payment channel actually is

A channel is funded by a single on-chain transaction that locks an amount into a multisignature output controlled by both parties. That funding transaction is the only on-chain footprint of a healthy channel. From that point the two parties exchange signed commitment transactions, each of which describes how the locked amount would be split if broadcast. A payment is a new pair of commitments in which the sender’s side is smaller and the receiver’s side is larger by the payment amount.

Neither party broadcasts these commitments during normal operation. They are held as a fallback. Because each new commitment supersedes the last, the channel can carry an unbounded number of payments on top of one fixed on-chain deposit. The on-chain fee is paid once at open and once at close, not per payment. This is the mechanism behind the low per-payment cost, and it is also why the cost profile changes sharply when a channel has to be closed unilaterally.

Routing a payment across channels you do not own

Two parties rarely share a channel with everyone they want to pay. A payment therefore travels as a path through several channels, with each hop forwarding a slightly smaller amount than it received; the difference is the routing fee. The sender constructs the route and encrypts the payment details so that each hop learns only the previous and next node, not the full path.

The forwarding is enforced by hash time-locked contracts (HTLCs). The sender generates a secret and gives its hash to the first hop. Each hop passes the same hash forward, and the final recipient can claim the funds only by revealing the secret, which unwinds back along the path and lets each hop take its fee. If the secret is never revealed, every HTLC expires after a timelock and the funds return to their senders. The timelocks are staggered so that each hop has time to reclaim before the hop behind it does.

This is why a Lightning payment either completes or fails; there is no partial state where one hop is paid and the next is not. It is also why a failed payment ties up liquidity along the attempted path until the HTLCs time out, which is the mechanism behind the temporary “pending” or “in flight” balances some wallets show.

Inbound and outbound liquidity are not the same thing

A channel’s capacity is split between the two parties. Outbound liquidity is what one side can send; inbound liquidity is what the other side can send to it. Opening a channel with your own funds gives you outbound capacity and gives the counterparty inbound capacity — the reverse of what a new recipient usually needs.

To receive a payment, a node needs inbound liquidity in some channel. A freshly opened channel with all funds on your side has none, so a payment to you cannot be routed through it until someone pushes funds the other way. Wallets and services address this in different ways: some open a channel to you and fund part of it on their side, some sell inbound capacity, and some route your receive through a custodial intermediary. Each approach trades control for convenience.

Liquidity is also consumed by use. A channel that has sent most of its balance in one direction can no longer forward payments in that direction, even though it still has capacity. Rebalancing — sending out and back through other paths, or using a service that does so — restores the split. A node with many channels but poor balance distribution will fail payments that a smaller, better-balanced node completes.

Custodial and self-custody Lightning wallets

A custodial Lightning wallet holds the funds on your behalf. The channel, the liquidity and the routing are managed by the operator; what you hold is a claim on that operator, recorded in their database. Payments are fast and inbound liquidity is usually not your problem, but the trust model is the same as any exchange balance: the operator controls the keys, and the funds are only as available as the operator’s solvency and terms.

A self-custody wallet runs a node, or connects to one you control, and holds the channel keys yourself. You manage liquidity, you pay on-chain fees to open and close, and you are responsible for keeping the node online enough to respond to a counterparty’s attempt to close. The trade is explicit: control and censorship resistance on one side, operational burden and the risk of losing funds to a stale state on the other.

A middle category exists — wallets that are non-custodial in key ownership but rely on a service for liquidity and routing. The distinction that matters is who can move the funds without your participation. If the answer is anyone but you, the wallet is custodial in effect regardless of how it is described. Backups for self-custody nodes are a separate subject; see the seed-phrase guide for what a recovery phrase does and does not restore.

Force-closes, timelocks and watchtowers

When both parties agree, a channel closes cooperatively with a single on-chain transaction that splits the balance. When one party disappears or broadcasts an old commitment, the other must respond on-chain within a timelock. A force-close is the unilateral path: it broadcasts the latest commitment the closing party holds, and the funds become spendable after the timelock expires.

A force-close costs more than a cooperative close because the commitment transaction is larger and may need additional transactions to sweep outputs. It also requires the honest party to be online, or to have delegated that duty. A watchtower is a service that monitors the chain for broadcasts of revoked commitments and submits a penalty transaction if one appears. Watchtowers mitigate the offline risk but do not remove it: the tower must be configured correctly, and the penalty must still confirm within the window.

The risk that marketing tends to omit is this: a node that is offline for the entire timelock period, with no watchtower, can lose the channel balance to a counterparty who broadcasts a revoked state. The timelock is the window in which that attack is possible, and it is measured in blocks, not minutes.

Reading a channel close on a block explorer

When a channel closes, the on-chain transaction shows what happened. A cooperative close is a single transaction spending the funding output to two addresses. A force-close spends the funding output to a commitment transaction with outputs that are encumbered by relative timelocks; the explorer will show the outputs but not the timelock condition unless you inspect the script.

Foundry’s cast can decode the calldata of an on-chain transaction, though Lightning channel transactions are usually plain Bitcoin spends rather than contract calls. For EVM-based layer-2 systems that settle to a chain with contract calls, the same decoding applies:

cast decode-calldata "approve(address,uint256)" 0x...

The output is the function name and its arguments, which tells you what the transaction asked the contract to do. If the selector is unfamiliar, look it up:

cast 4byte 0x095ea7b3

The output is the human-readable signature matching that selector, or nothing if the selector is not in the database. Neither command tells you whether a Lightning channel was closed cooperatively; that requires reading the transaction’s inputs and outputs against the funding outpoint.

Source: https://getfoundry.sh/cast/reference/decode-calldata (Foundry Book: cast decode-calldata) Source: https://getfoundry.sh/cast/reference/4byte (Foundry Book: cast 4byte)

Where the layer-2 boundary sits

The Lightning Network is a layer-2 system in the sense that it moves value off the base chain while relying on it for settlement and dispute resolution. It is not a sidechain and it does not have its own consensus. Its security model is the base chain’s timelock and penalty rules plus the liveness of the parties. That is why channel management is an operational discipline rather than a one-time setup, and why the difference between a custodial and a self-custody wallet is a difference in who carries that discipline.

When a payment fails and what the failure means

A failed payment is not necessarily an error in the wallet. The common causes are distinguishable by what the sender sees.

SymptomLikely causeWhen this is not the cause
“No route” before any HTLC is sentNo path with enough outbound liquidity on your side and inbound on the recipient’sThe recipient is offline but reachable through a public channel; routing can still succeed
Payment hangs, then failsAn HTLC was in flight and a hop did not forward in timeThe recipient rejected the payment; that returns an error quickly
Payment fails repeatedly at the same hopThat channel’s balance is exhausted in the needed directionYour own channel is the bottleneck; check both ends
Payment succeeds but balance looks wrongIn-flight HTLCs are reserved until settled or timed outA fee was deducted; fees are small but visible

A payment that fails after an HTLC was locked has temporarily reduced the spendable balance along that path. The funds are not lost; they return when the timelock expires. Repeated failures at the same hop usually indicate a liquidity problem rather than a software fault.

Common questions

How does the Lightning Network work without putting every payment on-chain?

Payments are signed balance updates inside a channel funded by one on-chain transaction. The chain only records the open and the close. Each update supersedes the last, so a channel can carry many payments on a single deposit.

What is a lightning channel and who controls it?

A channel is a multisignature output funded on-chain and controlled by two parties. Each holds signed commitments describing how the balance would split if broadcast. Neither can move the other's side without a valid commitment and, in a dispute, a timelock.

Why can't I receive a Lightning payment to a new channel?

A channel funded entirely from your side has outbound liquidity but no inbound liquidity. To receive, some capacity must exist on the counterparty's side. Wallets solve this by opening channels with funds on both sides or by routing through an intermediary.

What is a custodial lightning wallet?

A wallet where an operator holds the channel funds and you hold a claim on the operator. Payments are convenient and liquidity is managed for you, but the operator can move the funds without your participation. A self-custody wallet holds the channel keys yourself and makes you responsible for liquidity and uptime.

What happens if my node goes offline with open channels?

If a counterparty broadcasts a revoked commitment while you are offline, you have until the timelock expires to respond. A watchtower can monitor and submit the penalty transaction on your behalf, but it must be configured before the event and does not remove the risk entirely.

Read next