-
Notifications
You must be signed in to change notification settings - Fork 952
payalgo: Support bolt11 'r' fields. #1330
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, first this is screaming for a new source file, as your comment points out.
Secondly, you really need to implement 'r' for unannounced routes, at least for ones less than 6 confirms. That's completely independent of this, but does allow you to test this code nicely, too.
lightningd/payalgo.c
Outdated
else | ||
(*route)[route_end + i].nodeid = *receiver_id; | ||
(*route)[route_end + i].amount = amount; | ||
(*route)[route_end + i].delay = (*route)[route_end + i - 1].delay - cp->subroute[i].cltv_expiry_delta; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is wrong. It assumes the previous delay is loaded. But it is not loaded because we are loading route hops backward. Instead, we should load the delay as + from next delay (or final target delay if this is the last hop).
Unfortunately it seems unannounced channels cannot be used for The BOLT spec mentions My understanding of the invoice route is that for example if it indicates a route peer A going through channel C to us, then the fees should be the fees that A will charge for use of channel C. How do we learn that? Nothing in the spec suggests that we can learn that from a peer except for We could try to use our own fee settings, in the hope that nobody will change the defaults and everyone uses the same fee rate, but what if the peer is an lnd node? |
You're right. @cdecker may have thoughts on this... The alternative then is to implement non-public channels, which is what this was designed for. |
Even with non-public channels, how does the other side know how much we want to charge for use of our channel? Seems, limitation of BOLT spec? |
We had an alternative code path that'd allow |
Just to add some more color to this: we might eventually want to introduce a |
I would argue the opposite; we should retain even non-published channels in our routing map permanently once we learn of them via invoice, and remove it only on permanent channel failure. This makes it harder for route analyzers if we sometimes use non-published channels to pay unrelated nodes; the route analyzer might assume we terminate to the node after the non-published channel, when in fact we are using that node as a hop node, going into one non-published channel and out another non-published channel, and probably helps the privacy of that node too, since this is activity that naive route analysis might assume terminates at them but is actually hopped. |
c3e687f
to
c42364d
Compare
Yet another wrinkle: it seems c-lightning will return It seems to test this at integration test, we need to actually support non-published channels too, sigh. In any case my attempts to make this work also revealed a new bug in my bolt11-private-route handling:
|
7a41c4e
to
fcd49cf
Compare
@cdecker has there been some resolution regarding |
@ZmnSCPxj not really, they only make sense for published nodes since otherwise we are one of the peers (and know what we'd charge) or the other end, in which case we most likely don't want to route in that direction (because we're the receiving endpoint). We should probably just send a |
Yes, that is indeed what I was referring to when I asked about " This is approximately OK for interoperability, I think: strict followers of the spec will ignore incoming But if it is useful for us, we should probably think that other implementations may also find it useful, so we should consider to propose it for standardization. |
The contactpoint system does what you describe already. We generate a contactpoint for each The contactpoint list is then iterated over. We compute the target payment and compute how much has to reach the contact point node. If we fail to find a route to the contactpoint, or we get a failure onion past the contactpoint node, we drop the current contactpoint and move on to the next. I think the current PR is minimal enough as is. |
Just want to make sure, the first |
Yes. The contactpoint created at the destination is added using Contactpoints created for each |
Great, I'd say this is good to go, and let's revisit the ACK 34f73c2 |
Currently needs a rebase, and @rustyrussell's approval :-) |
Unifies some common computation code between gossipd and the 'r' handling in payalgo.
Rebased, |
Seems we now have a case clash:
|
Also add ability to use unconfirmed channel as route.
…a new common module.
Ready for review. Sadly my hacking node will be offline for some time, so I will have some difficulty updating this pull request in the close future, but I will try to respond to reviews anyway. |
ACK 2ad7867 Code is ok, but I'll let @rustyrussell get the final say. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^^
@ZmnSCPxj I'm sorry I botched the merge edit, and seem to be unable to push to your branch to to a real rebase. Could you rebase and I'll merge it :-) |
Sorry for the ridiculously long hiatus, I shall see what I can do (hacking computer is currently unstable due to lower-level issues, am currently stabilizing it). |
This PR has been inactive for a long time (partly my fault), and is probably more work to rebase than it is to rewrite from scratch. Would anybody object if I close this? @ZmnSCPxj @rustyrussell |
Part of spec.
Not sure how to test, though.We need some way to generate
r
fields in bolt11 invoices.