Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

askrene: fixup fee and delay computation #7639

Closed
wants to merge 1 commit into from

Conversation

Lagrang3
Copy link
Collaborator

@Lagrang3 Lagrang3 commented Sep 4, 2024

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}]

@Lagrang3 Lagrang3 force-pushed the askrene-fixup branch 2 times, most recently from 661412e to 2fbfa76 Compare September 4, 2024 14:33
@rustyrussell rustyrussell self-assigned this Sep 24, 2024
@rustyrussell rustyrussell added this to the v24.11 milestone Sep 24, 2024
@ShahanaFarooqui ShahanaFarooqui force-pushed the askrene-fixup branch 3 times, most recently from 6c1f2f6 to fdfd9de Compare September 25, 2024 19:10
@Lagrang3 Lagrang3 force-pushed the askrene-fixup branch 2 times, most recently from ea456a3 to 748dc8c Compare September 30, 2024 07:29
@Lagrang3 Lagrang3 changed the title askrene: fixup fee computation askrene: fixup fee and delay computation Sep 30, 2024
Changelog-EXPERIMENTAL: fixup to askrene to compute fees on routes correctly.

Signed-off-by: Lagrang3 <[email protected]>
@rustyrussell
Copy link
Contributor

No, this is deliberate; the sendpay API is wrong.

@Lagrang3 Lagrang3 deleted the askrene-fixup branch December 2, 2024 08:13
@Lagrang3
Copy link
Collaborator Author

Lagrang3 commented Feb 4, 2025

Hi @rustyrussell, I know sendpay API is a bit messed up.
But if the amounts and delays were correct in getroutes output, let's say correct in the sense of readiness
and no further processing is necessary before using those numbers to feed into injectpaymentonion, then
how come xpay parses from getroutes hops the amount as amount_in while using amount_out (which is the same
as amount_in but shifted by 1 index) to pass to injectpaymentonion?

hops[j-1].amount_out = hop->amount_in;

I stumbled upon this while adding getroutes to renepay.
It is a bit awkward to read the paths array and shift one of the fields by one index for apparently no reason.

Is it too late to redefine the meaning of amount_msat in the hops?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants