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

Prevent pay from accepting a zero-length route (self-payments) #4379

Merged
merged 3 commits into from
Feb 10, 2021

Conversation

cdecker
Copy link
Member

@cdecker cdecker commented Feb 8, 2021

As pointed out by #4345 we lost the check for zero-length routes in the pay plugin somewhere along the lines: gossipd.getroute refused to generate them, gossmap is happy to return an empty result, which is more correct, but also causes this regression, since we implicitly assumed that the route would never be empty and just access p->route[0] without checking.

While I'd like to make self-payments supported, there is currently no way of mapping a payment that doesn't result in HTLCs to a successful attempt, thus disabling self-payments and being verbose about it is the next best thing.

Note: the original issue arose during an attempt to rebalance using the pay plugin, which cannot possibly work, and the rebalance plugin should be used instead.

Fixes #4345

Copy link
Contributor

@rustyrussell rustyrussell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack d474fb6

Changelog-Fixed: pay: Payments with an empty route (self-payment) are now aborted.
This duplicates the check in libplugin-pay.c, with a more concise
error message. Both are needed since pay may not be the only
entrypoint.
@PatrickGeyer
Copy link

How about self-payments that aren't zero-length route, but still come back to same node? Is that possible?

@cdecker
Copy link
Member Author

cdecker commented Jul 1, 2022

That is totally possible, and is used in some plugins (rebalance) 👍

@PatrickGeyer
Copy link

How come it can't find a path internally that isn't zero length? Currently my wallet application code checks if node ID is the same as my apps, and then finds a circular route itself, but cumbersome and prone to errors.. But a fine workaround if nothing else works out the box.

@cdecker
Copy link
Member Author

cdecker commented Jul 4, 2022

Hm? I don't quite follow what you're trying to achieve. Zero-length routes by definition are no-ops, hence they'll not affect any channels balances. Going for a circular route however is an operation that'll cost fees, hence we shouldn't replace a zero-length route with a circular route.

@cdecker cdecker deleted the issue-4345 branch July 4, 2022 13:06
@PatrickGeyer
Copy link

The solution I'm going with to settle payments from my wallet to my wallet (same c-lightning node), is going via a circular route that I set up with my own nodes (zero fees). Ideally the node would fulfill invoices issued by itself with a zero length route (no extra nodes, no fees), but since this is not possible, what's the next best solution?

@PatrickGeyer
Copy link

@cdecker I'm assuming this is a pretty common thing people deal with with core-ln. Am I doing it the wrong way?

@cdecker
Copy link
Member Author

cdecker commented Jul 17, 2022

Why would that be a common occurence? If you are the recipient why even create the invoice at all, and then pay it via a circular route? The funds are already at the destination and any actual routing will incur in fees.

@PatrickGeyer
Copy link

Because custodial app users will often be paying each other and it adds complexity to handle some transactions locally and send outward transactions via the lightning network. I'm pretty sure CoinCorner uses circular routes as well for self payments.

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.

rebalancing (circular payment), crash c-lightning
3 participants