Pathfinding

Intelligent Pathfinding

Use reliable routes to send your lightning payments. With machine learning, it's possible to get a better understanding of the liquidity inside the Lightning Network and where it's positioned. Intelligent pathfinding can calculate routes with higher success probability.

📖

Read our research paper here (opens in a new tab).

Usage

To request a route using our API, you need to provide:

  • Source node
  • Payment request or target node + amount

Currently we provide a response formatted for LND, which can be used in SendToRoute (opens in a new tab)

API

Get access to our pathfinding through our API

Algorithm Explanation

The pathfinding endpoint uses a modified Djikstra's algorithm (opens in a new tab) to find paths between a pair of nodes. Dijkstra's algorithm is a classic pathfinding algorithm for finding the shortest path from a source node to all other nodes in a graph. In generic examples of this algorithm, physical distance between nodes used to calculate the weight of a path. However, any weight function can be used as long as it is:

  • non-negative (no zero or negative weighted edges)
  • deterministic (the same input gives the same output)

In the context of the Lightning Network, pathfinding decisions are typically made regarding fees and latency, not physical distance. Amboss' pathfinding endpoint uses a weight function that considers not only the cost of the path, but also the expected reliability of the path.

Weight Function

The weight of each edge ee is

w(e)=log(P(e)fece+1)+μfefee(e)w(e) = \textcolor{blue}{-\log\left(\frac{P(e) - f_e}{c_e + 1}\right)} + \textcolor{red}{\mu \cdot f_e \cdot \text{fee}(e)}

Where:

  • fef_e represents the flow (payment amount) through edge ee.
  • cec_e is the channel capacity for edge ee.
  • P(e)P(e) is the estimated channel balance for edge ee according to our model.
  • μ\mu is an arbitrary multiplier that weights the importance of fees.

This weight function balances reliability and cost in path selection. The first term, in blue, reflects the reliability of the path, with higher reliability associated with a lower weight. The second term, in red, accounts for the cost of fees along the path.

All else equal, the algorithm will prefer paths with higher reliability. Conversely, if two paths have the same reliability, the algorithm will prefer the path with lower cost. The purpose of μ\mu in the cost function is to control the relative impact of the fee component in the overall path weight. By adjusting μ\mu, the algorithm can place more or less emphasis on minimizing fees versus maximizing reliability.

This function is almost identical to René Pickhardt and Stefan Richter's work on Optimally Reliable Payment Flows. Their work explores methods for improving payment routing on the Lightning Network by considering reliability and cost in multi-path payments. Read their work here. (opens in a new tab)

Instead of using the channel's capacity, as in their work, this weight function uses the channel balance predictions from our trained model to estimate the reliability of a channel. By leveraging these predictions, the algorithm dynamically adjusts to changes in the network's liquidity. This results in fewer payment failures and more efficient routing.

Improving Model Accuracy and Selection for Payment Paths

Amboss has been able to achieve accurate predictions so far thanks to the nodes that have opted to share their channel balance data. Opting in to share your own channel balance data would further enhance our predictions and benefit the entire network.

For nodes aiming to increase their likelihood of being selected for payment paths, two key factors come into play: First, opening high capacity channels typically increases the predicted success probability of transactions through your node. Second, low fees reduce the cost in the weight function, making your node more likely to be selected in the pathfinding algorithm.