Repository navigation
Conversation
Lagrang3
marked this pull request as draft
October 14, 2026 08:40
Lagrang3
force-pushed
the
xpay-limit-path-length
branch
2 times, most recently
from
October 15, 2026 10:12
8045aef to
4eda748
Compare
Add onion budget and payload constructors to the internal xpay API. Onion budget computation can be used to know a realistic number of hops that constraints our payment before calling askrene. Changelog-None Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
Changelog-None Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
Added an homogeneous and constant cost to every hop in the MCF solver. We have also added a developer option "maxhops" to limit the length of routes. The algorithm is based on the added cost per-hop. In order to seek for a solution that satisfies the maxhops constraint the cost per hops is incremented gradually. Changelog-Fixed: askrene-getroutes: penalizes every extra hop in every route with an homogeneous and constant probability of failure of 1%, as a consequence askrene will slightly prefer smaller routes. Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
Changelog-Added: askrene: getroutes: maxhops, a parameter to limit the length of the paths in the solutions. Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
Changelog-Fixed: xpay: Clamp the length of the payment routes using askrene's maxhops option aiming at producing routes that fit the data limits in the onion packet. Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
Changelog-None Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
Lagrang3
force-pushed
the
xpay-limit-path-length
branch
from
October 16, 2026 20:50
4eda748 to
f79367b
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses: #9156
Supersedes: #9539
This PR adds a new constraint into askrene:
maxhops, to limit the length of the routes.Hard constraints of path length is not possible under the current implementation, minimum cost flows
do not allow that. Our approach is to add a constant cost per hop (a similar tweak in renepay #7540 was already deployed)
and scale that cost until the computed routes fit the
maxhopsconstraints.Fewer hops are expected with a base cost per hops and a
getroutesfailure if no routing solutionsare found satisfying
maxhopsconstraint.On
xpaywe compute theonion budgetfor each payment as the maximum number of hops we can afford to put insidean onion message given the hard limit of 1300 bytes for the onion package, payment amount, blockheight and tail
(ie. final payload in the case of bolt11 and blinded path plus final payload in the case of bolt12).
The onion budget is passed down to
getroutesso that solutions will not exceed it.No more "Could not create payment onion: path too long!" errors are expected afterwards, instead we might
get an error from
getroutesif no solutions can be found with themaxhopslimit.TODO:
onion_budget,maxhopsconstraint intoaskrene,maxhopsinaskrene,xpaywith heavy final payloads bolt11,xpaywith heavy final payloads bolt12,maxhopsfrom a developer option to a user option and add documentation formaxhops,