Routing Algorithm Visualizer

Interactive exploration of Lightning Network pathfinding: Dijkstra (fee-minimization), Pickhardt MCF (probability-maximization), and SpeedyMurmurs (landmark-based). Adjust payment size, select an algorithm, and watch the payment flow.

1. Why Routing in Payment Channel Networks is Hard

In the Lightning Network, nodes must route payments through a series of payment channels without any central coordinator. Unlike IP routing, PCN routing faces fundamental obstacles that make pathfinding uniquely challenging.

Incomplete Liquidity Information

BOLT #7 gossip only reveals channel capacity, not the current balance split. A channel with capacity 100k sat could have 1k or 99k on your side — you cannot know without probing.

Privacy Constraints

Balance information is intentionally hidden. Revealing balances would allow network-wide traffic analysis and deanonymize payment flows. Privacy and routability are in direct tension.

Dynamic State

Channel balances change with every payment. A path computed at time T may already be exhausted by the time the HTLC arrives. The network is non-stationary.

Atomic All-or-Nothing

HTLC execution is atomic: the payment either succeeds end-to-end or fails entirely. A single bottleneck hop with insufficient balance aborts the entire path.

Concurrency Interference

Multiple in-flight HTLCs lock liquidity simultaneously. A routing node sees reduced effective balance during concurrent payments, causing false failures.

Fee Market Complexity

Each channel has a base fee + fee rate. The fee-optimal path may have very different liquidity characteristics from the probability-optimal path.

The Three Main Approaches

Dijkstra Fee Minimization

Classic shortest-path on a fee-weighted graph. Fast (O(E log V)) but ignores balance probability. Widely deployed in early LND. Fails frequently on low-balance paths.

Pickhardt MCF Probability Maximization

Models balance as a uniform random variable. Minimizes −log P(success) via min-cost flow. Natively supports MPP splitting. 95%+ success rate in practice. Now used in LND + CLN.

SpeedyMurmurs Landmark Routing

Each node computes an embedding (distance vector) relative to a set of landmark nodes. Routing decisions are local — each hop routes greedily toward the destination's landmark coordinates.

2. Interactive Payment Network Graph

30k sat
Ample balance
Moderate
Low outbound
Selected path

Algorithm Info

AlgorithmDijkstra
Amount30,000 sat
Path
Fee
Hops
Success P
Select an algorithm and press Run
STEP LOG

3. Multi-Path Payments (MPP) Explorer

Large payments that exceed a single channel's balance can be split across multiple paths. MPP uses the same payment hash on all parts — atomicity is preserved because all parts must arrive before Grace can claim the preimage.

Payment: 100,000 sat from Alice → Grace
Path 1 — 40,000 sat

Alice → Bob → Dave → Grace

Path 2 — 35,000 sat

Alice → Carol → Dave → Grace

Path 3 — 25,000 sat

Alice → Carol → Frank → Grace

Atomicity via Payment Hash: All three HTLCs share the same payment_hash. Grace holds a single preimage R and only reveals it once all partial amounts arrive (total = 100,000 sat). If any path fails, the others time out and are cancelled. This is the all-or-nothing guarantee of MPP.

4. Channel Rebalancing Visualizer

When Alice's side of the Alice-Bob channel is depleted, she cannot route payments through Bob. The solution: Alice pays Bob, who pays Carol, who pays Alice — a circular payment that rebalances liquidity at the cost of small routing fees.

Circular payment: Alice → Bob → Carol → Alice (20,000 sat)
Alice → Bob Channel
5k95k

Alice:Bob split

Bob → Carol Channel
70k30k

Bob:Carol split

Carol → Alice Channel
60k40k

Carol:Alice split

Press "Run Rebalancing" to animate the circular payment.

5. Algorithm Comparison

Click a row to highlight that algorithm's behavior in the graph above.

Feature Dijkstra Pickhardt MCF SpeedyMurmurs
Optimization target Min total fee Max success probability Min routing table size
Success rate
~60%
~95%
~75%
Privacy Medium Medium Better (local info only)
Computation O(E log V) O(E log E) O(log N) per hop
MPP support No Yes (native) Partial
Handles unknown balances Ignores (assumes full) Probability distribution Embedding distance proxy
Real-world use LND (legacy) LND / CLN (modern) Research prototype

6. Liquidity Discovery Problem

The fundamental challenge: BOLT #7 gossip only reveals channel capacity. Balance split is private to channel endpoints. This creates the liquidity uncertainty that all routing algorithms must navigate.

What Gossip Reveals

Channel capacity (total sat locked), fee rates, CLTV delta, and whether the channel is active. Balance split is never broadcast.

Probing Attack

Send a fake HTLC with an invalid payment hash. If it bounces with unknown_payment_hash, the channel has sufficient balance. If temporary_channel_failure, it doesn't. Violates privacy.

Pickhardt's Insight

Treat balance as a continuous uniform random variable on [0, capacity]. Success probability = amount / capacity. No probing needed — just maximize the product of per-hop probabilities.

After Failed Attempt

A failed payment at amount X reveals that balance < X. Update the probability distribution: now uniform on [0, X−1]. This Bayesian update improves subsequent routing attempts.