]> git.bitcoin.ninja Git - rust-lightning/commit
Fix bug where we double-pay an offer due to stale manager
authorValentine Wallace <vwallace@protonmail.com>
Mon, 16 Sep 2024 16:26:16 +0000 (12:26 -0400)
committerValentine Wallace <vwallace@protonmail.com>
Tue, 17 Sep 2024 13:52:49 +0000 (09:52 -0400)
commitfbb3ab2704232a9aa993435b8d3e0867fa0c615b
treea68a4b7a90b7d216d1937e35891fbf533f9ab6fb
parent3c2da4147cf485a66317d455791c09d142579d31
Fix bug where we double-pay an offer due to stale manager

This fixes the following bug:
- An outbound payment is AwaitingInvoice
- We receive an invoice and lock the HTLCs into the relevant ChannelMonitors
- The monitors are successfully persisted, but the ChannelManager fails to
  persist, so the outbound payment remains AwaitingInvoice
- We restart, causing the channels to close due to a stale ChannelManager
- We receive a duplicate invoice, and attempt to pay it again due to the
  payment still being AwaitingInvoice in the stale ChannelManager

After the fix for this, we will notice that the payment is already locked into
the monitor on startup and transition the incorrectly-AwaitingInvoice payment
to Retryable, which prevents double-paying on duplicate invoice receipt.
lightning/src/ln/offers_tests.rs
lightning/src/ln/outbound_payment.rs