@@ -2499,7 +2499,7 @@ where
2499
2499
// Our commitment numbers start at 2^48-1 and count down, whereas the ones used in transaction
2500
2500
// generation start at 0 and count up...this simplifies some parts of implementation at the
2501
2501
// cost of others, but should really just be changed.
2502
- cur_counterparty_commitment_transaction_number : u64,
2502
+ counterparty_next_commitment_transaction_number : u64,
2503
2503
pending_inbound_htlcs: Vec<InboundHTLCOutput>,
2504
2504
pending_outbound_htlcs: Vec<OutboundHTLCOutput>,
2505
2505
holding_cell_htlc_updates: Vec<HTLCUpdateAwaitingACK>,
@@ -2798,7 +2798,7 @@ where
2798
2798
};
2799
2799
let context = self.context();
2800
2800
let commitment_data = context.build_commitment_transaction(self.funding(),
2801
- context.cur_counterparty_commitment_transaction_number ,
2801
+ context.counterparty_next_commitment_transaction_number ,
2802
2802
&context.counterparty_cur_commitment_point.unwrap(), false, false, logger);
2803
2803
let counterparty_initial_commitment_tx = commitment_data.tx;
2804
2804
let counterparty_trusted_tx = counterparty_initial_commitment_tx.trust();
@@ -2859,7 +2859,7 @@ where
2859
2859
counterparty_initial_commitment_tx.clone(),
2860
2860
);
2861
2861
2862
- self.context_mut().cur_counterparty_commitment_transaction_number -= 1;
2862
+ self.context_mut().counterparty_next_commitment_transaction_number -= 1;
2863
2863
2864
2864
Ok((channel_monitor, counterparty_initial_commitment_tx))
2865
2865
}
@@ -3224,7 +3224,7 @@ where
3224
3224
shutdown_scriptpubkey,
3225
3225
destination_script,
3226
3226
3227
- cur_counterparty_commitment_transaction_number : INITIAL_COMMITMENT_NUMBER,
3227
+ counterparty_next_commitment_transaction_number : INITIAL_COMMITMENT_NUMBER,
3228
3228
3229
3229
pending_inbound_htlcs: Vec::new(),
3230
3230
pending_outbound_htlcs: Vec::new(),
@@ -3462,7 +3462,7 @@ where
3462
3462
shutdown_scriptpubkey,
3463
3463
destination_script,
3464
3464
3465
- cur_counterparty_commitment_transaction_number : INITIAL_COMMITMENT_NUMBER,
3465
+ counterparty_next_commitment_transaction_number : INITIAL_COMMITMENT_NUMBER,
3466
3466
3467
3467
pending_inbound_htlcs: Vec::new(),
3468
3468
pending_outbound_htlcs: Vec::new(),
@@ -5540,7 +5540,7 @@ where
5540
5540
if is_splice {
5541
5541
debug_assert_eq!(
5542
5542
holder_commitment_transaction_number,
5543
- self.cur_counterparty_commitment_transaction_number ,
5543
+ self.counterparty_next_commitment_transaction_number ,
5544
5544
);
5545
5545
// TODO(splicing) Forced error, as the use case is not complete
5546
5546
return Err(msgs::TxAbort {
@@ -5572,7 +5572,7 @@ where
5572
5572
&self, holder_commitment_transaction_number: u64, msg_name: &str,
5573
5573
) {
5574
5574
if self.commitment_secrets.get_min_seen_secret() != (1 << 48)
5575
- || self.cur_counterparty_commitment_transaction_number != INITIAL_COMMITMENT_NUMBER
5575
+ || self.counterparty_next_commitment_transaction_number != INITIAL_COMMITMENT_NUMBER
5576
5576
|| holder_commitment_transaction_number != INITIAL_COMMITMENT_NUMBER
5577
5577
{
5578
5578
debug_assert!(
@@ -5590,7 +5590,7 @@ where
5590
5590
SP::Target: SignerProvider,
5591
5591
L::Target: Logger,
5592
5592
{
5593
- let mut commitment_number = self.cur_counterparty_commitment_transaction_number ;
5593
+ let mut commitment_number = self.counterparty_next_commitment_transaction_number ;
5594
5594
let mut commitment_point = self.counterparty_cur_commitment_point.unwrap();
5595
5595
5596
5596
// Use the previous commitment number and point when splicing since they shouldn't change.
@@ -6752,11 +6752,11 @@ where
6752
6752
// They probably disconnected/reconnected and re-sent the channel_ready, which is
6753
6753
// required, or they're sending a fresh SCID alias.
6754
6754
let expected_point =
6755
- if self.context.cur_counterparty_commitment_transaction_number == INITIAL_COMMITMENT_NUMBER - 1 {
6755
+ if self.context.counterparty_next_commitment_transaction_number == INITIAL_COMMITMENT_NUMBER - 1 {
6756
6756
// If they haven't ever sent an updated point, the point they send should match
6757
6757
// the current one.
6758
6758
self.context.counterparty_cur_commitment_point
6759
- } else if self.context.cur_counterparty_commitment_transaction_number == INITIAL_COMMITMENT_NUMBER - 2 {
6759
+ } else if self.context.counterparty_next_commitment_transaction_number == INITIAL_COMMITMENT_NUMBER - 2 {
6760
6760
// If we've advanced the commitment number once, the second commitment point is
6761
6761
// at `counterparty_prev_commitment_point`, which is not yet revoked.
6762
6762
debug_assert!(self.context.counterparty_prev_commitment_point.is_some());
@@ -7003,7 +7003,7 @@ where
7003
7003
.context
7004
7004
.build_commitment_transaction(
7005
7005
pending_splice_funding,
7006
- self.context.cur_counterparty_commitment_transaction_number + 1,
7006
+ self.context.counterparty_next_commitment_transaction_number + 1,
7007
7007
&self.context.counterparty_prev_commitment_point.unwrap(),
7008
7008
false,
7009
7009
false,
@@ -7626,7 +7626,7 @@ where
7626
7626
ChannelSignerType::Ecdsa(ecdsa) => {
7627
7627
ecdsa
7628
7628
.validate_counterparty_revocation(
7629
- self.context.cur_counterparty_commitment_transaction_number + 1,
7629
+ self.context.counterparty_next_commitment_transaction_number + 1,
7630
7630
&secret,
7631
7631
)
7632
7632
.map_err(|_| {
@@ -7641,7 +7641,7 @@ where
7641
7641
self.context
7642
7642
.commitment_secrets
7643
7643
.provide_secret(
7644
- self.context.cur_counterparty_commitment_transaction_number + 1,
7644
+ self.context.counterparty_next_commitment_transaction_number + 1,
7645
7645
msg.per_commitment_secret,
7646
7646
)
7647
7647
.map_err(|_| {
@@ -7651,7 +7651,7 @@ where
7651
7651
let mut monitor_update = ChannelMonitorUpdate {
7652
7652
update_id: self.context.latest_monitor_update_id,
7653
7653
updates: vec![ChannelMonitorUpdateStep::CommitmentSecret {
7654
- idx: self.context.cur_counterparty_commitment_transaction_number + 1,
7654
+ idx: self.context.counterparty_next_commitment_transaction_number + 1,
7655
7655
secret: msg.per_commitment_secret,
7656
7656
}],
7657
7657
channel_id: Some(self.context.channel_id()),
@@ -7666,7 +7666,7 @@ where
7666
7666
self.context.counterparty_prev_commitment_point =
7667
7667
self.context.counterparty_cur_commitment_point;
7668
7668
self.context.counterparty_cur_commitment_point = Some(msg.next_per_commitment_point);
7669
- self.context.cur_counterparty_commitment_transaction_number -= 1;
7669
+ self.context.counterparty_next_commitment_transaction_number -= 1;
7670
7670
7671
7671
if self.context.announcement_sigs_state == AnnouncementSigsState::Committed {
7672
7672
self.context.announcement_sigs_state = AnnouncementSigsState::PeerReceived;
@@ -8403,7 +8403,7 @@ where
8403
8403
}
8404
8404
let funding_signed = if self.context.signer_pending_funding && !self.funding.is_outbound() {
8405
8405
let commitment_data = self.context.build_commitment_transaction(&self.funding,
8406
- self.context.cur_counterparty_commitment_transaction_number + 1,
8406
+ self.context.counterparty_next_commitment_transaction_number + 1,
8407
8407
&self.context.counterparty_cur_commitment_point.unwrap(), false, false, logger);
8408
8408
let counterparty_initial_commitment_tx = commitment_data.tx;
8409
8409
self.context.get_funding_signed_msg(&self.funding.channel_transaction_parameters, logger, counterparty_initial_commitment_tx)
@@ -8769,12 +8769,12 @@ where
8769
8769
)));
8770
8770
};
8771
8771
8772
- // We increment cur_counterparty_commitment_transaction_number only upon receipt of
8772
+ // We increment counterparty_next_commitment_transaction_number only upon receipt of
8773
8773
// revoke_and_ack, not on sending commitment_signed, so we add one if have
8774
8774
// AwaitingRemoteRevoke set, which indicates we sent a commitment_signed but haven't gotten
8775
8775
// the corresponding revoke_and_ack back yet.
8776
8776
let is_awaiting_remote_revoke = self.context.channel_state.is_awaiting_remote_revoke();
8777
- let next_counterparty_commitment_number = INITIAL_COMMITMENT_NUMBER - self.context.cur_counterparty_commitment_transaction_number + if is_awaiting_remote_revoke { 1 } else { 0 };
8777
+ let next_counterparty_commitment_number = INITIAL_COMMITMENT_NUMBER - self.context.counterparty_next_commitment_transaction_number + if is_awaiting_remote_revoke { 1 } else { 0 };
8778
8778
8779
8779
let channel_ready = if msg.next_local_commitment_number == 1 && INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.next_transaction_number() == 1 {
8780
8780
// We should never have to worry about MonitorUpdateInProgress resending ChannelReady
@@ -9605,12 +9605,12 @@ where
9605
9605
}
9606
9606
9607
9607
pub fn get_cur_counterparty_commitment_transaction_number(&self) -> u64 {
9608
- self.context.cur_counterparty_commitment_transaction_number + 1
9608
+ self.context.counterparty_next_commitment_transaction_number + 1
9609
9609
- if self.context.channel_state.is_awaiting_remote_revoke() { 1 } else { 0 }
9610
9610
}
9611
9611
9612
9612
pub fn get_revoked_counterparty_commitment_transaction_number(&self) -> u64 {
9613
- self.context.cur_counterparty_commitment_transaction_number + 2
9613
+ self.context.counterparty_next_commitment_transaction_number + 2
9614
9614
}
9615
9615
9616
9616
#[cfg(any(test, feature = "_externalize_tests"))]
@@ -9726,7 +9726,7 @@ where
9726
9726
return true;
9727
9727
}
9728
9728
if self.holder_commitment_point.next_transaction_number() == INITIAL_COMMITMENT_NUMBER - 1 &&
9729
- self.context.cur_counterparty_commitment_transaction_number == INITIAL_COMMITMENT_NUMBER - 1 {
9729
+ self.context.counterparty_next_commitment_transaction_number == INITIAL_COMMITMENT_NUMBER - 1 {
9730
9730
// If we're a 0-conf channel, we'll move beyond AwaitingChannelReady immediately even while
9731
9731
// waiting for the initial monitor persistence. Thus, we check if our commitment
9732
9732
// transaction numbers have both been iterated only exactly once (for the
@@ -10513,7 +10513,7 @@ where
10513
10513
#[rustfmt::skip]
10514
10514
fn get_channel_reestablish<L: Deref>(&mut self, logger: &L) -> msgs::ChannelReestablish where L::Target: Logger {
10515
10515
assert!(self.context.channel_state.is_peer_disconnected());
10516
- assert_ne!(self.context.cur_counterparty_commitment_transaction_number , INITIAL_COMMITMENT_NUMBER);
10516
+ assert_ne!(self.context.counterparty_next_commitment_transaction_number , INITIAL_COMMITMENT_NUMBER);
10517
10517
// This is generally the first function which gets called on any given channel once we're
10518
10518
// up and running normally. Thus, we take this opportunity to attempt to resolve the
10519
10519
// `holder_commitment_point` to get any keys which we are currently missing.
@@ -10528,8 +10528,8 @@ where
10528
10528
// valid, and valid in fuzzing mode's arbitrary validity criteria:
10529
10529
let mut pk = [2; 33]; pk[1] = 0xff;
10530
10530
let dummy_pubkey = PublicKey::from_slice(&pk).unwrap();
10531
- let remote_last_secret = if self.context.cur_counterparty_commitment_transaction_number + 1 < INITIAL_COMMITMENT_NUMBER {
10532
- let remote_last_secret = self.context.commitment_secrets.get_secret(self.context.cur_counterparty_commitment_transaction_number + 2).unwrap();
10531
+ let remote_last_secret = if self.context.counterparty_next_commitment_transaction_number + 1 < INITIAL_COMMITMENT_NUMBER {
10532
+ let remote_last_secret = self.context.commitment_secrets.get_secret(self.context.counterparty_next_commitment_transaction_number + 2).unwrap();
10533
10533
log_trace!(logger, "Enough info to generate a Data Loss Protect with per_commitment_secret {} for channel {}", log_bytes!(remote_last_secret), &self.context.channel_id());
10534
10534
remote_last_secret
10535
10535
} else {
@@ -10552,10 +10552,10 @@ where
10552
10552
// receive, however we track it by the next commitment number for a remote transaction
10553
10553
// (which is one further, as they always revoke previous commitment transaction, not
10554
10554
// the one we send) so we have to decrement by 1. Note that if
10555
- // cur_counterparty_commitment_transaction_number is INITIAL_COMMITMENT_NUMBER we will have
10555
+ // counterparty_next_commitment_transaction_number is INITIAL_COMMITMENT_NUMBER we will have
10556
10556
// dropped this channel on disconnect as it hasn't yet reached AwaitingChannelReady so we can't
10557
10557
// overflow here.
10558
- next_remote_commitment_number: INITIAL_COMMITMENT_NUMBER - self.context.cur_counterparty_commitment_transaction_number - 1,
10558
+ next_remote_commitment_number: INITIAL_COMMITMENT_NUMBER - self.context.counterparty_next_commitment_transaction_number - 1,
10559
10559
your_last_per_commitment_secret: remote_last_secret,
10560
10560
my_current_per_commitment_point: dummy_pubkey,
10561
10561
next_funding_txid: self.maybe_get_next_funding_txid(),
@@ -11174,7 +11174,7 @@ where
11174
11174
ChannelMonitorUpdateStep::LatestCounterpartyCommitmentTXInfo {
11175
11175
commitment_txid: counterparty_commitment_tx.trust().txid(),
11176
11176
htlc_outputs,
11177
- commitment_number: self.context.cur_counterparty_commitment_transaction_number ,
11177
+ commitment_number: self.context.counterparty_next_commitment_transaction_number ,
11178
11178
their_per_commitment_point: self.context.counterparty_cur_commitment_point.unwrap(),
11179
11179
feerate_per_kw: Some(counterparty_commitment_tx.feerate_per_kw()),
11180
11180
to_broadcaster_value_sat: Some(counterparty_commitment_tx.to_broadcaster_value_sat()),
@@ -11231,7 +11231,7 @@ where
11231
11231
L::Target: Logger,
11232
11232
{
11233
11233
let commitment_data = self.context.build_commitment_transaction(
11234
- funding, self.context.cur_counterparty_commitment_transaction_number ,
11234
+ funding, self.context.counterparty_next_commitment_transaction_number ,
11235
11235
&self.context.counterparty_cur_commitment_point.unwrap(), false, true, logger,
11236
11236
);
11237
11237
let counterparty_commitment_tx = commitment_data.tx;
@@ -11282,7 +11282,7 @@ where
11282
11282
self.build_commitment_no_state_update(funding, logger);
11283
11283
11284
11284
let commitment_data = self.context.build_commitment_transaction(
11285
- funding, self.context.cur_counterparty_commitment_transaction_number ,
11285
+ funding, self.context.counterparty_next_commitment_transaction_number ,
11286
11286
&self.context.counterparty_cur_commitment_point.unwrap(), false, true, logger,
11287
11287
);
11288
11288
let counterparty_commitment_tx = commitment_data.tx;
@@ -11850,7 +11850,7 @@ where
11850
11850
#[rustfmt::skip]
11851
11851
fn get_funding_created_msg<L: Deref>(&mut self, logger: &L) -> Option<msgs::FundingCreated> where L::Target: Logger {
11852
11852
let commitment_data = self.context.build_commitment_transaction(&self.funding,
11853
- self.context.cur_counterparty_commitment_transaction_number ,
11853
+ self.context.counterparty_next_commitment_transaction_number ,
11854
11854
&self.context.counterparty_cur_commitment_point.unwrap(), false, false, logger);
11855
11855
let counterparty_initial_commitment_tx = commitment_data.tx;
11856
11856
let signature = match &self.context.holder_signer {
@@ -12875,7 +12875,7 @@ where
12875
12875
self.context.destination_script.write(writer)?;
12876
12876
12877
12877
self.holder_commitment_point.next_transaction_number().write(writer)?;
12878
- self.context.cur_counterparty_commitment_transaction_number .write(writer)?;
12878
+ self.context.counterparty_next_commitment_transaction_number .write(writer)?;
12879
12879
self.funding.value_to_self_msat.write(writer)?;
12880
12880
12881
12881
let mut dropped_inbound_htlcs = 0;
@@ -13305,7 +13305,7 @@ where
13305
13305
let destination_script = Readable::read(reader)?;
13306
13306
13307
13307
let holder_commitment_next_transaction_number = Readable::read(reader)?;
13308
- let cur_counterparty_commitment_transaction_number = Readable::read(reader)?;
13308
+ let counterparty_next_commitment_transaction_number = Readable::read(reader)?;
13309
13309
let value_to_self_msat = Readable::read(reader)?;
13310
13310
13311
13311
let pending_inbound_htlc_count: u64 = Readable::read(reader)?;
@@ -13934,7 +13934,7 @@ where
13934
13934
shutdown_scriptpubkey,
13935
13935
destination_script,
13936
13936
13937
- cur_counterparty_commitment_transaction_number ,
13937
+ counterparty_next_commitment_transaction_number ,
13938
13938
13939
13939
holder_max_accepted_htlcs,
13940
13940
pending_inbound_htlcs,
0 commit comments