Skip to content

Commit 2d6c763

Browse files
committed
f - handle closing signed while waiting on signer
1 parent 5c30ef9 commit 2d6c763

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
@@ -6168,6 +6168,14 @@ impl<SP: Deref> Channel<SP> where
61686168
-> Result<(Option<msgs::ClosingSigned>, Option<Transaction>, Option<ShutdownResult>), ChannelError>
61696169
where F::Target: FeeEstimator, L::Target: Logger
61706170
{
6171+
if matches!(self.context.channel_state, ChannelState::ShutdownComplete) {
6172+
// During async signing, we may need to keep the channel around
6173+
// even after it's been fully closed, so that we can construct
6174+
// and sign the final transaction to send back to the peer.
6175+
// If they send us another closing_signed, we should act as
6176+
// if the channel has already been fully closed.
6177+
return Err(ChannelError::Warn(String::from("Remote end sent us a closing_signed after shutdown complete")));
6178+
}
61716179
if !self.context.channel_state.is_both_sides_shutdown() {
61726180
return Err(ChannelError::close("Remote end sent us a closing_signed before both sides provided a shutdown".to_owned()));
61736181
}

lightning/src/ln/channelmanager.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8738,7 +8738,9 @@ where
87388738
node_id: chan.context.get_counterparty_node_id(), msg,
87398739
});
87408740
}
8741-
debug_assert_eq!(shutdown_result_opt.is_some(), chan.is_shutdown());
8741+
if shutdown_result_opt.is_some() {
8742+
debug_assert!(chan.is_shutdown());
8743+
}
87428744
if let Some(shutdown_result) = shutdown_result_opt {
87438745
shutdown_results.push(shutdown_result);
87448746
}

0 commit comments

Comments
 (0)