Skip to content

Commit 2c2d6bf

Browse files
committed
f allow assert_no_commitment_advancement to take a message
1 parent 4514e42 commit 2c2d6bf

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

lightning/src/ln/channel.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3954,11 +3954,12 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
39543954
}
39553955

39563956
/// Asserts that the commitment tx numbers have not advanced from their initial number.
3957-
fn assert_no_commitment_advancement(&self) {
3957+
fn assert_no_commitment_advancement(&self, msg_name: &str) {
39583958
if self.commitment_secrets.get_min_seen_secret() != (1 << 48) ||
39593959
self.cur_counterparty_commitment_transaction_number != INITIAL_COMMITMENT_NUMBER ||
39603960
self.holder_commitment_point.transaction_number() != INITIAL_COMMITMENT_NUMBER {
3961-
debug_assert!(false, "Should not have advanced channel commitment tx numbers prior to funding_created");
3961+
debug_assert!(false, "Should not have advanced channel commitment tx numbers prior to {}",
3962+
msg_name);
39623963
}
39633964
}
39643965

@@ -4001,11 +4002,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
40014002
if flags == (NegotiatingFundingFlags::OUR_INIT_SENT | NegotiatingFundingFlags::THEIR_INIT_SENT)) {
40024003
panic!("Tried to get a funding_created messsage at a time other than immediately after initial handshake completion (or tried to get funding_created twice)");
40034004
}
4004-
if self.commitment_secrets.get_min_seen_secret() != (1 << 48) ||
4005-
self.cur_counterparty_commitment_transaction_number != INITIAL_COMMITMENT_NUMBER ||
4006-
self.holder_commitment_point.transaction_number() != INITIAL_COMMITMENT_NUMBER {
4007-
panic!("Should not have advanced channel commitment tx numbers prior to initial commitment_signed");
4008-
}
4005+
self.assert_no_commitment_advancement("initial commitment_signed");
40094006

40104007
let signature = match self.get_initial_counterparty_commitment_signature(logger) {
40114008
Ok(res) => res,
@@ -4938,7 +4935,7 @@ impl<SP: Deref> Channel<SP> where
49384935
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) },
49394936
)));
49404937
}
4941-
self.context.assert_no_commitment_advancement();
4938+
self.context.assert_no_commitment_advancement("initial commitment_signed");
49424939

49434940
let (channel_monitor, _) = self.initial_commitment_signed(
49444941
self.context.channel_id(), msg.signature,
@@ -8262,7 +8259,7 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
82628259
) {
82638260
panic!("Tried to get a funding_created messsage at a time other than immediately after initial handshake completion (or tried to get funding_created twice)");
82648261
}
8265-
self.context.assert_no_commitment_advancement();
8262+
self.context.assert_no_commitment_advancement("funding_created");
82668263

82678264
self.context.channel_transaction_parameters.funding_outpoint = Some(funding_txo);
82688265
self.context.holder_signer.as_mut().provide_channel_parameters(&self.context.channel_transaction_parameters);
@@ -8387,7 +8384,7 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
83878384
if !matches!(self.context.channel_state, ChannelState::FundingNegotiated) {
83888385
return Err((self, ChannelError::close("Received funding_signed in strange state!".to_owned())));
83898386
}
8390-
self.context.assert_no_commitment_advancement();
8387+
self.context.assert_no_commitment_advancement("funding_created");
83918388

83928389
let (channel_monitor, _) = match self.initial_commitment_signed(
83938390
self.context.channel_id(),
@@ -8601,7 +8598,7 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
86018598
// channel.
86028599
return Err((self, ChannelError::close("Received funding_created after we got the channel!".to_owned())));
86038600
}
8604-
self.context.assert_no_commitment_advancement();
8601+
self.context.assert_no_commitment_advancement("funding_created");
86058602

86068603
let funding_txo = OutPoint { txid: msg.funding_txid, index: msg.funding_output_index };
86078604
self.context.channel_transaction_parameters.funding_outpoint = Some(funding_txo);

0 commit comments

Comments
 (0)