@@ -1653,7 +1653,7 @@ impl<SP: Deref> InteractivelyFunded<SP> for InboundV2Channel<SP> where SP::Targe
1653
1653
}
1654
1654
}
1655
1655
1656
- impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
1656
+ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
1657
1657
fn new_for_inbound_channel<'a, ES: Deref, F: Deref, L: Deref>(
1658
1658
fee_estimator: &'a LowerBoundedFeeEstimator<F>,
1659
1659
entropy_source: &'a ES,
@@ -3747,6 +3747,15 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3747
3747
self.channel_transaction_parameters.channel_type_features = self.channel_type.clone();
3748
3748
Ok(())
3749
3749
}
3750
+
3751
+ /// Panics if the commitment tx numbers have advanced from their initial number.
3752
+ fn assert_no_commitment_advancement(&self) {
3753
+ if self.commitment_secrets.get_min_seen_secret() != (1 << 48) ||
3754
+ self.cur_counterparty_commitment_transaction_number != INITIAL_COMMITMENT_NUMBER ||
3755
+ self.holder_commitment_point.transaction_number() != INITIAL_COMMITMENT_NUMBER {
3756
+ panic!("Should not have advanced channel commitment tx numbers prior to funding_created");
3757
+ }
3758
+ }
3750
3759
}
3751
3760
3752
3761
// Internal utility functions for channels
@@ -4679,11 +4688,7 @@ impl<SP: Deref> Channel<SP> where
4679
4688
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) },
4680
4689
)));
4681
4690
}
4682
- if self.context.commitment_secrets.get_min_seen_secret() != (1 << 48) ||
4683
- self.context.cur_counterparty_commitment_transaction_number != INITIAL_COMMITMENT_NUMBER ||
4684
- self.context.holder_commitment_point.transaction_number() != INITIAL_COMMITMENT_NUMBER {
4685
- panic!("Should not have advanced channel commitment tx numbers prior to funding_created");
4686
- }
4691
+ self.context.assert_no_commitment_advancement();
4687
4692
4688
4693
let funding_script = self.context.get_funding_redeemscript();
4689
4694
@@ -7987,11 +7992,7 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
7987
7992
) {
7988
7993
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)");
7989
7994
}
7990
- if self.context.commitment_secrets.get_min_seen_secret() != (1 << 48) ||
7991
- self.context.cur_counterparty_commitment_transaction_number != INITIAL_COMMITMENT_NUMBER ||
7992
- self.context.holder_commitment_point.transaction_number() != INITIAL_COMMITMENT_NUMBER {
7993
- panic!("Should not have advanced channel commitment tx numbers prior to funding_created");
7994
- }
7995
+ self.context.assert_no_commitment_advancement();
7995
7996
7996
7997
self.context.channel_transaction_parameters.funding_outpoint = Some(funding_txo);
7997
7998
self.context.holder_signer.as_mut().provide_channel_parameters(&self.context.channel_transaction_parameters);
@@ -8115,11 +8116,7 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
8115
8116
if !matches!(self.context.channel_state, ChannelState::FundingNegotiated) {
8116
8117
return Err((self, ChannelError::close("Received funding_signed in strange state!".to_owned())));
8117
8118
}
8118
- if self.context.commitment_secrets.get_min_seen_secret() != (1 << 48) ||
8119
- self.context.cur_counterparty_commitment_transaction_number != INITIAL_COMMITMENT_NUMBER ||
8120
- self.context.holder_commitment_point.transaction_number() != INITIAL_COMMITMENT_NUMBER {
8121
- panic!("Should not have advanced channel commitment tx numbers prior to funding_created");
8122
- }
8119
+ self.context.assert_no_commitment_advancement();
8123
8120
8124
8121
let funding_script = self.context.get_funding_redeemscript();
8125
8122
@@ -8411,11 +8408,7 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
8411
8408
// channel.
8412
8409
return Err((self, ChannelError::close("Received funding_created after we got the channel!".to_owned())));
8413
8410
}
8414
- if self.context.commitment_secrets.get_min_seen_secret() != (1 << 48) ||
8415
- self.context.cur_counterparty_commitment_transaction_number != INITIAL_COMMITMENT_NUMBER ||
8416
- self.context.holder_commitment_point.transaction_number() != INITIAL_COMMITMENT_NUMBER {
8417
- panic!("Should not have advanced channel commitment tx numbers prior to funding_created");
8418
- }
8411
+ self.context.assert_no_commitment_advancement();
8419
8412
8420
8413
let funding_txo = OutPoint { txid: msg.funding_txid, index: msg.funding_output_index };
8421
8414
self.context.channel_transaction_parameters.funding_outpoint = Some(funding_txo);
0 commit comments