-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Allow user specify routing hints in private invoice. #3672
Conversation
287d440
to
20c7950
Compare
Can be consolidated with #3022? Or is it different? |
Yes, needs to. I didn't see the other PR when opened this. I Actually think the approach there is better (user needs to only pass channel ids as hops). |
Yes that's the case. |
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.
Catching up on the overlap between this and #3022:
3022: User provides a list of channels which restricts which channels we use to create hop hints, with the intention of limiting which channels are used for hop hints for balancing reasons
3672: User specifically provides the hop hints they need, to cover the case where the current logic does not allow creating a hint for the desired channel yet
@roeierez what are your thoughts on limiting the hints used for invoices to the route hints provided by the user? This would cover the use case of #3022 because the user can just provide hints for the channels they want to include.
There is a UX consideration of having to construct hints yourself wrt work for the user + potential for error. Generally, it would be nice to be able to check that the user provided hints are ok, but not in the case of #3660. We could potentially address this with a getHopHint
endpoint which will produce a hop hint for a given channel and perform validation on the channel? Most users can query this endpoint to get hints for the channels which they want to use, and in special use cases you can just roll your own?
Tagging @Crypt-iQ, author of #3022, to loop him into this discussion.
I am fine with this approach.
I actually like the approach of #3022 where the user is only pass channel ids as input instead of RouteHint structures and your arguments explains that well. I can think of two approaches for such adaptation:
Since this is a bit "advanced" use case I tend to go with #1. |
I think either method (3022 or 3672) would work. My motivation for opening 3022 was for privacy reasons since creating an invoice populates all private channels by default with no option for specificity. As long as that is addressed (which both methods would), I'm fine :) |
@roeierez Do you want to pick this up again? I think we can get this merged addressing the following:
This should also let the user specify public channels as route hints, which can be useful in certain cases. We should also update the RPC documentation to reflect the behaviour. |
Sounds good. I'll address the feedback. |
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.
A few nits otherwise LGTM 👍
lnrpc/invoicesrpc/addinvoice.go
Outdated
usedChannels := make(map[uint64]struct{}) | ||
for i, h := range invoice.RouteHints { | ||
if i >= 20 { | ||
break |
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.
return error instead?
Also needs rebase as pointed out by @hsjoberg |
Closed the other one in favor of this one @roeierez |
Note that this one currently does not support providing route hints via the CLI, only RPC |
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.
I think we'll want lncli
to be updated with the same capabilities.
lnrpc/rpc.proto
Outdated
@@ -2659,7 +2659,8 @@ message Invoice { | |||
|
|||
/* | |||
Route hints that can each be individually used to assist in reaching the | |||
invoice's destination. | |||
invoice's destination. The specified routing hints will be included in | |||
the invoice. |
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.
Comment changes need to re-generate protos as the comments are replicated in other lnrpc
files
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.
Removed the comment change, not needed after all.
lnrpc/invoicesrpc/addinvoice.go
Outdated
break | ||
} | ||
options = append(options, zpay32.RouteHint(h)) | ||
usedChannels[h[0].ChannelID] = struct{}{} |
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.
I don't think we should index like this - what if h
is empty? Why is only the first channel added to usedChannels
?
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.
@Crypt-iQ
Added validation for h is empty, missed that so thanks for catching it.
Regarding indexing, I am thinking only the first hop is our direct channel, am I missing something?
Is this PR still active? The 0.12 window is closing in a week or so. |
ping @roeierez |
Yes, I am here :). Going to pick this up again. |
036ccb5
to
a022990
Compare
@halseth rebased and adapted to the code changes that have been introduced since the start of this PR. |
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.
Apart from a few nits this LGTM 👯♂️
a022990
to
16f207b
Compare
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.
Great to get this in!
|
||
// Optional route hints that can each be individually used to assist in | ||
// reaching the invoice's destination. | ||
RouteHints [][]zpay32.HopHint |
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.
nittynit: godocs shoudl start with the var name RouteHints...
16f207b
to
4463a4c
Compare
utACK @ 4463a4c, although I've tested previous iterations. |
This PR changes the
AddInvoice/AddHoldInvoice
RPC endpoints to be able to get routing hints and populate them in the resulted invoice.In fact the
RoutingHints
already existed in bothlnrpc.Invoice
andlnrpc.AddHoldInvoiceRequest
but were ignored and this change only adds them to the invoice.This is useful in the following cases: