For educational purposes, i write this article with a precise description of what really happens when we pay a Lightning invoice from start to finish. This note follows a single 500 sat payment across the Lightning Network, from the invoice to the final settlement. The payment was sent from the SatsRouting node and went through one intermediate node to the recipient. All values come from the sender’s own LND output (decodepayreq, queryroutes, payinvoice --json, trackpayment). What the other two nodes did is inferred from the protocol (BOLT 2, 4 and 11), since their logs are not available.
The invoice is published in full. It was single-use and has already been paid. The preimage and the channel balances have been left out on purpose.
1. The invoice
lnbc5u1p4sdrnppp5f8gfvxwjp25tehncd46lwqzg85csv2689rrxu5h6xuxv5c2lge3qdqcwpshjmt9de6zqar9wd6rqvp3cqzzsxqyz5vqsp5tfu52c0d7w6pgy0mx49ugg0ru5tkgay87gmujk7sxen2d7hwla9q9qxpqysgqdars79wftjx9haapv306zal384574kckksjp88txj7jjkdxlsl03qvmhp04wvcn54n05naffmu6n2l2h9wg0gyws9dyjvzgdm8qmascpw84c70The human-readable prefix lnbc5u means mainnet (lnbc) and 5 micro-BTC (5u), that is 500 sat. The 1 separates it from the bech32 data part. Decoded with lncli decodepayreq:
{
“destination”: “0324ba2392e25bff76abd0b1f7e4b53b5f82aa53fddc3419b051b6c801db9e2247”,
“payment_hash”: “49d09619d20aa8bcde786d75f700483d31062b4728c66e52fa370cca615f4662”,
“num_satoshis”: “500”,
“timestamp”: “1795591777”,
“expiry”: “86400”,
“description”: “payment test001”,
“description_hash”: “”,
“fallback_addr”: “”,
“cltv_expiry”: “80”,
“route_hints”: [],
“payment_addr”: “5a794561edf3b41411fb354bc421e3e517647487f237c95bd03666a6faeeff4a”,
“num_msat”: “500000”,
“features”: {
“8”: {”name”: “tlv-onion”, “is_required”: true, “is_known”: true},
“14”: {”name”: “payment-addr”, “is_required”: true, “is_known”: true},
“17”: {”name”: “multi-path-payments”, “is_required”: false, “is_known”: true},
“25”: {”name”: “route-blinding”, “is_required”: false, “is_known”: true}
},
“blinded_paths”: []
}What the fields mean:
destination: the node that collects the payment, “kappa”. Recovered from the invoice signature, because the invoice has no n field.
payment_hash: SHA-256 of a preimage that only the recipient knows.
payment_addr: the payment secret (BOLT 11 tag s). The recipient accepts the payment only if it finds this value in the last hop’s payload.
timestamp and expiry: valid for 86,400 s after creation. It was paid about 95 s after creation.
cltv_expiry: min_final_cltv_expiry, 80 blocks beyond the current height at the last hop.
route_hints and blinded_paths: empty, so the recipient is reachable through the public graph.
features 8 and 14: required (TLV onion payloads and payment secret).
features 17 and 25: optional (multi-part payments and blinded paths, not used here).
2. The route
The sender asked for a route with queryroutes (final CLTV delta 80, mission control enabled). The result had two hops:
SatsRouting -> bfx-lnd0 -> kappa
Hop 1, to bfx-lnd0:
Channel: 1067680766186946561 (short channel id 971050x535x1)
Node: 033d8656219478701227199cbd6f670335c8d408a92ae88b962c49d4dc0e83e025
Amount forwarded: 500,000 msat
Fee: 1,000 msat
Outgoing CLTV: 977564
Hop 2, to kappa (final):
Channel: 1068326179496722433
Node: 0324ba2392e25bff76abd0b1f7e4b53b5f82aa53fddc3419b051b6c801db9e2247
Amount forwarded: 500,000 msat
Fee: 0
Outgoing CLTV: 977564
The HTLC leaving the sender carried 501,000 msat with an absolute timelock of block 977644. The estimated success probability was 0.847. The payment succeeded on the first attempt.
3. Per-hop data
The JSON below is the route as returned by LND for the successful attempt. The onion payloads that follow are reconstructed from these values following BOLT 4. LND does not expose the raw onion bytes, so the hex is not an observation from the wire.
Hop 1 (forwarding hop, bfx-lnd0)
{
“chan_id”: “1067680766186946561”,
“amt_to_forward”: “500”,
“fee”: “1”,
“expiry”: 977564,
“amt_to_forward_msat”: “500000”,
“fee_msat”: “1000”,
“pub_key”: “033d8656219478701227199cbd6f670335c8d408a92ae88b962c49d4dc0e83e025”,
“tlv_payload”: true,
“mpp_record”: null,
“amp_record”: null,
“custom_records”: {}
}Onion payload (length byte 0x14, then 20 bytes):
14 020307a120 04030eea9c 06080ed12a0002170001type 2, amt_to_forward: 07a120 = 500,000 msat
type 4, outgoing_cltv_value: 0eea9c = 977564
type 6, short_channel_id: 0ed12a0002170001 = 971050x535x1
Hop 2 (final hop, kappa)
{
“chan_id”: “1068326179496722433”,
“amt_to_forward”: “500”,
“fee”: “0”,
“expiry”: 977564,
“amt_to_forward_msat”: “500000”,
“fee_msat”: “0”,
“pub_key”: “0324ba2392e25bff76abd0b1f7e4b53b5f82aa53fddc3419b051b6c801db9e2247”,
“tlv_payload”: true,
“mpp_record”: {
“payment_addr”: “5a794561edf3b41411fb354bc421e3e517647487f237c95bd03666a6faeeff4a”,
“total_amt_msat”: “500000”
},
“amp_record”: null,
“custom_records”: {}
}Onion payload (length byte 0x2f, then 47 bytes):
2f 020307a120 04030eea9c 0823 5a794561edf3b41411fb354bc421e3e517647487f237c95bd03666a6faeeff4a 07a120type 2, amt_to_forward: 07a120 = 500,000 msat
type 4, outgoing_cltv_value: 0eea9c = 977564
type 8, payment_data: the 32-byte payment secret followed by total_msat 07a120
The last hop has no short_channel_id because there is nothing left to forward to. The total_amt_msat: “0” shown at hop level is normal; the real total is inside the MPP record.
4. Step by step
Steps marked (observed) come from the sender’s LND. Steps marked (inferred) follow from the protocol.
The recipient creates a random preimage, computes its SHA-256 as the payment hash, adds a payment secret and signs the invoice. (inferred)
The sender decodes the invoice and checks checksum, signature, network, amount and expiry. The invoice was still valid, about 95 s after creation. (observed)
The sender finds the two-hop route above. (observed)
The sender builds the onion from the last hop backwards: the final payload first, then the fee and CLTV delta of the intermediate node. Each hop gets its own encrypted layer, so a node only sees its own instructions. (values observed, bytes inferred)
The sender adds an HTLC of 501,000 msat to the channel with bfx-lnd0 (update_add_htlc), with the payment hash, a timelock of 977644 and the onion. After the commitment exchange (commitment_signed, revoke_and_ack) the HTLC is locked in on both sides. (HTLC observed, exchange inferred)
bfx-lnd0 decrypts its layer and reads: forward 500,000 msat on channel 1068326179496722433 with CLTV 977564. It checks that incoming minus outgoing amount is at least its fee (1,000 msat base plus 1 ppm, which truncates to nothing on this amount) and that the CLTV difference is at least its delta (80). It then opens an HTLC towards the recipient and keeps 1,000 msat. (inferred)
The recipient decrypts the final payload and checks that the payment secret matches, the amount matches the declared total, the CLTV is at least current height plus 80, and the hash belongs to an open invoice. It then releases the preimage with update_fulfill_htlc. (inferred)
The preimage travels back: recipient to bfx-lnd0, then bfx-lnd0 to the sender. The sender closes the HTLC as succeeded and checks that SHA-256(preimage) equals the payment hash. The HTLC was in flight for about 650 ms. (result observed, middle step inferred)
5. Fees
The total fee was 1 sat (1,000 msat), paid to the intermediate node, bfx-lnd0. Its policy on the channel towards the recipient is a base fee of 1,000 msat plus 1 ppm. On 500,000 msat the proportional part is 0.5 msat and is truncated, so only the base fee remains. The sender pays no fee to itself, and the recipient charges none because it is the final destination (its forwarding policy of 0 base and 300 ppm would only matter if it were forwarding). The fee limit was set to 5 sat, and the queryroutes estimate (1 sat) matched the actual cost.
The channel between bfx-lnd0 and the recipient appears in the gossip graph with a null funding outpoint and zero capacity, so it looks like an unannounced or virtual channel. Its real capacity cannot be verified from the graph.
6. How the CLTV values are built
CLTV is the absolute timelock of an HTLC, counted in blocks. Until that block the HTLC can be claimed with the preimage; after it, the party that created the HTLC can take the funds back. It has nothing to do with the invoice expiry, which is a time in seconds.
Each node needs more time than the next one. If the recipient revealed the preimage at the last possible block, the intermediate node must still have time to claim from the previous channel, even on-chain if the channel closes. The minimum margin is the node’s cltv_expiry_delta, 80 blocks here (about 13.3 hours).
LND builds the values from the end:
Block height when paying: 977481
Plus LND block padding (3): 977484
Plus min_final_cltv_expiry (80): 977564, the outgoing CLTV of the last hop
Plus the intermediate node’s delta (80): 977644, the timelock of the HTLC leaving the sender
The sender’s own channel delta is not added, because the delta applies to nodes that forward. In the hop JSON, expiry is the timelock of the HTLC leaving that node, so both hops show 977564 and 977644 appears only as the route’s total time lock.
The intermediate node rejects the HTLC if its incoming timelock minus the outgoing CLTV is below its delta. The recipient rejects it if the CLTV is below current height plus 80. If the preimage had never been released, the recipient’s HTLC would have expired at block 977564 and the sender would have been refunded at block 977644, roughly 27 hours later in the worst case. In practice the payment settled in well under a second.
7. Limits of this write-up
The onion bytes are reconstructed, not captured. Only the intermediate and final nodes could show the exact bytes they received.
What bfx-lnd0 and the recipient did is derived from the protocol rules and from the numbers in the route, not from their logs.
The block height was read a few seconds before the payment, so 977481 is accurate to within a block or two. The timelocks 977564 and 977644 come straight from the payment record.
Follow this publication and youtube channel for more value added content: https://www.youtube.com/@massmux


