]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Process updates before archiving monitors.
authorArik Sosman <git@arik.io>
Wed, 28 Aug 2024 16:33:14 +0000 (09:33 -0700)
committerArik Sosman <git@arik.io>
Wed, 28 Aug 2024 19:19:38 +0000 (12:19 -0700)
Previously, `MonitorUpdatingPersister` was disregarding any unapplied
monitor updates when archiving them. This commit ensures that upon
reading monitors, their corresponding updates are also read and
applied prior to archiving.

lightning/src/util/persist.rs

index a845cc1780020eb41bd427d66aab4f60f2749a37..64fe84a09a71ae47ebc6880d6c70981e2cb6f2bd 100644 (file)
@@ -762,7 +762,8 @@ where
 
        fn archive_persisted_channel(&self, funding_txo: OutPoint) {
                let monitor_name = MonitorName::from(funding_txo);
-               let monitor = match self.read_monitor(&monitor_name) {
+               let monitor_key = monitor_name.as_str().to_string();
+               let monitor = match self.read_channel_monitor_with_updates(monitor_key) {
                        Ok((_block_hash, monitor)) => monitor,
                        Err(_) => return
                };
@@ -770,9 +771,9 @@ where
                        ARCHIVED_CHANNEL_MONITOR_PERSISTENCE_PRIMARY_NAMESPACE,
                        ARCHIVED_CHANNEL_MONITOR_PERSISTENCE_SECONDARY_NAMESPACE,
                        monitor_name.as_str(),
-                       &monitor.encode()
+                       &monitor.encode(),
                ) {
-                       Ok(()) => {},
+                       Ok(()) => {}
                        Err(_e) => return,
                };
                let _ = self.kv_store.remove(