@@ -3659,15 +3659,21 @@ where
36593659
36603660 if let Some((_, funding_txo, _, update)) = shutdown_res.monitor_update.take() {
36613661 handle_new_monitor_update_locked_actions_handled_by_caller!(
3662- cm, funding_txo, update, in_flight_monitor_updates, chan.context
3662+ cm,
3663+ funding_txo,
3664+ update,
3665+ in_flight_monitor_updates,
3666+ chan.context
36633667 );
36643668 }
36653669 // If there's a possibility that we need to generate further monitor updates for this
36663670 // channel, we need to store the last update_id of it. However, we don't want to insert
36673671 // into the map (which prevents the `PeerState` from being cleaned up) for channels that
36683672 // never even got confirmations (which would open us up to DoS attacks).
36693673 let update_id = chan.context.get_latest_monitor_update_id();
3670- if chan.funding.get_funding_tx_confirmation_height().is_some() || chan.context.minimum_depth(&chan.funding) == Some(0) || update_id > 1 {
3674+ let funding_confirmed = chan.funding.get_funding_tx_confirmation_height().is_some();
3675+ let chan_zero_conf = chan.context.minimum_depth(&chan.funding) == Some(0);
3676+ if funding_confirmed || chan_zero_conf || update_id > 1 {
36713677 closed_channel_monitor_update_ids.insert(chan_id, update_id);
36723678 }
36733679 let mut short_to_chan_info = cm.short_to_chan_info.write().unwrap();
@@ -3680,7 +3686,8 @@ where
36803686 // also don't want a counterparty to be able to trivially cause a memory leak by simply
36813687 // opening a million channels with us which are closed before we ever reach the funding
36823688 // stage.
3683- let alias_removed = cm.outbound_scid_aliases.lock().unwrap().remove(&chan.context.outbound_scid_alias());
3689+ let outbound_alias = chan.context.outbound_scid_alias();
3690+ let alias_removed = cm.outbound_scid_aliases.lock().unwrap().remove(&outbound_alias);
36843691 debug_assert!(alias_removed);
36853692 }
36863693 short_to_chan_info.remove(&chan.context.outbound_scid_alias());
@@ -3712,7 +3719,8 @@ where
37123719 // also don't want a counterparty to be able to trivially cause a memory leak by simply
37133720 // opening a million channels with us which are closed before we ever reach the funding
37143721 // stage.
3715- let alias_removed = cm.outbound_scid_aliases.lock().unwrap().remove(&chan.context().outbound_scid_alias());
3722+ let outbound_alias = chan.context().outbound_scid_alias();
3723+ let alias_removed = cm.outbound_scid_aliases.lock().unwrap().remove(&outbound_alias);
37163724 debug_assert!(alias_removed);
37173725 (shutdown_res, None)
37183726 })
0 commit comments