@@ -2497,6 +2497,7 @@ where
2497
2497
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
2498
2498
2499
2499
let mut failed_htlcs: Vec<(HTLCSource, PaymentHash)>;
2500
+ let mut shutdown_result = None;
2500
2501
loop {
2501
2502
let per_peer_state = self.per_peer_state.read().unwrap();
2502
2503
@@ -2541,6 +2542,7 @@ where
2541
2542
});
2542
2543
}
2543
2544
self.issue_channel_close_events(&chan.context, ClosureReason::HolderForceClosed);
2545
+ shutdown_result = Some((None, Vec::new()));
2544
2546
}
2545
2547
}
2546
2548
break;
@@ -2562,6 +2564,10 @@ where
2562
2564
self.fail_htlc_backwards_internal(&htlc_source.0, &htlc_source.1, &reason, receiver);
2563
2565
}
2564
2566
2567
+ if let Some(shutdown_result) = shutdown_result {
2568
+ self.finish_force_close_channel(shutdown_result);
2569
+ }
2570
+
2565
2571
Ok(())
2566
2572
}
2567
2573
@@ -3537,7 +3543,7 @@ where
3537
3543
///
3538
3544
/// See [`ChannelManager::send_preflight_probes`] for more information.
3539
3545
pub fn send_spontaneous_preflight_probes(
3540
- &self, node_id: PublicKey, amount_msat: u64, final_cltv_expiry_delta: u32,
3546
+ &self, node_id: PublicKey, amount_msat: u64, final_cltv_expiry_delta: u32,
3541
3547
liquidity_limit_multiplier: Option<u64>,
3542
3548
) -> Result<Vec<(PaymentHash, PaymentId)>, ProbeSendFailure> {
3543
3549
let payment_params =
@@ -6082,6 +6088,7 @@ where
6082
6088
}
6083
6089
6084
6090
fn internal_closing_signed(&self, counterparty_node_id: &PublicKey, msg: &msgs::ClosingSigned) -> Result<(), MsgHandleErrInternal> {
6091
+ let mut shutdown_result = None;
6085
6092
let per_peer_state = self.per_peer_state.read().unwrap();
6086
6093
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
6087
6094
.ok_or_else(|| {
@@ -6130,6 +6137,12 @@ where
6130
6137
});
6131
6138
}
6132
6139
self.issue_channel_close_events(&chan.context, ClosureReason::CooperativeClosure);
6140
+ shutdown_result = Some((None, Vec::new()));
6141
+ }
6142
+ mem::drop(peer_state_mutex);
6143
+ mem::drop(per_peer_state);
6144
+ if let Some(shutdown_result) = shutdown_result {
6145
+ self.finish_force_close_channel(shutdown_result);
6133
6146
}
6134
6147
Ok(())
6135
6148
}
@@ -6804,6 +6817,7 @@ where
6804
6817
fn maybe_generate_initial_closing_signed(&self) -> bool {
6805
6818
let mut handle_errors: Vec<(PublicKey, Result<(), _>)> = Vec::new();
6806
6819
let mut has_update = false;
6820
+ let mut shutdown_result = None;
6807
6821
{
6808
6822
let per_peer_state = self.per_peer_state.read().unwrap();
6809
6823
@@ -6836,6 +6850,7 @@ where
6836
6850
log_info!(self.logger, "Broadcasting {}", log_tx!(tx));
6837
6851
self.tx_broadcaster.broadcast_transactions(&[&tx]);
6838
6852
update_maps_on_chan_removal!(self, &chan.context);
6853
+ shutdown_result = Some((None, Vec::new()));
6839
6854
false
6840
6855
} else { true }
6841
6856
},
@@ -6857,6 +6872,10 @@ where
6857
6872
let _ = handle_error!(self, err, counterparty_node_id);
6858
6873
}
6859
6874
6875
+ if let Some(shutdown_result) = shutdown_result {
6876
+ self.finish_force_close_channel(shutdown_result);
6877
+ }
6878
+
6860
6879
has_update
6861
6880
}
6862
6881
@@ -7853,6 +7872,7 @@ where
7853
7872
// Clean up for removal.
7854
7873
update_maps_on_chan_removal!(self, &context);
7855
7874
self.issue_channel_close_events(&context, ClosureReason::DisconnectedPeer);
7875
+ failed_channels.push((None, Vec::new()));
7856
7876
false
7857
7877
});
7858
7878
// Note that we don't bother generating any events for pre-accept channels -
0 commit comments