The shortest distance between two points is a straight line. Everybody knows that. Except it’s not true — at least not outside of a Euclidean universe of mathematical abstraction. Everyone who’s watched lightning knows that it doesn’t travel in a straight line. Instead, lightning travels from one point in space to the next depending on the resistance it encounters, automatically finding the most efficient route, one infinitesimal segment at a time.Kinda beautiful, isn’t it? (Source: wikimedia)
Payments on the Lightning Network face a similar challenge, but the network doesn’t have nature’s optimization procedures built in. Lightning (we’re talking about the network now) requires plenty of thought, code, and adaptation to be as robust and efficient as possible. In this post, we’re going to explain how payment routing works on the Lightning Network, what aspects still need improvement, and the routing technologies of the future.Where Routing Stands Today
The first point to note is that routing already works on the Lightning Network. In fact, it works very well. On Android and the iPhone too.The Basics: Nodes, Channels, Onions
The fundamental building blocks of the Lightning Network are nodes and the payment channels (i.e. edges) that connect them. A node can be any user, merchant, or LSP. Payment channels connect (some) nodes to (some) other nodes.
Naturally, every node on the network will be connected to at least one other node, but it is not very likely that a given node, like your light client, will have a channel open with another given node, say Tschego and Lonny, whose bees make the best honey this side of Johannesburg. Opening a payment channel is an on-chain transaction, so having to open a channel for every new counterparty would defeat the purpose of having a second-layer network. Therefore, any payment between two unconnected nodes is better off finding a route through a series of existing payment channels.You’re n...