askrene: fixup fee and delay computation #7639
Closed
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.
Askrene fixup fee and delay computation
Description
Sendpay's API expects a route description where the i-th hop contains an amount corresponding to "The amount expected by the node at the end of this hop" and a delay field corresponding to "The total CLTV expected by the node at the end of this hop".
That means the final amount and the final cltv is what is expected in the last hop and we compute backwards from there
the amounts and delays for the rest of the hops.
Eg. the chain of nodes
N1 ---> N2 ---> N3 ---> N4
where
N1-->N2 are connected by channel c12 with zero proportional fee and 3 base fee, delay 6
N2-->N3 are connected by channel c23 with zero proportional fee and 10 base fee, delay 6
N3-->N4 are connected by channel c34 with zero base fee and 2 ppm proportional fee, delay 6
If we want to send x=1e6 msat with final CLTV=10, sendpay expects
[{channel: c12, node: N2, delay: 22, amount: 1000012msat},
{channel: c23, node: N3, delay: 16, amount: 1000002msat},
{channel: c34, node: N4, delay: 10, amount: 1000000msat}]