THAMER
Sovereign Bitcoin Wallet

WALLET AI BITCOIN

Your Bitcoin Wallet. Your Keys. Your Engine.

Self-hosted Bitcoin software built for developers, applications, and AI agents.

CREATE WALLET

Lightning Network Routing and Liquidity: How Payments Find Paths

permalink THAMER
#inbound-liquidity#lightning-routing#outbound-liquidity#payment-channels#routing-fees

Lightning routing finds a path across payment channels so a sender can pay a recipient without opening a direct channel. A path may exist in the network graph but still fail because channels lack usable liquidity in the needed direction.

Public channel information versus balances

Nodes can learn advertised channels and forwarding policies through gossip. However, publicly advertised capacity does not reveal the current directional balance of a channel. A route finder therefore makes estimates and learns from payment attempts rather than knowing every channel's exact spendable liquidity.

Private channels and changing policies make routing more complicated. A route that worked previously may not work now.

Inbound and outbound liquidity

Outbound liquidity is the amount a node can send through a channel in a given direction. Inbound liquidity is the amount it can receive from the peer in that channel. A service can have substantial channel capacity but still struggle to receive payments if most capacity is on its own side.

Liquidity can be managed through channel openings, spending patterns, swaps, or rebalancing, each with costs and tradeoffs. These methods are operational choices rather than guarantees.

Routing fees and constraints

Forwarding nodes can charge a base fee and a proportional fee according to their advertised policies. Payment senders may impose maximum fees, timeouts, and hop limits. A cheaper route is not necessarily the most reliable route, and a route that succeeds for a small amount may fail for a larger one.

Why payments fail

Common reasons include insufficient directional liquidity, expired invoices, unavailable peers, forwarding policy mismatches, or temporary channel failures. Applications should surface actionable errors without exposing sensitive node information unnecessarily.

Developer checklist

Record payment attempts separately from final payment status. Bound retries and fees, avoid duplicate settlement, respect invoice expiry, and distinguish a route search failure from a failed on-chain transaction. When comparing Lightning with ordinary Bitcoin transfers, account for channel liquidity and operational availability rather than only headline transaction speed.

Primary references

BOLT 7 — P2P Node and Channel Discovery: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md

BOLT 4 — Onion Routing Protocol: https://github.com/lightning/bolts/blob/master/04-onion-routing.md

Lightning specifications: https://github.com/lightning/bolts

Questions & Answers

Explore all questions →

Latest from the Lab

THAMER illustrated developer portrait and signature

ABOUT THE DEVELOPER

Independent Software Developer specializing in Bitcoin Script, Golang, and AI Agents.

Software engineering · Independent research · Open-source projects