Avoid refusing ChannelMonitorUpdates we expect to receive after closing
authorWilmer Paulino <wilmer@wilmerpaulino.com>
Tue, 28 Feb 2023 18:45:48 +0000 (10:45 -0800)
committerWilmer Paulino <wilmer@wilmerpaulino.com>
Tue, 21 Mar 2023 23:25:47 +0000 (16:25 -0700)
There is no need to fill the user's logs with errors that are expected
to be hit based on specific edge cases, like providing preimages after
a monitor has seen a confirmed commitment on-chain.

This doesn't really change our behavior – we still apply and persist the
state changes resulting from processing these updates regardless of
whether they succeed or not.

lightning/src/chain/channelmonitor.rs

index df5160df015fae8550c487660d0a959c59687fe6..97e1e8ee6125e2f583cf9a1aaa155a9121a0e60d 100644 (file)
@@ -2373,6 +2373,13 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
                                },
                        }
                }
+
+               // If the updates succeeded and we were in an already closed channel state, then there's no
+               // need to refuse any updates we expect to receive afer seeing a confirmed commitment.
+               if ret.is_ok() && updates.update_id == CLOSED_CHANNEL_UPDATE_ID && self.latest_update_id == updates.update_id {
+                       return Ok(());
+               }
+
                self.latest_update_id = updates.update_id;
 
                if ret.is_ok() && self.funding_spend_seen {