@@ -1601,6 +1601,8 @@ where
1601
1601
/// the highest `update_id` of all the pending in-flight updates (note that any pending updates
1602
1602
/// not yet applied sitting in [`ChannelManager::pending_background_events`] will also be
1603
1603
/// 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`.
1604
1606
closed_channel_monitor_update_ids: BTreeMap<ChannelId, u64>,
1605
1607
/// The peer is currently connected (i.e. we've seen a
1606
1608
/// [`BaseMessageHandler::peer_connected`] and no corresponding
@@ -13262,7 +13264,8 @@ where
13262
13264
.closed_channel_monitor_update_ids
13263
13265
.get_mut(&channel_id)
13264
13266
.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);
13266
13269
13267
13270
let update = ChannelMonitorUpdate {
13268
13271
update_id: *update_id,
@@ -16523,7 +16526,9 @@ where
16523
16526
should_queue_fc_update = !monitor.no_further_updates_allowed();
16524
16527
let mut latest_update_id = monitor.get_latest_update_id();
16525
16528
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);
16527
16532
}
16528
16533
per_peer_state
16529
16534
.entry(counterparty_node_id)
@@ -17170,7 +17175,9 @@ where
17170
17175
.closed_channel_monitor_update_ids
17171
17176
.get_mut(channel_id)
17172
17177
.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);
17174
17181
17175
17182
pending_background_events.push(BackgroundEvent::MonitorUpdateRegeneratedOnStartup {
17176
17183
counterparty_node_id: monitor.get_counterparty_node_id(),
0 commit comments