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

getroutes: amounts and delays are wrong #7550

Closed
daywalker90 opened this issue Aug 10, 2024 · 4 comments
Closed

getroutes: amounts and delays are wrong #7550

daywalker90 opened this issue Aug 10, 2024 · 4 comments

Comments

@daywalker90
Copy link
Contributor

I'm trying the new getroutes @rustyrussell and i encountered this:

regtest l1->l2->l3

[GetroutesRoutes { amount_msat: Amount { msat: 100000000 }, path: [GetroutesRoutesPath { amount_msat: Amount { msat: 100001001 }, delay: 11, direction: 1, next_node_id: PublicKey(*snip*), short_channel_id: ShortChannelId(114349209354240) }, GetroutesRoutesPath { amount_msat: Amount { msat: 100001001 }, delay: 11, direction: 0, next_node_id: PublicKey(*snip*), short_channel_id: ShortChannelId(114349209419776) }], probability_ppm: 900044 }]

with auto layers applied. Notice how the second Amount in the path is not Amount { msat: 100000000 } but Amount { msat: 100001001 } instead. So the l2 node does not get paid and errors rightfully with WIRE_FEE_INSUFFICIENT.

@daywalker90
Copy link
Contributor Author

using cln-rpc from master + #7549

@daywalker90
Copy link
Contributor Author

looking at the getroutes tests this seems to be expected behaviour?! If that's actually the case then it would be very different from getroute and what sendpay expects as a path structure!

@daywalker90
Copy link
Contributor Author

daywalker90 commented Aug 12, 2024

Another test with 4 nodes in a line graph:

[GetroutesRoutes { amount_msat: Amount { msat: 100000000 }, 
path: [
GetroutesRoutesPath { amount_msat: Amount { msat: 100002002 }, delay: 17, direction: 1, next_node_id: PublicKey(591da33c1e1cc154001a228933a53d926cc4857c44acf7f77fa459a32036222ddc43a957fdb57d8b5eaf8923daa676fba27e758020a8ecd46ab778cbb695da12), short_channel_id: ShortChannelId(115448721113088) }, 
GetroutesRoutesPath { amount_msat: Amount { msat: 100002002 }, delay: 17, direction: 0, next_node_id: PublicKey(5d885d3a9cb390c0806b76aad553c38bbc6e365d8740e5104e13badf92112b5d6bb8de8f265f6aea7859832ab48862da43eb4c2d8b6ff041a9a688ac25c62fa4), short_channel_id: ShortChannelId(115448721047552) }, 
GetroutesRoutesPath { amount_msat: Amount { msat: 100001001 }, delay: 11, direction: 0, next_node_id: PublicKey(99e19d2dcbc6568acf1f4995cace92994b29235fe3c27746d8e78bf1eb59ce82a7e4f407779fb5c98c36a2f25799f03fedd2479a4e94cf4af97d88dfb7691c54), short_channel_id: ShortChannelId(115448720982016) }],
probability_ppm: 810079 }]

[GetrouteRoute { style: TLV, amount_msat: Amount { msat: 100002002 }, channel: ShortChannelId(115448721113088), delay: 21, direction: 1, id: PublicKey(591da33c1e1cc154001a228933a53d926cc4857c44acf7f77fa459a32036222ddc43a957fdb57d8b5eaf8923daa676fba27e758020a8ecd46ab778cbb695da12) }, 
GetrouteRoute { style: TLV, amount_msat: Amount { msat: 100001001 }, channel: ShortChannelId(115448721047552), delay: 15, direction: 0, id: PublicKey(5d885d3a9cb390c0806b76aad553c38bbc6e365d8740e5104e13badf92112b5d6bb8de8f265f6aea7859832ab48862da43eb4c2d8b6ff041a9a688ac25c62fa4) }, 
GetrouteRoute { style: TLV, amount_msat: Amount { msat: 100000000 }, channel: ShortChannelId(115448720982016), delay: 9, direction: 0, id: PublicKey(99e19d2dcbc6568acf1f4995cace92994b29235fe3c27746d8e78bf1eb59ce82a7e4f407779fb5c98c36a2f25799f03fedd2479a4e94cf4af97d88dfb7691c54) }]

I believe the tests and code are wrong for getroutes. Since the nodes and channel id's match getroute output i believe that the intent was not to change the structure of these paths and therefore the amounts and delays in getroutes are wrong.

  • the amounts need to be moved back by 1 element in the path and the last element must be filled with the correct amount_msat
  • the delays are wrong and lead to error

@daywalker90 daywalker90 changed the title getroutes: amounts with wrong fee getroutes: amounts and delays are wrong Aug 12, 2024
@rustyrussell
Copy link
Contributor

OK, so getroutes() is different than getroute(). I should document this properly.

It's optimized towards onion creation, i.e. these are what you would put in the intermediary onions. So, it's the path to the destination, not including the destination. This will work better with injectpayonion (which I have yet to write(. But to be fair, it should also include the final_ctlv value, too.

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

No branches or pull requests

2 participants