Skip to content

Commit d007d1b

Browse files
authored
Merge pull request #2628 from wvanlint/fix_multiple_shutdown_results
Fix handling multiple ShutdownResults
2 parents b58f057 + db79ed0 commit d007d1b

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
@@ -6984,8 +6984,7 @@ where
69846984
fn maybe_generate_initial_closing_signed(&self) -> bool {
69856985
let mut handle_errors: Vec<(PublicKey, Result<(), _>)> = Vec::new();
69866986
let mut has_update = false;
6987-
let mut shutdown_result = None;
6988-
let mut unbroadcasted_batch_funding_txid = None;
6987+
let mut shutdown_results = Vec::new();
69896988
{
69906989
let per_peer_state = self.per_peer_state.read().unwrap();
69916990

@@ -6996,7 +6995,7 @@ where
69966995
peer_state.channel_by_id.retain(|channel_id, phase| {
69976996
match phase {
69986997
ChannelPhase::Funded(chan) => {
6999-
unbroadcasted_batch_funding_txid = chan.context.unbroadcasted_batch_funding_txid();
6998+
let unbroadcasted_batch_funding_txid = chan.context.unbroadcasted_batch_funding_txid();
70006999
match chan.maybe_propose_closing_signed(&self.fee_estimator, &self.logger) {
70017000
Ok((msg_opt, tx_opt)) => {
70027001
if let Some(msg) = msg_opt {
@@ -7019,7 +7018,7 @@ where
70197018
log_info!(self.logger, "Broadcasting {}", log_tx!(tx));
70207019
self.tx_broadcaster.broadcast_transactions(&[&tx]);
70217020
update_maps_on_chan_removal!(self, &chan.context);
7022-
shutdown_result = Some((None, Vec::new(), unbroadcasted_batch_funding_txid));
7021+
shutdown_results.push((None, Vec::new(), unbroadcasted_batch_funding_txid));
70237022
false
70247023
} else { true }
70257024
},
@@ -7041,7 +7040,7 @@ where
70417040
let _ = handle_error!(self, err, counterparty_node_id);
70427041
}
70437042

7044-
if let Some(shutdown_result) = shutdown_result {
7043+
for shutdown_result in shutdown_results.drain(..) {
70457044
self.finish_close_channel(shutdown_result);
70467045
}
70477046

0 commit comments

Comments
 (0)