Skip to content

Commit 605184f

Browse files
committed
Use debug_assert & error on unexpected initial commitment_signed
This replaces the hard panic from this case.
1 parent 2d2c542 commit 605184f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lightning/src/ln/channel.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4357,8 +4357,13 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
43574357
{
43584358
if !matches!(
43594359
self.channel_state, ChannelState::NegotiatingFunding(flags)
4360-
if flags == (NegotiatingFundingFlags::OUR_INIT_SENT | NegotiatingFundingFlags::THEIR_INIT_SENT)) {
4361-
panic!("Tried to get an initial commitment_signed messsage at a time other than immediately after initial handshake completion (or tried to get funding_created twice)");
4360+
if flags == (NegotiatingFundingFlags::OUR_INIT_SENT | NegotiatingFundingFlags::THEIR_INIT_SENT)
4361+
) {
4362+
debug_assert!(false);
4363+
return Err(ChannelError::Close(("Tried to get an initial commitment_signed messsage at a time other than \
4364+
immediately after initial handshake completion (or tried to get funding_created twice)".to_string(),
4365+
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(true) }
4366+
)));
43624367
}
43634368

43644369
let signature = match self.get_initial_counterparty_commitment_signature(logger) {

0 commit comments

Comments
 (0)