Skip to content

Commit eb3e9ee

Browse files
committed
f - handle closing signed while waiting on signer
1 parent 8f31bf5 commit eb3e9ee

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lightning/src/ln/channel.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6066,6 +6066,14 @@ impl<SP: Deref> Channel<SP> where
60666066
-> Result<(Option<msgs::ClosingSigned>, Option<Transaction>, Option<ShutdownResult>), ChannelError>
60676067
where F::Target: FeeEstimator, L::Target: Logger
60686068
{
6069+
if matches!(self.context.channel_state, ChannelState::ShutdownComplete) {
6070+
// During async signing, we may need to keep the channel around
6071+
// even after it's been fully closed, so that we can construct
6072+
// and sign the final transaction to send back to the peer.
6073+
// If they send us another closing_signed, we should act as
6074+
// if the channel has already been fully closed.
6075+
return Err(ChannelError::Warn(String::from("Remote end sent us a closing_signed after shutdown complete")));
6076+
}
60696077
if !self.context.channel_state.is_both_sides_shutdown() {
60706078
return Err(ChannelError::close("Remote end sent us a closing_signed before both sides provided a shutdown".to_owned()));
60716079
}

lightning/src/ln/channelmanager.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8544,7 +8544,9 @@ where
85448544
node_id: chan.context.get_counterparty_node_id(), msg,
85458545
});
85468546
}
8547-
debug_assert_eq!(shutdown_result_opt.is_some(), chan.is_shutdown());
8547+
if shutdown_result_opt.is_some() {
8548+
debug_assert!(chan.is_shutdown());
8549+
}
85488550
if let Some(shutdown_result) = shutdown_result_opt {
85498551
shutdown_results.push(shutdown_result);
85508552
}

0 commit comments

Comments
 (0)