@@ -1250,8 +1250,8 @@ pub(crate) struct ShutdownResult {
1250
1250
/// commitment points from our signer.
1251
1251
#[derive(Debug, Copy, Clone)]
1252
1252
struct HolderCommitmentPoint {
1253
- transaction_number : u64,
1254
- point : PublicKey,
1253
+ next_transaction_number : u64,
1254
+ next_point : PublicKey,
1255
1255
pending_next_point: Option<PublicKey>,
1256
1256
}
1257
1257
@@ -1261,8 +1261,8 @@ impl HolderCommitmentPoint {
1261
1261
where SP::Target: SignerProvider
1262
1262
{
1263
1263
Some(HolderCommitmentPoint {
1264
- transaction_number : INITIAL_COMMITMENT_NUMBER,
1265
- point : signer.as_ref().get_per_commitment_point(INITIAL_COMMITMENT_NUMBER, secp_ctx).ok()?,
1264
+ next_transaction_number : INITIAL_COMMITMENT_NUMBER,
1265
+ next_point : signer.as_ref().get_per_commitment_point(INITIAL_COMMITMENT_NUMBER, secp_ctx).ok()?,
1266
1266
pending_next_point: signer.as_ref().get_per_commitment_point(INITIAL_COMMITMENT_NUMBER - 1, secp_ctx).ok(),
1267
1267
})
1268
1268
}
@@ -1271,12 +1271,12 @@ impl HolderCommitmentPoint {
1271
1271
self.pending_next_point.is_some()
1272
1272
}
1273
1273
1274
- pub fn transaction_number (&self) -> u64 {
1275
- self.transaction_number
1274
+ pub fn next_transaction_number (&self) -> u64 {
1275
+ self.next_transaction_number
1276
1276
}
1277
1277
1278
- pub fn point (&self) -> PublicKey {
1279
- self.point
1278
+ pub fn next_point (&self) -> PublicKey {
1279
+ self.next_point
1280
1280
}
1281
1281
1282
1282
/// If we are pending advancing the next commitment point, this method tries asking the signer
@@ -1288,20 +1288,21 @@ impl HolderCommitmentPoint {
1288
1288
L::Target: Logger,
1289
1289
{
1290
1290
if !self.can_advance() {
1291
- let pending_next_point =
1292
- signer.as_ref().get_per_commitment_point(self.transaction_number - 1, secp_ctx);
1291
+ let pending_next_point = signer
1292
+ .as_ref()
1293
+ .get_per_commitment_point(self.next_transaction_number - 1, secp_ctx);
1293
1294
if let Ok(point) = pending_next_point {
1294
1295
log_trace!(
1295
1296
logger,
1296
1297
"Retrieved per-commitment point {} for next advancement",
1297
- self.transaction_number - 1
1298
+ self.next_transaction_number - 1
1298
1299
);
1299
1300
self.pending_next_point = Some(point);
1300
1301
} else {
1301
1302
log_trace!(
1302
1303
logger,
1303
1304
"Pending per-commitment point {} for next advancement",
1304
- self.transaction_number - 1
1305
+ self.next_transaction_number - 1
1305
1306
);
1306
1307
}
1307
1308
}
@@ -1326,8 +1327,8 @@ impl HolderCommitmentPoint {
1326
1327
{
1327
1328
if let Some(next_point) = self.pending_next_point {
1328
1329
*self = Self {
1329
- transaction_number : self.transaction_number - 1,
1330
- point: next_point,
1330
+ next_transaction_number : self.next_transaction_number - 1,
1331
+ next_point,
1331
1332
pending_next_point: None,
1332
1333
};
1333
1334
@@ -1787,7 +1788,7 @@ where
1787
1788
&mut funding,
1788
1789
&mut signing_session,
1789
1790
true,
1790
- chan.holder_commitment_point.transaction_number (),
1791
+ chan.holder_commitment_point.next_transaction_number (),
1791
1792
&&logger,
1792
1793
)?;
1793
1794
@@ -2001,7 +2002,7 @@ impl UnfundedChannelContext {
2001
2002
fn transaction_number(&self) -> u64 {
2002
2003
self.holder_commitment_point
2003
2004
.as_ref()
2004
- .map(|point| point.transaction_number ())
2005
+ .map(|point| point.next_transaction_number ())
2005
2006
.unwrap_or(INITIAL_COMMITMENT_NUMBER)
2006
2007
}
2007
2008
}
@@ -2745,7 +2746,7 @@ where
2745
2746
let funding_script = self.funding().get_funding_redeemscript();
2746
2747
2747
2748
let commitment_data = self.context().build_commitment_transaction(self.funding(),
2748
- holder_commitment_point.transaction_number (), &holder_commitment_point.point (),
2749
+ holder_commitment_point.next_transaction_number (), &holder_commitment_point.next_point (),
2749
2750
true, false, logger);
2750
2751
let initial_commitment_tx = commitment_data.tx;
2751
2752
let trusted_tx = initial_commitment_tx.trust();
@@ -4192,7 +4193,7 @@ where
4192
4193
let funding_script = funding.get_funding_redeemscript();
4193
4194
4194
4195
let commitment_data = self.build_commitment_transaction(funding,
4195
- holder_commitment_point.transaction_number (), &holder_commitment_point.point (),
4196
+ holder_commitment_point.next_transaction_number (), &holder_commitment_point.next_point (),
4196
4197
true, false, logger);
4197
4198
let commitment_txid = {
4198
4199
let trusted_tx = commitment_data.tx.trust();
@@ -6942,7 +6943,7 @@ where
6942
6943
}
6943
6944
6944
6945
let holder_commitment_point = &mut self.holder_commitment_point.clone();
6945
- self.context.assert_no_commitment_advancement(holder_commitment_point.transaction_number (), "initial commitment_signed");
6946
+ self.context.assert_no_commitment_advancement(holder_commitment_point.next_transaction_number (), "initial commitment_signed");
6946
6947
6947
6948
let (channel_monitor, _) = self.initial_commitment_signed(
6948
6949
self.context.channel_id(), msg.signature, holder_commitment_point, best_block, signer_provider, logger)?;
@@ -8483,30 +8484,30 @@ where
8483
8484
8484
8485
#[rustfmt::skip]
8485
8486
fn get_last_revoke_and_ack<L: Deref>(&mut self, logger: &L) -> Option<msgs::RevokeAndACK> where L::Target: Logger {
8486
- debug_assert!(self.holder_commitment_point.transaction_number () <= INITIAL_COMMITMENT_NUMBER - 2);
8487
+ debug_assert!(self.holder_commitment_point.next_transaction_number () <= INITIAL_COMMITMENT_NUMBER - 2);
8487
8488
self.holder_commitment_point.try_resolve_pending(&self.context.holder_signer, &self.context.secp_ctx, logger);
8488
8489
let per_commitment_secret = self.context.holder_signer.as_ref()
8489
- .release_commitment_secret(self.holder_commitment_point.transaction_number () + 2).ok();
8490
+ .release_commitment_secret(self.holder_commitment_point.next_transaction_number () + 2).ok();
8490
8491
if let Some(per_commitment_secret) = per_commitment_secret {
8491
8492
if self.holder_commitment_point.can_advance() {
8492
8493
self.context.signer_pending_revoke_and_ack = false;
8493
8494
return Some(msgs::RevokeAndACK {
8494
8495
channel_id: self.context.channel_id,
8495
8496
per_commitment_secret,
8496
- next_per_commitment_point: self.holder_commitment_point.point (),
8497
+ next_per_commitment_point: self.holder_commitment_point.next_point (),
8497
8498
#[cfg(taproot)]
8498
8499
next_local_nonce: None,
8499
8500
})
8500
8501
}
8501
8502
}
8502
8503
if !self.holder_commitment_point.can_advance() {
8503
8504
log_trace!(logger, "Last revoke-and-ack pending in channel {} for sequence {} because the next per-commitment point is not available",
8504
- &self.context.channel_id(), self.holder_commitment_point.transaction_number ());
8505
+ &self.context.channel_id(), self.holder_commitment_point.next_transaction_number ());
8505
8506
}
8506
8507
if per_commitment_secret.is_none() {
8507
8508
log_trace!(logger, "Last revoke-and-ack pending in channel {} for sequence {} because the next per-commitment secret for {} is not available",
8508
- &self.context.channel_id(), self.holder_commitment_point.transaction_number (),
8509
- self.holder_commitment_point.transaction_number () + 2);
8509
+ &self.context.channel_id(), self.holder_commitment_point.next_transaction_number (),
8510
+ self.holder_commitment_point.next_transaction_number () + 2);
8510
8511
}
8511
8512
// Technically if HolderCommitmentPoint::can_advance is false,
8512
8513
// we have a commitment point ready to send in an RAA, however we
@@ -8515,7 +8516,7 @@ where
8515
8516
// RAA here is a convenient way to make sure that post-funding
8516
8517
// we're only ever waiting on one commitment point at a time.
8517
8518
log_trace!(logger, "Last revoke-and-ack pending in channel {} for sequence {} because the next per-commitment point is not available",
8518
- &self.context.channel_id(), self.holder_commitment_point.transaction_number ());
8519
+ &self.context.channel_id(), self.holder_commitment_point.next_transaction_number ());
8519
8520
self.context.signer_pending_revoke_and_ack = true;
8520
8521
None
8521
8522
}
@@ -8663,7 +8664,7 @@ where
8663
8664
return Err(ChannelError::close("Peer sent an invalid channel_reestablish to force close in a non-standard way".to_owned()));
8664
8665
}
8665
8666
8666
- let our_commitment_transaction = INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number () - 1;
8667
+ let our_commitment_transaction = INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.next_transaction_number () - 1;
8667
8668
if msg.next_remote_commitment_number > 0 {
8668
8669
let expected_point = self.context.holder_signer.as_ref()
8669
8670
.get_per_commitment_point(INITIAL_COMMITMENT_NUMBER - msg.next_remote_commitment_number + 1, &self.context.secp_ctx)
@@ -8765,7 +8766,7 @@ where
8765
8766
let is_awaiting_remote_revoke = self.context.channel_state.is_awaiting_remote_revoke();
8766
8767
let next_counterparty_commitment_number = INITIAL_COMMITMENT_NUMBER - self.context.cur_counterparty_commitment_transaction_number + if is_awaiting_remote_revoke { 1 } else { 0 };
8767
8768
8768
- let channel_ready = if msg.next_local_commitment_number == 1 && INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number () == 1 {
8769
+ let channel_ready = if msg.next_local_commitment_number == 1 && INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.next_transaction_number () == 1 {
8769
8770
// We should never have to worry about MonitorUpdateInProgress resending ChannelReady
8770
8771
self.get_channel_ready(logger)
8771
8772
} else { None };
@@ -9590,7 +9591,7 @@ where
9590
9591
}
9591
9592
9592
9593
pub fn get_cur_holder_commitment_transaction_number(&self) -> u64 {
9593
- self.holder_commitment_point.transaction_number () + 1
9594
+ self.holder_commitment_point.next_transaction_number () + 1
9594
9595
}
9595
9596
9596
9597
pub fn get_cur_counterparty_commitment_transaction_number(&self) -> u64 {
@@ -9714,7 +9715,7 @@ where
9714
9715
debug_assert!(self.context.minimum_depth.unwrap_or(1) > 0);
9715
9716
return true;
9716
9717
}
9717
- if self.holder_commitment_point.transaction_number () == INITIAL_COMMITMENT_NUMBER - 1 &&
9718
+ if self.holder_commitment_point.next_transaction_number () == INITIAL_COMMITMENT_NUMBER - 1 &&
9718
9719
self.context.cur_counterparty_commitment_transaction_number == INITIAL_COMMITMENT_NUMBER - 1 {
9719
9720
// If we're a 0-conf channel, we'll move beyond AwaitingChannelReady immediately even while
9720
9721
// waiting for the initial monitor persistence. Thus, we check if our commitment
@@ -9852,7 +9853,7 @@ where
9852
9853
self.context.signer_pending_channel_ready = false;
9853
9854
Some(msgs::ChannelReady {
9854
9855
channel_id: self.context.channel_id(),
9855
- next_per_commitment_point: self.holder_commitment_point.point (),
9856
+ next_per_commitment_point: self.holder_commitment_point.next_point (),
9856
9857
short_channel_id_alias: Some(self.context.outbound_scid_alias),
9857
9858
})
9858
9859
} else {
@@ -10555,7 +10556,7 @@ where
10555
10556
10556
10557
// next_local_commitment_number is the next commitment_signed number we expect to
10557
10558
// receive (indicating if they need to resend one that we missed).
10558
- next_local_commitment_number: INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number (),
10559
+ next_local_commitment_number: INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.next_transaction_number (),
10559
10560
// We have to set next_remote_commitment_number to the next revoke_and_ack we expect to
10560
10561
// receive, however we track it by the next commitment number for a remote transaction
10561
10562
// (which is one further, as they always revoke previous commitment transaction, not
@@ -11963,7 +11964,7 @@ where
11963
11964
let first_per_commitment_point = match self.unfunded_context.holder_commitment_point {
11964
11965
Some(holder_commitment_point) if holder_commitment_point.can_advance() => {
11965
11966
self.signer_pending_open_channel = false;
11966
- holder_commitment_point.point ()
11967
+ holder_commitment_point.next_point ()
11967
11968
},
11968
11969
_ => {
11969
11970
log_trace!(_logger, "Unable to generate open_channel message, waiting for commitment point");
@@ -12035,7 +12036,7 @@ where
12035
12036
Some(point) => point,
12036
12037
None => return Err((self, ChannelError::close("Received funding_signed before our first commitment point was available".to_owned()))),
12037
12038
};
12038
- self.context.assert_no_commitment_advancement(holder_commitment_point.transaction_number (), "funding_signed");
12039
+ self.context.assert_no_commitment_advancement(holder_commitment_point.next_transaction_number (), "funding_signed");
12039
12040
12040
12041
let (channel_monitor, _) = match self.initial_commitment_signed(
12041
12042
self.context.channel_id(), msg.signature,
@@ -12237,7 +12238,7 @@ where
12237
12238
let first_per_commitment_point = match self.unfunded_context.holder_commitment_point {
12238
12239
Some(holder_commitment_point) if holder_commitment_point.can_advance() => {
12239
12240
self.signer_pending_accept_channel = false;
12240
- holder_commitment_point.point ()
12241
+ holder_commitment_point.next_point ()
12241
12242
},
12242
12243
_ => {
12243
12244
log_trace!(_logger, "Unable to generate accept_channel message, waiting for commitment point");
@@ -12311,7 +12312,7 @@ where
12311
12312
Some(point) => point,
12312
12313
None => return Err((self, ChannelError::close("Received funding_created before our first commitment point was available".to_owned()))),
12313
12314
};
12314
- self.context.assert_no_commitment_advancement(holder_commitment_point.transaction_number (), "funding_created");
12315
+ self.context.assert_no_commitment_advancement(holder_commitment_point.next_transaction_number (), "funding_created");
12315
12316
12316
12317
let funding_txo = OutPoint { txid: msg.funding_txid, index: msg.funding_output_index };
12317
12318
self.funding.channel_transaction_parameters.funding_outpoint = Some(funding_txo);
@@ -12866,7 +12867,7 @@ where
12866
12867
}
12867
12868
self.context.destination_script.write(writer)?;
12868
12869
12869
- self.holder_commitment_point.transaction_number ().write(writer)?;
12870
+ self.holder_commitment_point.next_transaction_number ().write(writer)?;
12870
12871
self.context.cur_counterparty_commitment_transaction_number.write(writer)?;
12871
12872
self.funding.value_to_self_msat.write(writer)?;
12872
12873
@@ -13197,8 +13198,8 @@ where
13197
13198
}
13198
13199
let is_manual_broadcast = Some(self.context.is_manual_broadcast);
13199
13200
13200
- // `HolderCommitmentPoint::point ` will become optional when async signing is implemented.
13201
- let holder_commitment_point = Some(self.holder_commitment_point.point ());
13201
+ // `HolderCommitmentPoint::next_point ` will become optional when async signing is implemented.
13202
+ let holder_commitment_point_next = Some(self.holder_commitment_point.next_point ());
13202
13203
let holder_commitment_point_pending_next = self.holder_commitment_point.pending_next_point;
13203
13204
13204
13205
write_tlv_fields!(writer, {
@@ -13237,7 +13238,7 @@ where
13237
13238
(39, pending_outbound_blinding_points, optional_vec),
13238
13239
(41, holding_cell_blinding_points, optional_vec),
13239
13240
(43, malformed_htlcs, optional_vec), // Added in 0.0.119
13240
- (45, holder_commitment_point , option),
13241
+ (45, holder_commitment_point_next , option),
13241
13242
(47, holder_commitment_point_pending_next, option),
13242
13243
(49, self.context.local_initiated_shutdown, option), // Added in 0.0.122
13243
13244
(51, is_manual_broadcast, option), // Added in 0.0.124
@@ -13295,7 +13296,7 @@ where
13295
13296
};
13296
13297
let destination_script = Readable::read(reader)?;
13297
13298
13298
- let holder_commitment_transaction_number = Readable::read(reader)?;
13299
+ let holder_commitment_next_transaction_number = Readable::read(reader)?;
13299
13300
let cur_counterparty_commitment_transaction_number = Readable::read(reader)?;
13300
13301
let value_to_self_msat = Readable::read(reader)?;
13301
13302
@@ -13598,7 +13599,7 @@ where
13598
13599
let mut malformed_htlcs: Option<Vec<(u64, u16, [u8; 32])>> = None;
13599
13600
let mut monitor_pending_update_adds: Option<Vec<msgs::UpdateAddHTLC>> = None;
13600
13601
13601
- let mut holder_commitment_point_opt : Option<PublicKey> = None;
13602
+ let mut holder_commitment_point_next_opt : Option<PublicKey> = None;
13602
13603
let mut holder_commitment_point_pending_next_opt: Option<PublicKey> = None;
13603
13604
let mut is_manual_broadcast = None;
13604
13605
@@ -13639,7 +13640,7 @@ where
13639
13640
(39, pending_outbound_blinding_points_opt, optional_vec),
13640
13641
(41, holding_cell_blinding_points_opt, optional_vec),
13641
13642
(43, malformed_htlcs, optional_vec), // Added in 0.0.119
13642
- (45, holder_commitment_point_opt , option),
13643
+ (45, holder_commitment_point_next_opt , option),
13643
13644
(47, holder_commitment_point_pending_next_opt, option),
13644
13645
(49, local_initiated_shutdown, option),
13645
13646
(51, is_manual_broadcast, option),
@@ -13829,26 +13830,29 @@ where
13829
13830
// signer be available so that we can immediately populate the current commitment point. Channel
13830
13831
// restoration will fail if this is not possible.
13831
13832
let holder_commitment_point =
13832
- match (holder_commitment_point_opt , holder_commitment_point_pending_next_opt) {
13833
- (Some(point ), pending_next_point) => HolderCommitmentPoint {
13834
- transaction_number: holder_commitment_transaction_number ,
13835
- point ,
13833
+ match (holder_commitment_point_next_opt , holder_commitment_point_pending_next_opt) {
13834
+ (Some(next_point ), pending_next_point) => HolderCommitmentPoint {
13835
+ next_transaction_number: holder_commitment_next_transaction_number ,
13836
+ next_point ,
13836
13837
pending_next_point,
13837
13838
},
13838
13839
(_, _) => {
13839
- let point = holder_signer.get_per_commitment_point(holder_commitment_transaction_number, &secp_ctx)
13840
- .expect("Must be able to derive the current commitment point upon channel restoration");
13840
+ let next_point = holder_signer
13841
+ .get_per_commitment_point(holder_commitment_next_transaction_number, &secp_ctx)
13842
+ .expect(
13843
+ "Must be able to derive the next commitment point upon channel restoration",
13844
+ );
13841
13845
let pending_next_point = holder_signer
13842
13846
.get_per_commitment_point(
13843
- holder_commitment_transaction_number - 1,
13847
+ holder_commitment_next_transaction_number - 1,
13844
13848
&secp_ctx,
13845
13849
)
13846
13850
.expect(
13847
13851
"Must be able to derive the pending next commitment point upon channel restoration",
13848
13852
);
13849
13853
HolderCommitmentPoint {
13850
- transaction_number: holder_commitment_transaction_number ,
13851
- point ,
13854
+ next_transaction_number: holder_commitment_next_transaction_number ,
13855
+ next_point ,
13852
13856
pending_next_point: Some(pending_next_point),
13853
13857
}
13854
13858
},
0 commit comments