@@ -2525,7 +2525,7 @@ where
2525
2525
// Our commitment numbers start at 2^48-1 and count down, whereas the ones used in transaction
2526
2526
// generation start at 0 and count up...this simplifies some parts of implementation at the
2527
2527
// cost of others, but should really just be changed.
2528
- cur_counterparty_commitment_transaction_number : u64,
2528
+ counterparty_next_commitment_transaction_number : u64,
2529
2529
pending_inbound_htlcs: Vec<InboundHTLCOutput>,
2530
2530
pending_outbound_htlcs: Vec<OutboundHTLCOutput>,
2531
2531
holding_cell_htlc_updates: Vec<HTLCUpdateAwaitingACK>,
@@ -2820,7 +2820,7 @@ where
2820
2820
};
2821
2821
let context = self.context();
2822
2822
let commitment_data = context.build_commitment_transaction(self.funding(),
2823
- context.cur_counterparty_commitment_transaction_number ,
2823
+ context.counterparty_next_commitment_transaction_number ,
2824
2824
&context.counterparty_cur_commitment_point.unwrap(), false, false, logger);
2825
2825
let counterparty_initial_commitment_tx = commitment_data.tx;
2826
2826
let counterparty_trusted_tx = counterparty_initial_commitment_tx.trust();
@@ -2881,7 +2881,7 @@ where
2881
2881
counterparty_initial_commitment_tx.clone(),
2882
2882
);
2883
2883
2884
- self.context_mut().cur_counterparty_commitment_transaction_number -= 1;
2884
+ self.context_mut().counterparty_next_commitment_transaction_number -= 1;
2885
2885
2886
2886
Ok((channel_monitor, counterparty_initial_commitment_tx))
2887
2887
}
@@ -3246,7 +3246,7 @@ where
3246
3246
shutdown_scriptpubkey,
3247
3247
destination_script,
3248
3248
3249
- cur_counterparty_commitment_transaction_number : INITIAL_COMMITMENT_NUMBER,
3249
+ counterparty_next_commitment_transaction_number : INITIAL_COMMITMENT_NUMBER,
3250
3250
3251
3251
pending_inbound_htlcs: Vec::new(),
3252
3252
pending_outbound_htlcs: Vec::new(),
@@ -3482,7 +3482,7 @@ where
3482
3482
shutdown_scriptpubkey,
3483
3483
destination_script,
3484
3484
3485
- cur_counterparty_commitment_transaction_number : INITIAL_COMMITMENT_NUMBER,
3485
+ counterparty_next_commitment_transaction_number : INITIAL_COMMITMENT_NUMBER,
3486
3486
3487
3487
pending_inbound_htlcs: Vec::new(),
3488
3488
pending_outbound_htlcs: Vec::new(),
@@ -5558,7 +5558,7 @@ where
5558
5558
if is_splice {
5559
5559
debug_assert_eq!(
5560
5560
holder_commitment_transaction_number,
5561
- self.cur_counterparty_commitment_transaction_number ,
5561
+ self.counterparty_next_commitment_transaction_number ,
5562
5562
);
5563
5563
// TODO(splicing) Forced error, as the use case is not complete
5564
5564
return Err(msgs::TxAbort {
@@ -5590,7 +5590,7 @@ where
5590
5590
&self, holder_commitment_transaction_number: u64, msg_name: &str,
5591
5591
) {
5592
5592
if self.commitment_secrets.get_min_seen_secret() != (1 << 48)
5593
- || self.cur_counterparty_commitment_transaction_number != INITIAL_COMMITMENT_NUMBER
5593
+ || self.counterparty_next_commitment_transaction_number != INITIAL_COMMITMENT_NUMBER
5594
5594
|| holder_commitment_transaction_number != INITIAL_COMMITMENT_NUMBER
5595
5595
{
5596
5596
debug_assert!(
@@ -5608,7 +5608,7 @@ where
5608
5608
SP::Target: SignerProvider,
5609
5609
L::Target: Logger,
5610
5610
{
5611
- let mut commitment_number = self.cur_counterparty_commitment_transaction_number ;
5611
+ let mut commitment_number = self.counterparty_next_commitment_transaction_number ;
5612
5612
let mut commitment_point = self.counterparty_cur_commitment_point.unwrap();
5613
5613
5614
5614
// Use the previous commitment number and point when splicing since they shouldn't change.
@@ -6776,11 +6776,11 @@ where
6776
6776
// They probably disconnected/reconnected and re-sent the channel_ready, which is
6777
6777
// required, or they're sending a fresh SCID alias.
6778
6778
let expected_point =
6779
- if self.context.cur_counterparty_commitment_transaction_number == INITIAL_COMMITMENT_NUMBER - 1 {
6779
+ if self.context.counterparty_next_commitment_transaction_number == INITIAL_COMMITMENT_NUMBER - 1 {
6780
6780
// If they haven't ever sent an updated point, the point they send should match
6781
6781
// the current one.
6782
6782
self.context.counterparty_cur_commitment_point
6783
- } else if self.context.cur_counterparty_commitment_transaction_number == INITIAL_COMMITMENT_NUMBER - 2 {
6783
+ } else if self.context.counterparty_next_commitment_transaction_number == INITIAL_COMMITMENT_NUMBER - 2 {
6784
6784
// If we've advanced the commitment number once, the second commitment point is
6785
6785
// at `counterparty_prev_commitment_point`, which is not yet revoked.
6786
6786
debug_assert!(self.context.counterparty_prev_commitment_point.is_some());
@@ -7027,7 +7027,7 @@ where
7027
7027
.context
7028
7028
.build_commitment_transaction(
7029
7029
pending_splice_funding,
7030
- self.context.cur_counterparty_commitment_transaction_number + 1,
7030
+ self.context.counterparty_next_commitment_transaction_number + 1,
7031
7031
&self.context.counterparty_prev_commitment_point.unwrap(),
7032
7032
false,
7033
7033
false,
@@ -7650,7 +7650,7 @@ where
7650
7650
ChannelSignerType::Ecdsa(ecdsa) => {
7651
7651
ecdsa
7652
7652
.validate_counterparty_revocation(
7653
- self.context.cur_counterparty_commitment_transaction_number + 1,
7653
+ self.context.counterparty_next_commitment_transaction_number + 1,
7654
7654
&secret,
7655
7655
)
7656
7656
.map_err(|_| {
@@ -7665,7 +7665,7 @@ where
7665
7665
self.context
7666
7666
.commitment_secrets
7667
7667
.provide_secret(
7668
- self.context.cur_counterparty_commitment_transaction_number + 1,
7668
+ self.context.counterparty_next_commitment_transaction_number + 1,
7669
7669
msg.per_commitment_secret,
7670
7670
)
7671
7671
.map_err(|_| {
@@ -7675,7 +7675,7 @@ where
7675
7675
let mut monitor_update = ChannelMonitorUpdate {
7676
7676
update_id: self.context.latest_monitor_update_id,
7677
7677
updates: vec![ChannelMonitorUpdateStep::CommitmentSecret {
7678
- idx: self.context.cur_counterparty_commitment_transaction_number + 1,
7678
+ idx: self.context.counterparty_next_commitment_transaction_number + 1,
7679
7679
secret: msg.per_commitment_secret,
7680
7680
}],
7681
7681
channel_id: Some(self.context.channel_id()),
@@ -7690,7 +7690,7 @@ where
7690
7690
self.context.counterparty_prev_commitment_point =
7691
7691
self.context.counterparty_cur_commitment_point;
7692
7692
self.context.counterparty_cur_commitment_point = Some(msg.next_per_commitment_point);
7693
- self.context.cur_counterparty_commitment_transaction_number -= 1;
7693
+ self.context.counterparty_next_commitment_transaction_number -= 1;
7694
7694
7695
7695
if self.context.announcement_sigs_state == AnnouncementSigsState::Committed {
7696
7696
self.context.announcement_sigs_state = AnnouncementSigsState::PeerReceived;
@@ -8429,7 +8429,7 @@ where
8429
8429
}
8430
8430
let funding_signed = if self.context.signer_pending_funding && !self.funding.is_outbound() {
8431
8431
let commitment_data = self.context.build_commitment_transaction(&self.funding,
8432
- self.context.cur_counterparty_commitment_transaction_number + 1,
8432
+ self.context.counterparty_next_commitment_transaction_number + 1,
8433
8433
&self.context.counterparty_cur_commitment_point.unwrap(), false, false, logger);
8434
8434
let counterparty_initial_commitment_tx = commitment_data.tx;
8435
8435
self.context.get_funding_signed_msg(&self.funding.channel_transaction_parameters, logger, counterparty_initial_commitment_tx)
@@ -8795,12 +8795,12 @@ where
8795
8795
)));
8796
8796
};
8797
8797
8798
- // We increment cur_counterparty_commitment_transaction_number only upon receipt of
8798
+ // We increment counterparty_next_commitment_transaction_number only upon receipt of
8799
8799
// revoke_and_ack, not on sending commitment_signed, so we add one if have
8800
8800
// AwaitingRemoteRevoke set, which indicates we sent a commitment_signed but haven't gotten
8801
8801
// the corresponding revoke_and_ack back yet.
8802
8802
let is_awaiting_remote_revoke = self.context.channel_state.is_awaiting_remote_revoke();
8803
- let next_counterparty_commitment_number = INITIAL_COMMITMENT_NUMBER - self.context.cur_counterparty_commitment_transaction_number + if is_awaiting_remote_revoke { 1 } else { 0 };
8803
+ let next_counterparty_commitment_number = INITIAL_COMMITMENT_NUMBER - self.context.counterparty_next_commitment_transaction_number + if is_awaiting_remote_revoke { 1 } else { 0 };
8804
8804
8805
8805
let channel_ready = if msg.next_local_commitment_number == 1 && INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.next_transaction_number() == 1 {
8806
8806
// We should never have to worry about MonitorUpdateInProgress resending ChannelReady
@@ -9631,12 +9631,12 @@ where
9631
9631
}
9632
9632
9633
9633
pub fn get_cur_counterparty_commitment_transaction_number(&self) -> u64 {
9634
- self.context.cur_counterparty_commitment_transaction_number + 1
9634
+ self.context.counterparty_next_commitment_transaction_number + 1
9635
9635
- if self.context.channel_state.is_awaiting_remote_revoke() { 1 } else { 0 }
9636
9636
}
9637
9637
9638
9638
pub fn get_revoked_counterparty_commitment_transaction_number(&self) -> u64 {
9639
- let ret = self.context.cur_counterparty_commitment_transaction_number + 2;
9639
+ let ret = self.context.counterparty_next_commitment_transaction_number + 2;
9640
9640
debug_assert_eq!(self.context.commitment_secrets.get_min_seen_secret(), ret);
9641
9641
ret
9642
9642
}
@@ -9754,7 +9754,7 @@ where
9754
9754
return true;
9755
9755
}
9756
9756
if self.holder_commitment_point.next_transaction_number() == INITIAL_COMMITMENT_NUMBER - 1 &&
9757
- self.context.cur_counterparty_commitment_transaction_number == INITIAL_COMMITMENT_NUMBER - 1 {
9757
+ self.context.counterparty_next_commitment_transaction_number == INITIAL_COMMITMENT_NUMBER - 1 {
9758
9758
// If we're a 0-conf channel, we'll move beyond AwaitingChannelReady immediately even while
9759
9759
// waiting for the initial monitor persistence. Thus, we check if our commitment
9760
9760
// transaction numbers have both been iterated only exactly once (for the
@@ -10541,7 +10541,7 @@ where
10541
10541
#[rustfmt::skip]
10542
10542
fn get_channel_reestablish<L: Deref>(&mut self, logger: &L) -> msgs::ChannelReestablish where L::Target: Logger {
10543
10543
assert!(self.context.channel_state.is_peer_disconnected());
10544
- assert_ne!(self.context.cur_counterparty_commitment_transaction_number , INITIAL_COMMITMENT_NUMBER);
10544
+ assert_ne!(self.context.counterparty_next_commitment_transaction_number , INITIAL_COMMITMENT_NUMBER);
10545
10545
// This is generally the first function which gets called on any given channel once we're
10546
10546
// up and running normally. Thus, we take this opportunity to attempt to resolve the
10547
10547
// `holder_commitment_point` to get any keys which we are currently missing.
@@ -10556,8 +10556,8 @@ where
10556
10556
// valid, and valid in fuzzing mode's arbitrary validity criteria:
10557
10557
let mut pk = [2; 33]; pk[1] = 0xff;
10558
10558
let dummy_pubkey = PublicKey::from_slice(&pk).unwrap();
10559
- let remote_last_secret = if self.context.cur_counterparty_commitment_transaction_number + 1 < INITIAL_COMMITMENT_NUMBER {
10560
- let remote_last_secret = self.context.commitment_secrets.get_secret(self.context.cur_counterparty_commitment_transaction_number + 2).unwrap();
10559
+ let remote_last_secret = if self.context.counterparty_next_commitment_transaction_number + 1 < INITIAL_COMMITMENT_NUMBER {
10560
+ let remote_last_secret = self.context.commitment_secrets.get_secret(self.context.counterparty_next_commitment_transaction_number + 2).unwrap();
10561
10561
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());
10562
10562
remote_last_secret
10563
10563
} else {
@@ -10580,10 +10580,10 @@ where
10580
10580
// receive, however we track it by the next commitment number for a remote transaction
10581
10581
// (which is one further, as they always revoke previous commitment transaction, not
10582
10582
// the one we send) so we have to decrement by 1. Note that if
10583
- // cur_counterparty_commitment_transaction_number is INITIAL_COMMITMENT_NUMBER we will have
10583
+ // counterparty_next_commitment_transaction_number is INITIAL_COMMITMENT_NUMBER we will have
10584
10584
// dropped this channel on disconnect as it hasn't yet reached AwaitingChannelReady so we can't
10585
10585
// overflow here.
10586
- next_remote_commitment_number: INITIAL_COMMITMENT_NUMBER - self.context.cur_counterparty_commitment_transaction_number - 1,
10586
+ next_remote_commitment_number: INITIAL_COMMITMENT_NUMBER - self.context.counterparty_next_commitment_transaction_number - 1,
10587
10587
your_last_per_commitment_secret: remote_last_secret,
10588
10588
my_current_per_commitment_point: dummy_pubkey,
10589
10589
next_funding_txid: self.maybe_get_next_funding_txid(),
@@ -11202,7 +11202,7 @@ where
11202
11202
ChannelMonitorUpdateStep::LatestCounterpartyCommitmentTXInfo {
11203
11203
commitment_txid: counterparty_commitment_tx.trust().txid(),
11204
11204
htlc_outputs,
11205
- commitment_number: self.context.cur_counterparty_commitment_transaction_number ,
11205
+ commitment_number: self.context.counterparty_next_commitment_transaction_number ,
11206
11206
their_per_commitment_point: self.context.counterparty_cur_commitment_point.unwrap(),
11207
11207
feerate_per_kw: Some(counterparty_commitment_tx.feerate_per_kw()),
11208
11208
to_broadcaster_value_sat: Some(counterparty_commitment_tx.to_broadcaster_value_sat()),
@@ -11259,7 +11259,7 @@ where
11259
11259
L::Target: Logger,
11260
11260
{
11261
11261
let commitment_data = self.context.build_commitment_transaction(
11262
- funding, self.context.cur_counterparty_commitment_transaction_number ,
11262
+ funding, self.context.counterparty_next_commitment_transaction_number ,
11263
11263
&self.context.counterparty_cur_commitment_point.unwrap(), false, true, logger,
11264
11264
);
11265
11265
let counterparty_commitment_tx = commitment_data.tx;
@@ -11310,7 +11310,7 @@ where
11310
11310
self.build_commitment_no_state_update(funding, logger);
11311
11311
11312
11312
let commitment_data = self.context.build_commitment_transaction(
11313
- funding, self.context.cur_counterparty_commitment_transaction_number ,
11313
+ funding, self.context.counterparty_next_commitment_transaction_number ,
11314
11314
&self.context.counterparty_cur_commitment_point.unwrap(), false, true, logger,
11315
11315
);
11316
11316
let counterparty_commitment_tx = commitment_data.tx;
@@ -11879,7 +11879,7 @@ where
11879
11879
#[rustfmt::skip]
11880
11880
fn get_funding_created_msg<L: Deref>(&mut self, logger: &L) -> Option<msgs::FundingCreated> where L::Target: Logger {
11881
11881
let commitment_data = self.context.build_commitment_transaction(&self.funding,
11882
- self.context.cur_counterparty_commitment_transaction_number ,
11882
+ self.context.counterparty_next_commitment_transaction_number ,
11883
11883
&self.context.counterparty_cur_commitment_point.unwrap(), false, false, logger);
11884
11884
let counterparty_initial_commitment_tx = commitment_data.tx;
11885
11885
let signature = match &self.context.holder_signer {
@@ -12910,7 +12910,7 @@ where
12910
12910
self.context.destination_script.write(writer)?;
12911
12911
12912
12912
self.holder_commitment_point.next_transaction_number().write(writer)?;
12913
- self.context.cur_counterparty_commitment_transaction_number .write(writer)?;
12913
+ self.context.counterparty_next_commitment_transaction_number .write(writer)?;
12914
12914
self.funding.value_to_self_msat.write(writer)?;
12915
12915
12916
12916
let mut dropped_inbound_htlcs = 0;
@@ -13341,7 +13341,7 @@ where
13341
13341
let destination_script = Readable::read(reader)?;
13342
13342
13343
13343
let holder_commitment_next_transaction_number = Readable::read(reader)?;
13344
- let cur_counterparty_commitment_transaction_number = Readable::read(reader)?;
13344
+ let counterparty_next_commitment_transaction_number = Readable::read(reader)?;
13345
13345
let value_to_self_msat = Readable::read(reader)?;
13346
13346
13347
13347
let pending_inbound_htlc_count: u64 = Readable::read(reader)?;
@@ -13973,7 +13973,7 @@ where
13973
13973
shutdown_scriptpubkey,
13974
13974
destination_script,
13975
13975
13976
- cur_counterparty_commitment_transaction_number ,
13976
+ counterparty_next_commitment_transaction_number ,
13977
13977
13978
13978
holder_max_accepted_htlcs,
13979
13979
pending_inbound_htlcs,
0 commit comments