Skip to content

Commit 4061675

Browse files
committed
Use debug_assert & error on unexpected initial commitment_signed
This replaces the hard panic from this case.
1 parent fe1cf69 commit 4061675

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
@@ -4055,8 +4055,13 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
40554055
{
40564056
if !matches!(
40574057
self.channel_state, ChannelState::NegotiatingFunding(flags)
4058-
if flags == (NegotiatingFundingFlags::OUR_INIT_SENT | NegotiatingFundingFlags::THEIR_INIT_SENT)) {
4059-
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)");
4058+
if flags == (NegotiatingFundingFlags::OUR_INIT_SENT | NegotiatingFundingFlags::THEIR_INIT_SENT)
4059+
) {
4060+
debug_assert!(false);
4061+
return Err(ChannelError::Close(("Tried to get an initial commitment_signed messsage at a time other than \
4062+
immediately after initial handshake completion (or tried to get funding_created twice)".to_string(),
4063+
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) }
4064+
)));
40604065
}
40614066
self.assert_no_commitment_advancement("initial commitment_signed");
40624067

0 commit comments

Comments
 (0)