@@ -1601,6 +1601,8 @@ where
16011601 /// the highest `update_id` of all the pending in-flight updates (note that any pending updates
16021602 /// not yet applied sitting in [`ChannelManager::pending_background_events`] will also be
16031603 /// considered as they are also in [`Self::in_flight_monitor_updates`]).
1604+ ///
1605+ /// Note that channels which were closed prior to LDK 0.1 may have a value here of `u64::MAX`.
16041606 closed_channel_monitor_update_ids: BTreeMap<ChannelId, u64>,
16051607 /// The peer is currently connected (i.e. we've seen a
16061608 /// [`BaseMessageHandler::peer_connected`] and no corresponding
@@ -13262,7 +13264,8 @@ where
1326213264 .closed_channel_monitor_update_ids
1326313265 .get_mut(&channel_id)
1326413266 .expect("Channels originating a payment resolution must have a monitor");
13265- *update_id += 1;
13267+ // Note that for channels closed pre-0.1, the latest update_id is `u64::MAX`.
13268+ *update_id = update_id.saturating_add(1);
1326613269
1326713270 let update = ChannelMonitorUpdate {
1326813271 update_id: *update_id,
@@ -16523,7 +16526,9 @@ where
1652316526 should_queue_fc_update = !monitor.no_further_updates_allowed();
1652416527 let mut latest_update_id = monitor.get_latest_update_id();
1652516528 if should_queue_fc_update {
16526- latest_update_id += 1;
16529+ // Note that for channels closed pre-0.1, the latest update_id is
16530+ // `u64::MAX`.
16531+ latest_update_id = latest_update_id.saturating_add(1);
1652716532 }
1652816533 per_peer_state
1652916534 .entry(counterparty_node_id)
@@ -17170,7 +17175,9 @@ where
1717017175 .closed_channel_monitor_update_ids
1717117176 .get_mut(channel_id)
1717217177 .expect("Channels originating a preimage must have a monitor");
17173- *update_id += 1;
17178+ // Note that for channels closed pre-0.1, the latest
17179+ // update_id is `u64::MAX`.
17180+ *update_id = update_id.saturating_add(1);
1717417181
1717517182 pending_background_events.push(BackgroundEvent::MonitorUpdateRegeneratedOnStartup {
1717617183 counterparty_node_id: monitor.get_counterparty_node_id(),
0 commit comments