UNDER DEVELOPMENT - DRAFT
Skip to main content
ln.university
LN 100 Fundamentals Lesson 05 Lesson 5 of 7 · 5 min · no measured block
Lesson 05 Reading lesson revised

Routing is not sending

A payment crosses a chain of channels, and every channel needs enough room in the direction of travel at the moment the payment arrives. The sender can see which channels exist, what each one charges and what limits it advertises, but not how each balance is split. So it picks a path and learns by trying. This lesson shows why a payment can fail on one hop even though the sender saw a path. It uses chapter 12 of Mastering the Lightning Network and two Lightning specifications, BOLT 4 and BOLT 7.

After this lesson you can
  • Say which channel limits a payment must satisfy at every hop
  • Compute the amount that each hop must carry when every forwarding node charges a fee
  • Read a failure message as information about one channel
Anchor text · read alongside CC-BY-SA-4.0 · free online
Chapter 12 · anchor
Mastering the Lightning Network
Andreas M. Antonopoulos, Olaoluwa Osuntokun, René Pickhardt
"Pathfinding and Payment Delivery", the sections on capacity, balance and liquidity, on uncertainty, and on the trial-and-error loop. This lesson's §2 and §4 condense them.
Read the chapter →

A payment crosses a chain of channels, and every channel needs enough room in the direction of travel at the moment the payment arrives. The sender sees which channels exist, what each one charges and which limits it advertises, but not how each balance is split. So it picks a path and learns by trying. A single channel can pass a payment only up to the room it has in that direction. This lesson shows why a payment can fail on one hop even though the sender saw a path.

A path is a list of channels, a route adds the amounts

A path is the sequence of channels. A route is that path plus the amount and expiry for the HTLC on each channel.1 The sender builds the route, and then it offers one HTLC to its first peer. Every other node on the path offers its own HTLC to the next node, with the amount and expiry that the onion tells it to use. Lesson 4 shows the mechanism. Each node can fail the HTLC if its own outgoing channel has no room, and the sender cannot know that in advance. A path can exist and still carry no payment.

What each hop must carry

Each forwarding node keeps a fee from the amount, so the amounts fall along the route, and the first channel carries the most. BOLT 7 says a node SHOULD accept an HTLC that pays at least:

fee_base_msat + (amount_to_forward * fee_proportional_millionths / 1000000)

The node publishes fee_base_msat and fee_proportional_millionths in its channel_update for the outgoing channel. BOLT 7 also says that a sender calculates amounts and expiries backward from the destination, because each fee depends on the amount that the next hop must receive.

The table reuses the worked example from lesson 4. A pays D through B and C. D wants 1 000 000 sats, which is 1 000 000 000 msat. C and B each charge a base fee of 0 and 100 ppm on their outgoing channels. No real node is involved.

ChannelHTLC amount (msat)Fee kept by the node that receives this HTLC
C to D1 000 000 0000
B to C1 000 100 000100 000 (C’s fee on 1 000 000 000)
A to B1 000 200 010100 010 (B’s fee on 1 000 100 000)

C’s fee is 1 000 000 000 × 100 / 1 000 000 = 100 000 msat. B’s fee is 1 000 100 000 × 100 / 1 000 000 = 100 010 msat. A’s first channel needs room for 1 000 200 010 msat, which is 1 000 200.010 sats. A pays 200 010 msat in fees in total, and D receives the full 1 000 000 sats.

Each channel in the route must also satisfy its own limits for the amount it carries. The amount must be at least htlc_minimum_msat, and a sender should keep it at or below the advertised htlc_maximum_msat. It also needs to fit under the in-flight limits from lesson 2. For a pending HTLC, the amount counts against the offerer’s liquidity until the HTLC is fulfilled or failed.

What the sender knows, and what it does not

The public data tells the sender which channels exist and what each direction charges. A channel_update carries fees, a delay, an HTLC minimum and maximum, and a flag that disables the direction. It does not carry the balance. The sender knows the balances of its own channels only.

Each attempt teaches the sender something about the channels it used. If the payment succeeds, then every channel on the path had at least that much liquidity. If it fails with a temporary channel failure, the most likely cause is that one channel lacked the liquidity for that amount.

Adapted from Mastering the Lightning Network, ch. 12, Pathfinding and Payment Delivery · CC-BY-SA-4.0 · condensed, terminology aligned to this course

So a sender works with a range for each channel it does not own. The book bounds the liquidity of one side between the reserve and the capacity minus the reserve, and each attempt narrows the range. This is why pathfinding is a loop of tries, and why a failed payment is normal operation and not an incident.

What a failure tells the sender

BOLT 4 defines the failure codes that a node can return. Five matter most here, and each one names one channel:

CodeMeaning, from BOLT 4What the sender can do
temporary_channel_failureThe channel was unable to handle this HTLC but may handle it, or others, later.Try another path, or a smaller part.
amount_below_minimumThe amount was below the channel’s htlc_minimum_msat.Raise the amount, or choose another channel.
fee_insufficientThe HTLC did not pay a sufficient fee.Recompute with the fresh channel_update, which the failure carries.
incorrect_cltv_expiryThe expiry did not satisfy the channel’s delta.Recompute with the fresh channel_update.
channel_disabledThe channel is disabled.Choose another channel.

The middle three can arise when the sender’s copy of a policy is out of date.2 Each failure returns the current channel_update, so the next attempt can use it.

When an attempt fails, each node on the earlier part of the path removes the HTLC it offered, and no balance changes. The attempt costs no routing fee.

Splitting a payment

A payment that does not fit any single path can be split. With basic_mpp, a sender may send several HTLCs with the same payment_hash, each with its own amt_to_forward, and a total_msat that states the whole amount. The recipient does not fulfill any part until the parts add up to total_msat. If the parts do not arrive in time, the recipient fails them all, and BOLT 4 suggests waiting at least 60 seconds after the first part before it does. Each part is a separate route and obeys all the limits in this lesson. The book notes that splitting gives the payment more paths with enough room.

What to take from this

One channel limits you to its balance. A path adds three conditions: every channel needs room in the direction of travel, the first channel carries more than the recipient receives, and the sender does not know the balances, so its attempts are tests. The next lesson takes the fee that each node charges and asks how a node should set it.

Check yourself · 3 questions no score, no record
  1. 01 You send a payment and get back `temporary_channel_failure` from the second forwarding node on the path. What do you learn about your own first channel?
  2. 02 Three channels on a path each have 1 000 000 sats of room in the direction of travel. You send 1 000 000 sats to the recipient. Does the payment go through?
  3. 03 Two senders pay the same recipient in the same minute, over the same graph. One payment succeeds and one fails. Name two reasons that both follow from this lesson.

Notes

  1. The glossary keeps path for the sequence of channels and route for the path plus the amount and expiry at each hop. The book uses routing for the act of forwarding a payment along a chosen path and pathfinding for the choice of the path, so the two sources split the words differently.Mastering the Lightning Network, ch. 8
  2. BOLT 7 asks a node that changes its channel parameters to keep accepting the previous ones for 10 minutes. A sender that works from an older channel_update can therefore still get its payment through for a short time.BOLT 7, channel_update

Source & license

This page adapts Mastering the Lightning Network by Andreas M. Antonopoulos, Olaoluwa Osuntokun, René Pickhardt, licensed CC BY-SA 4.0. Adapted passages are marked in the text with a hairline rule and a source line. Changes: condensed, re-sequenced into lesson order, terminology aligned to this course's glossary, and the book's example replaced with one whose amounts follow the fee formula in BOLT 7.

This page is therefore also CC BY-SA 4.0. Copy it, translate it, teach from it, republish it under the same license, with attribution to the works above and to ln.university.