Skip to content

Fix handling multiple ShutdownResults #2628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6976,8 +6976,7 @@ where
fn maybe_generate_initial_closing_signed(&self) -> bool {
let mut handle_errors: Vec<(PublicKey, Result<(), _>)> = Vec::new();
let mut has_update = false;
let mut shutdown_result = None;
let mut unbroadcasted_batch_funding_txid = None;
let mut shutdown_results = Vec::new();
{
let per_peer_state = self.per_peer_state.read().unwrap();

Expand All @@ -6988,7 +6987,7 @@ where
peer_state.channel_by_id.retain(|channel_id, phase| {
match phase {
ChannelPhase::Funded(chan) => {
unbroadcasted_batch_funding_txid = chan.context.unbroadcasted_batch_funding_txid();
let unbroadcasted_batch_funding_txid = chan.context.unbroadcasted_batch_funding_txid();
match chan.maybe_propose_closing_signed(&self.fee_estimator, &self.logger) {
Ok((msg_opt, tx_opt)) => {
if let Some(msg) = msg_opt {
Expand All @@ -7011,7 +7010,7 @@ where
log_info!(self.logger, "Broadcasting {}", log_tx!(tx));
self.tx_broadcaster.broadcast_transactions(&[&tx]);
update_maps_on_chan_removal!(self, &chan.context);
shutdown_result = Some((None, Vec::new(), unbroadcasted_batch_funding_txid));
shutdown_results.push((None, Vec::new(), unbroadcasted_batch_funding_txid));
false
} else { true }
},
Expand All @@ -7033,7 +7032,7 @@ where
let _ = handle_error!(self, err, counterparty_node_id);
}

if let Some(shutdown_result) = shutdown_result {
for shutdown_result in shutdown_results.drain(..) {
self.finish_close_channel(shutdown_result);
}

Expand Down