Skip to content

Commit 7fc2cf4

Browse files
committed
Use debug_assert & error on unexpected initial commitment_signed
This replaces the hard panic from this case.
1 parent 047bd61 commit 7fc2cf4

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
@@ -4501,8 +4501,13 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
45014501
{
45024502
if !matches!(
45034503
self.channel_state, ChannelState::NegotiatingFunding(flags)
4504-
if flags == (NegotiatingFundingFlags::OUR_INIT_SENT | NegotiatingFundingFlags::THEIR_INIT_SENT)) {
4505-
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)");
4504+
if flags == (NegotiatingFundingFlags::OUR_INIT_SENT | NegotiatingFundingFlags::THEIR_INIT_SENT)
4505+
) {
4506+
debug_assert!(false);
4507+
return Err(ChannelError::Close(("Tried to get an initial commitment_signed messsage at a time other than \
4508+
immediately after initial handshake completion (or tried to get funding_created twice)".to_string(),
4509+
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(true) }
4510+
)));
45064511
}
45074512

45084513
let signature = match self.get_initial_counterparty_commitment_signature(funding, logger) {

0 commit comments

Comments
 (0)