Routing

From claude-dev-suite/claude-dev-suite · View interactive version

Routing is an AI agent skill from the GitHub repository claude-dev-suite/claude-dev-suite. Lightning pathfinding and routing: cost models, MPP / AMP / trampoline, blinded paths (BOLT 4 update), apriori probability, pickhardt-payments. USE WHEN: implementing/tuning a routing algorithm, debugging "no route" errors, evaluating pathfinding strategies.

How to use this skill

Skill file

Lightning Routing

Lightning is a source-routed network: the sender computes the full

path through intermediaries and constructs the onion accordingly. Each

hop sees only its forwarding instructions, not the full route.

Channel graph

Built from channel_announcement + channel_update gossip:

Edge {
  short_channel_id,
  node_a, node_b,
  capacity (from on-chain funding tx),
  per-direction:
    fee_base_msat,
    fee_proportional_millionths (PPM),
    cltv_expiry_delta,
    htlc_minimum_msat, htlc_maximum_msat,
    enabled flag,
}

Each edge has TWO directions, each with potentially different fees

and CLTV deltas.

Cost function

Standard scoring (LND, CLN, LDK):

cost(edge, amount) =
    base_fee_msat
  + (proportional_millionths × amount) / 10^6
  + cltv_delta × cltv_factor
  + amount × probability_factor / 10^6 × ln(1 / p_success)

p_success (apriori probability of success) often defaults to 95% for

unknown edges, decreasing with recent failures.

Pathfinder: Dijkstra or Yen's k-shortest-paths over the cost function.

Multi-Path Payments (MPP)

Split a payment across multiple paths; each part has the same payment

hash. Receiver claims when all parts arrive.

payment_secret (BOLT 11 's' tag) marks parts as belonging to one

payment.

max_parts typically 16 in LND, configurable. Smaller parts =

higher likelihood of finding routes; more onion overhead.

Atomic Multi-Path (AMP)

Each "part" has a different payment hash, computed deterministically

from a shared secret + per-part nonce. Receiver computes secret from

any t-of-n parts (Shamir-like). Variant of MPP, less common in

production.

Trampoline routing

Solves: pathfinding requires complete network gossip → mobile clients

can't keep up.

Mechanism:

destination.

CLN, LDK support; LND partial.

Blinded paths (BOLT 4 update, BOLT12)

Receiver constructs a "blinded path" — a partial route that hides the

final destination. Sender's pathfinder routes to the blinded path's

introduction node, then onion delivers via blinded routing data.

Privacy benefit: sender doesn't learn receiver's node id.

Pickhardt payments (probabilistic)

Research direction (Pickhardt-Nowostawski 2021):

liquidity at the moment.

CLN and LDK have implementations; experimental in production.

CLTV calculation

For a 3-hop route Alice → Bob → Carol → Dave:

final_cltv = current_height + min_final_cltv_expiry_delta + payment_secret_buffer
carol_cltv = final_cltv + carol.cltv_expiry_delta
bob_cltv   = carol_cltv + bob.cltv_expiry_delta
alice_cltv = bob_cltv   + alice's_safety_margin

alice_cltv is what's set in Alice's first HTLC.

Failure handling

When a hop fails:

mismatch, no liquidity, etc.).

failed edge) and retries with different path.

Common failure types (BOLT 4)

fee.

recognize this payment hash (BOLT 11 invoice expired or wrong).

(MPP not assembled correctly).

Implementations

| Algorithm | LND | CLN | LDK |

|-----------|-----|-----|-----|

| Dijkstra | yes | yes | yes |

| Multi-path (MPP) | yes | yes | yes |

| AMP keysend | yes | partial | yes |

| Trampoline | partial | yes | yes |

| Blinded paths | yes | yes | yes |

| Pickhardt-style | partial | yes | yes |

Common bugs

vs many-hop low-fee.

rejected (it means "no max" only when set to channel capacity).

been disabled an hour ago.

but route only first part).

See also

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.