@@ -3616,6 +3616,13 @@ where
36163616 self.latest_monitor_update_id
36173617 }
36183618
3619+ pub fn get_latest_unblocked_monitor_update_id(&self) -> u64 {
3620+ if self.blocked_monitor_updates.is_empty() {
3621+ return self.get_latest_monitor_update_id();
3622+ }
3623+ self.blocked_monitor_updates[0].update.update_id - 1
3624+ }
3625+
36193626 pub fn should_announce(&self) -> bool {
36203627 self.config.announce_for_forwarding
36213628 }
@@ -5379,7 +5386,7 @@ where
53795386 // monitor update to the user, even if we return one).
53805387 // See test_duplicate_chan_id and test_pre_lockin_no_chan_closed_update for more.
53815388 if !self.channel_state.is_pre_funded_state() {
5382- self.latest_monitor_update_id += 1;
5389+ self.latest_monitor_update_id = self.get_latest_unblocked_monitor_update_id() + 1;
53835390 let update = ChannelMonitorUpdate {
53845391 update_id: self.latest_monitor_update_id,
53855392 updates: vec![ChannelMonitorUpdateStep::ChannelForceClosed {
@@ -9301,10 +9308,7 @@ where
93019308
93029309 /// Gets the latest [`ChannelMonitorUpdate`] ID which has been released and is in-flight.
93039310 pub fn get_latest_unblocked_monitor_update_id(&self) -> u64 {
9304- if self.context.blocked_monitor_updates.is_empty() {
9305- return self.context.get_latest_monitor_update_id();
9306- }
9307- self.context.blocked_monitor_updates[0].update.update_id - 1
9311+ self.context.get_latest_unblocked_monitor_update_id()
93089312 }
93099313
93109314 /// Returns the next blocked monitor update, if one exists, and a bool which indicates a
0 commit comments