Skip to content

Commit db79ed0

Browse files
committed
Fix handling multiple ShutdownResults
1 parent fbc86cb commit db79ed0

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6976,8 +6976,7 @@ where
69766976
fn maybe_generate_initial_closing_signed(&self) -> bool {
69776977
let mut handle_errors: Vec<(PublicKey, Result<(), _>)> = Vec::new();
69786978
let mut has_update = false;
6979-
let mut shutdown_result = None;
6980-
let mut unbroadcasted_batch_funding_txid = None;
6979+
let mut shutdown_results = Vec::new();
69816980
{
69826981
let per_peer_state = self.per_peer_state.read().unwrap();
69836982

@@ -6988,7 +6987,7 @@ where
69886987
peer_state.channel_by_id.retain(|channel_id, phase| {
69896988
match phase {
69906989
ChannelPhase::Funded(chan) => {
6991-
unbroadcasted_batch_funding_txid = chan.context.unbroadcasted_batch_funding_txid();
6990+
let unbroadcasted_batch_funding_txid = chan.context.unbroadcasted_batch_funding_txid();
69926991
match chan.maybe_propose_closing_signed(&self.fee_estimator, &self.logger) {
69936992
Ok((msg_opt, tx_opt)) => {
69946993
if let Some(msg) = msg_opt {
@@ -7011,7 +7010,7 @@ where
70117010
log_info!(self.logger, "Broadcasting {}", log_tx!(tx));
70127011
self.tx_broadcaster.broadcast_transactions(&[&tx]);
70137012
update_maps_on_chan_removal!(self, &chan.context);
7014-
shutdown_result = Some((None, Vec::new(), unbroadcasted_batch_funding_txid));
7013+
shutdown_results.push((None, Vec::new(), unbroadcasted_batch_funding_txid));
70157014
false
70167015
} else { true }
70177016
},
@@ -7033,7 +7032,7 @@ where
70337032
let _ = handle_error!(self, err, counterparty_node_id);
70347033
}
70357034

7036-
if let Some(shutdown_result) = shutdown_result {
7035+
for shutdown_result in shutdown_results.drain(..) {
70377036
self.finish_close_channel(shutdown_result);
70387037
}
70397038

0 commit comments

Comments
 (0)