-
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
routing: allow route to self #3736
Conversation
f128194
to
bfc27d6
Compare
e651429
to
86027ba
Compare
86027ba
to
0542f81
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.
Clean and well crafted PR!
It's very nice to see that we can now rebalance easily, even through the command line.
Only found a few nits, nothing critical.
0542f81
to
ad7d590
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.
Note that if you pay to yourself without any of these restrictions, it may happen that the payment comes back in through the same channel that was used to send it out. In that case balances don't change. They may only go down because of the routing fees paid.
Given that this doesn't really have a use case, perhaps we could detect this and return an error?
ad7d590
to
3406c11
Compare
I wouldn't really want to hard block this. I think we can assume that people using send to self know what they are doing. I also think we cannot really rule out that such use case would emerge at some point. There is for example the trick where you drop off more routing fees than required as a way to do spontaneous payment. |
3406c11
to
336e71f
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.
The exact incoming channel cannot be specified because routing nodes forward non-strict.
We may not be able to choose which channel the HTLC is forwarded over, but we can reject the payment if it doesn't come over the intended channel and retry. Now that we index the invoice htlcs by circuit key, it should be straight forward (apart from needing to add this restriction on the invoice).
Note that if you pay to yourself without any of these restrictions, it may happen that the payment comes back in through the same channel that was used to send it out. In that case balances don't change. They may only go down because of the routing fees paid.
I don't think this would be the expected behavior for simply calling payinvoice <payreq>
, and seems pretty easy to mess up. IMO this should produce a warning when source==destination, especially considering it changes the existing behavior which would normally fail. Perhaps adding an --allow-cycle
flag would suffice?
f91c130
to
637fcc3
Compare
I consider this out of scope for this PR? It is definitely useful functionality, also to prevent tying up capital on expensive peers.
Flag added |
This prepares for routing to self. When checking the condition at the start, the loop would terminate immediately because the source is equal to the target.
This prepares for routing to self.
637fcc3
to
2d19201
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.
LGTM 🍣
Thanks. Glad to see that merged in. |
Great feature. But when I tried to test it, I get the Error "[lncli] invalid vertex string length of 18, want 66"
The
It seems LND is not happy with my |
Last hop needs to be a node public key (33 bytes) |
Yes, that worked! I missed that little detail. Thank you! |
This PR makes it possible to find routes to yourself. It is useful for rebalancing purposes if combined with #3739 and an outgoing channel restriction.
Usage from the command line:
lncli addinvoice <amt>
lncli payinvoice --allow_self_payment --outgoing_chan_id <outgoing_chan> --last_hop <last_hop> <payreq_from_1>
This will push out
amt
throughoutgoing_chan
back to yourself via one of your channels with your peerlast_hop
. The exact incoming channel cannot be specified because routing nodes forward non-strict.Note that if you pay to yourself without any of these restrictions, it may happen that the payment comes back in through the same channel that was used to send it out. In that case balances don't change. They may only go down because of the routing fees paid.
Fixes #1645