Skip to content

Commit 0681b00

Browse files
committed
f handle shutdown
1 parent f835d87 commit 0681b00

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6016,7 +6016,8 @@ where
60166016
}
60176017

60186018
fn internal_shutdown(&self, counterparty_node_id: &PublicKey, msg: &msgs::Shutdown) -> Result<(), MsgHandleErrInternal> {
6019-
let mut dropped_htlcs: Vec<(HTLCSource, PaymentHash)>;
6019+
let mut dropped_htlcs: Vec<(HTLCSource, PaymentHash)> = Vec::new();
6020+
let mut finish_shutdown = None;
60206021
{
60216022
let per_peer_state = self.per_peer_state.read().unwrap();
60226023
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
@@ -6061,8 +6062,7 @@ where
60616062
log_error!(self.logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
60626063
self.issue_channel_close_events(&context, ClosureReason::CounterpartyCoopClosedUnfundedChannel);
60636064
let mut chan = remove_channel_phase!(self, chan_phase_entry);
6064-
self.finish_force_close_channel(chan.context_mut().force_shutdown(false));
6065-
return Ok(());
6065+
finish_shutdown = Some(chan.context_mut().force_shutdown(false));
60666066
},
60676067
}
60686068
} else {
@@ -6074,6 +6074,9 @@ where
60746074
let reason = HTLCFailReason::from_failure_code(0x4000 | 8);
60756075
self.fail_htlc_backwards_internal(&htlc_source.0, &htlc_source.1, &reason, receiver);
60766076
}
6077+
if let Some(shutdown_res) = finish_shutdown {
6078+
self.finish_force_close_channel(shutdown_res);
6079+
}
60776080

60786081
Ok(())
60796082
}

0 commit comments

Comments
 (0)