invoices+channeldb: reject payments to expired invoices#3694
invoices+channeldb: reject payments to expired invoices#3694Roasbeef merged 5 commits intolightningnetwork:masterfrom
Conversation
Roasbeef
left a comment
There was a problem hiding this comment.
Solid fix! Nice to finally patch this behavior. No major comments on my end, just mostly relevant areas of the contribution/style guide that aren't fully adhere to.
An example of a better PR title would've been something along the lines of:
invoices+channeldb: reject payments to expired invoices
joostjager
left a comment
There was a problem hiding this comment.
Perhaps not in this PR, but eventually we also may want to actively cancel invoices when they expire. So that there state is reflectly properly even without someone paying to them first.
|
Working on a different timer in #3415 using a priority queue |
|
Can we change the default invoice time to be higher than an hour? How about 3 hours? Otherwise I anticipate this change resulting in some error rate increases. |
|
Why would error rates increase? The sender already checks the expiry now. Or are you thinking about other implementations that may not do this? Or people decoding the pay req and using |
There is decoding and sending yes, but there is also a natural race condition between acceptance and sending. It can easily take me 10 minutes to complete a payment to some destinations, but the timer would have shown "you have 10 minutes left" when I pressed the button. Clocks may not be perfectly synchronized, etc. |
|
What does changing the default fix about this? The problem remains, only with a different time. |
|
I didn't say it fixed it, it just can counterbalance it |
I would prefer this being a follow up. Can also make an issue on it for someone to pick up. |
@bhandras and I discussed this offline. Both approaches aren't compatible with each other, so doesn't work very well as a follow up. |
|
Even though the original issue is solved with the current PR, as discussed with @joostjager, it is cleaner to implement a watcher for invoice expiry and cancellation. I'll update this PR soon. |
|
Here is a data point on how many errors are due to expiry
|
This commit adds InvoiceExpryWatcher which is a separate class that receives new invoices (and existing ones upon restart) from InvoiceRegistry and actively watches their expiry. When an invoice is expired InvoiceExpiryWatcher will call into InvoiceRegistry to cancel the invoice and by that notify all subscribers about the state change.
This commit changes how FetchAllInvoicesWithPaymentHash behaves when the DB is empty and also adds a unit test to test that case as well as normal expected behavior.
This commits builds on top of PR lightningnetwork#3694 to further clarify invoice state by defining pending invoices as the ones which are not settled or canceled. Automatic cancellation of expired invoices makes this possbile. While this change only directly affects ChannelDB, users of the listinvoices RPC will receive actual pending invoices when pending_only flag is set.
This commits builds on top of PR lightningnetwork#3694 to further clarify invoice state by defining pending invoices as the ones which are not settled or canceled. Automatic cancellation of expired invoices makes this possbile. While this change only directly affects ChannelDB, users of the listinvoices RPC will receive actual pending invoices when pending_only flag is set.
invoices+channeldb: reject payments to expired invoices
This change is