]> git.bitcoin.ninja Git - rust-lightning/commit
Prefer to use `MonitorUpdateRegeneratedOnStartup` where possible
authorMatt Corallo <git@bluematt.me>
Sun, 6 Oct 2024 19:54:32 +0000 (19:54 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 13 Nov 2024 01:24:06 +0000 (01:24 +0000)
commit3f368909121897d35cfd3dc77e743531c7301ee8
tree22813f6eab5e08c3d18f917d476db65f751d55d0
parent6f023f8f0896545fdac3aa30eb9e0003a58897fe
Prefer to use `MonitorUpdateRegeneratedOnStartup` where possible

In the next commit we'll drop the magic `u64::MAX`
`ChannelMonitorUpdate::update_id` value used when we don't know the
`ChannelMonitor`'s `latest_update_id` (i.e. when the channel is
closed). In order to do so, we will store further information about
`ChannelMonitor`s in the per-peer structure, keyed by the
counterparty's node ID, which will be used when applying
`ChannelMonitorUpdate`s to closed channels.

By taking advantage of the change in the previous commit, that
information is now reliably available when we generate the
`ChannelMonitorUpdate` (when claiming HTLCs), but in order to
ensure it is available when applying the `ChannelMonitorUpdate` we
need to use `BackgroundEvent::MonitorUpdateRegeneratedOnStartup`
instead of
`BackgroundEvent::ClosedMonitorUpdateRegeneratedOnStartup` where
possible.

Here we do this, leaving `ClosedMonitorUpdateRegeneratedOnStartup`
only used to ensure very old channels (created in 0.0.118 or
earlier) which are not in the `ChannelManager` are force-closed on
startup.
lightning/src/ln/channelmanager.rs