File tree 1 file changed +14
-6
lines changed
1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -12576,12 +12576,20 @@ where
12576
12576
for (funding_txo, monitor) in args.channel_monitors.iter() {
12577
12577
if !funding_txo_set.contains(funding_txo) {
12578
12578
if let Some(counterparty_node_id) = monitor.get_counterparty_node_id() {
12579
- per_peer_state.entry(counterparty_node_id)
12580
- .or_insert_with(|| Mutex::new(empty_peer_state()))
12581
- .lock().unwrap()
12582
- .closed_channel_monitor_update_ids.entry(monitor.channel_id())
12583
- .and_modify(|v| *v = cmp::max(monitor.get_latest_update_id(), *v))
12584
- .or_insert(monitor.get_latest_update_id());
12579
+ // If the ChannelMonitor had any updates, we may need to update it further and
12580
+ // thus track it in `closed_channel_monitor_update_ids`. If the channel never
12581
+ // had any updates at all, there can't be any HTLCs pending which we need to
12582
+ // claim.
12583
+ // Note that a `ChannelMonitor` is created with `update_id` 0 and after we
12584
+ // provide it with a closure update its `update_id` will be at 1.
12585
+ if !monitor.offchain_closed() || monitor.get_latest_update_id() > 1 {
12586
+ per_peer_state.entry(counterparty_node_id)
12587
+ .or_insert_with(|| Mutex::new(empty_peer_state()))
12588
+ .lock().unwrap()
12589
+ .closed_channel_monitor_update_ids.entry(monitor.channel_id())
12590
+ .and_modify(|v| *v = cmp::max(monitor.get_latest_update_id(), *v))
12591
+ .or_insert(monitor.get_latest_update_id());
12592
+ }
12585
12593
}
12586
12594
12587
12595
if monitor.offchain_closed() {
You can’t perform that action at this time.
0 commit comments