@@ -1790,7 +1790,7 @@ where
1790
1790
&mut funding,
1791
1791
&mut signing_session,
1792
1792
true,
1793
- chan.holder_commitment_point .transaction_number(),
1793
+ chan.next_holder_commitment_point .transaction_number(),
1794
1794
&&logger,
1795
1795
)?;
1796
1796
@@ -1851,7 +1851,7 @@ where
1851
1851
pending_funding: vec![],
1852
1852
context: chan.context,
1853
1853
interactive_tx_signing_session: chan.interactive_tx_signing_session,
1854
- holder_commitment_point : initial_holder_commitment_point,
1854
+ next_holder_commitment_point : initial_holder_commitment_point,
1855
1855
#[cfg(splicing)]
1856
1856
pending_splice: None,
1857
1857
};
@@ -6065,7 +6065,10 @@ where
6065
6065
///
6066
6066
/// This field is cleared once our counterparty sends a `channel_ready`.
6067
6067
pub interactive_tx_signing_session: Option<InteractiveTxSigningSession>,
6068
- holder_commitment_point: HolderCommitmentPoint,
6068
+
6069
+ /// The commitment point used for the next commitment transaction.
6070
+ next_holder_commitment_point: HolderCommitmentPoint,
6071
+
6069
6072
/// Info about an in-progress, pending splice (if any), on the pre-splice channel
6070
6073
#[cfg(splicing)]
6071
6074
pending_splice: Option<PendingSplice>,
@@ -6944,12 +6947,12 @@ where
6944
6947
return Err(ChannelError::Close((msg.to_owned(), reason)));
6945
6948
}
6946
6949
6947
- let holder_commitment_point = &mut self.holder_commitment_point .clone();
6948
- self.context.assert_no_commitment_advancement(holder_commitment_point .transaction_number(), "initial commitment_signed");
6950
+ let next_holder_commitment_point = &mut self.next_holder_commitment_point .clone();
6951
+ self.context.assert_no_commitment_advancement(next_holder_commitment_point .transaction_number(), "initial commitment_signed");
6949
6952
6950
6953
let (channel_monitor, _) = self.initial_commitment_signed(
6951
- self.context.channel_id(), msg.signature, holder_commitment_point , best_block, signer_provider, logger)?;
6952
- self.holder_commitment_point = *holder_commitment_point ;
6954
+ self.context.channel_id(), msg.signature, next_holder_commitment_point , best_block, signer_provider, logger)?;
6955
+ self.next_holder_commitment_point = *next_holder_commitment_point ;
6953
6956
6954
6957
log_info!(logger, "Received initial commitment_signed from peer for channel {}", &self.context.channel_id());
6955
6958
@@ -6996,7 +6999,7 @@ where
6996
6999
.expect("Funding must exist for negotiated pending splice");
6997
7000
let (holder_commitment_tx, _) = self.context.validate_commitment_signed(
6998
7001
pending_splice_funding,
6999
- &self.holder_commitment_point ,
7002
+ &self.next_holder_commitment_point ,
7000
7003
msg,
7001
7004
logger,
7002
7005
)?;
@@ -7082,7 +7085,12 @@ where
7082
7085
7083
7086
let update = self
7084
7087
.context
7085
- .validate_commitment_signed(&self.funding, &self.holder_commitment_point, msg, logger)
7088
+ .validate_commitment_signed(
7089
+ &self.funding,
7090
+ &self.next_holder_commitment_point,
7091
+ msg,
7092
+ logger,
7093
+ )
7086
7094
.map(|(commitment_tx, htlcs_included)| {
7087
7095
let (nondust_htlc_sources, dust_htlcs) =
7088
7096
Self::get_commitment_htlc_data(&htlcs_included);
@@ -7146,7 +7154,7 @@ where
7146
7154
})?;
7147
7155
let (commitment_tx, htlcs_included) = self.context.validate_commitment_signed(
7148
7156
funding,
7149
- &self.holder_commitment_point ,
7157
+ &self.next_holder_commitment_point ,
7150
7158
msg,
7151
7159
logger,
7152
7160
)?;
@@ -7205,7 +7213,7 @@ where
7205
7213
L::Target: Logger,
7206
7214
{
7207
7215
if self
7208
- .holder_commitment_point
7216
+ .next_holder_commitment_point
7209
7217
.advance(&self.context.holder_signer, &self.context.secp_ctx, logger)
7210
7218
.is_err()
7211
7219
{
@@ -8389,9 +8397,9 @@ where
8389
8397
/// blocked.
8390
8398
#[rustfmt::skip]
8391
8399
pub fn signer_maybe_unblocked<L: Deref>(&mut self, logger: &L) -> SignerResumeUpdates where L::Target: Logger {
8392
- if !self.holder_commitment_point .can_advance() {
8400
+ if !self.next_holder_commitment_point .can_advance() {
8393
8401
log_trace!(logger, "Attempting to update holder per-commitment point...");
8394
- self.holder_commitment_point .try_resolve_pending(&self.context.holder_signer, &self.context.secp_ctx, logger);
8402
+ self.next_holder_commitment_point .try_resolve_pending(&self.context.holder_signer, &self.context.secp_ctx, logger);
8395
8403
}
8396
8404
let funding_signed = if self.context.signer_pending_funding && !self.funding.is_outbound() {
8397
8405
let commitment_data = self.context.build_commitment_transaction(&self.funding,
@@ -8486,30 +8494,30 @@ where
8486
8494
8487
8495
#[rustfmt::skip]
8488
8496
fn get_last_revoke_and_ack<L: Deref>(&mut self, logger: &L) -> Option<msgs::RevokeAndACK> where L::Target: Logger {
8489
- debug_assert!(self.holder_commitment_point .transaction_number() <= INITIAL_COMMITMENT_NUMBER - 2);
8490
- self.holder_commitment_point .try_resolve_pending(&self.context.holder_signer, &self.context.secp_ctx, logger);
8497
+ debug_assert!(self.next_holder_commitment_point .transaction_number() <= INITIAL_COMMITMENT_NUMBER - 2);
8498
+ self.next_holder_commitment_point .try_resolve_pending(&self.context.holder_signer, &self.context.secp_ctx, logger);
8491
8499
let per_commitment_secret = self.context.holder_signer.as_ref()
8492
- .release_commitment_secret(self.holder_commitment_point .transaction_number() + 2).ok();
8500
+ .release_commitment_secret(self.next_holder_commitment_point .transaction_number() + 2).ok();
8493
8501
if let Some(per_commitment_secret) = per_commitment_secret {
8494
- if self.holder_commitment_point .can_advance() {
8502
+ if self.next_holder_commitment_point .can_advance() {
8495
8503
self.context.signer_pending_revoke_and_ack = false;
8496
8504
return Some(msgs::RevokeAndACK {
8497
8505
channel_id: self.context.channel_id,
8498
8506
per_commitment_secret,
8499
- next_per_commitment_point: self.holder_commitment_point .point(),
8507
+ next_per_commitment_point: self.next_holder_commitment_point .point(),
8500
8508
#[cfg(taproot)]
8501
8509
next_local_nonce: None,
8502
8510
})
8503
8511
}
8504
8512
}
8505
- if !self.holder_commitment_point .can_advance() {
8513
+ if !self.next_holder_commitment_point .can_advance() {
8506
8514
log_trace!(logger, "Last revoke-and-ack pending in channel {} for sequence {} because the next per-commitment point is not available",
8507
- &self.context.channel_id(), self.holder_commitment_point .transaction_number());
8515
+ &self.context.channel_id(), self.next_holder_commitment_point .transaction_number());
8508
8516
}
8509
8517
if per_commitment_secret.is_none() {
8510
8518
log_trace!(logger, "Last revoke-and-ack pending in channel {} for sequence {} because the next per-commitment secret for {} is not available",
8511
- &self.context.channel_id(), self.holder_commitment_point .transaction_number(),
8512
- self.holder_commitment_point .transaction_number() + 2);
8519
+ &self.context.channel_id(), self.next_holder_commitment_point .transaction_number(),
8520
+ self.next_holder_commitment_point .transaction_number() + 2);
8513
8521
}
8514
8522
// Technically if HolderCommitmentPoint::can_advance is false,
8515
8523
// we have a commitment point ready to send in an RAA, however we
@@ -8518,7 +8526,7 @@ where
8518
8526
// RAA here is a convenient way to make sure that post-funding
8519
8527
// we're only ever waiting on one commitment point at a time.
8520
8528
log_trace!(logger, "Last revoke-and-ack pending in channel {} for sequence {} because the next per-commitment point is not available",
8521
- &self.context.channel_id(), self.holder_commitment_point .transaction_number());
8529
+ &self.context.channel_id(), self.next_holder_commitment_point .transaction_number());
8522
8530
self.context.signer_pending_revoke_and_ack = true;
8523
8531
None
8524
8532
}
@@ -8666,7 +8674,7 @@ where
8666
8674
return Err(ChannelError::close("Peer sent an invalid channel_reestablish to force close in a non-standard way".to_owned()));
8667
8675
}
8668
8676
8669
- let our_commitment_transaction = INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point .transaction_number() - 1;
8677
+ let our_commitment_transaction = INITIAL_COMMITMENT_NUMBER - self.next_holder_commitment_point .transaction_number() - 1;
8670
8678
if msg.next_remote_commitment_number > 0 {
8671
8679
let expected_point = self.context.holder_signer.as_ref()
8672
8680
.get_per_commitment_point(INITIAL_COMMITMENT_NUMBER - msg.next_remote_commitment_number + 1, &self.context.secp_ctx)
@@ -8768,7 +8776,7 @@ where
8768
8776
let is_awaiting_remote_revoke = self.context.channel_state.is_awaiting_remote_revoke();
8769
8777
let next_counterparty_commitment_number = INITIAL_COMMITMENT_NUMBER - self.context.cur_counterparty_commitment_transaction_number + if is_awaiting_remote_revoke { 1 } else { 0 };
8770
8778
8771
- let channel_ready = if msg.next_local_commitment_number == 1 && INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point .transaction_number() == 1 {
8779
+ let channel_ready = if msg.next_local_commitment_number == 1 && INITIAL_COMMITMENT_NUMBER - self.next_holder_commitment_point .transaction_number() == 1 {
8772
8780
// We should never have to worry about MonitorUpdateInProgress resending ChannelReady
8773
8781
self.get_channel_ready(logger)
8774
8782
} else { None };
@@ -9593,7 +9601,7 @@ where
9593
9601
}
9594
9602
9595
9603
pub fn get_cur_holder_commitment_transaction_number(&self) -> u64 {
9596
- self.holder_commitment_point .transaction_number() + 1
9604
+ self.next_holder_commitment_point .transaction_number() + 1
9597
9605
}
9598
9606
9599
9607
pub fn get_cur_counterparty_commitment_transaction_number(&self) -> u64 {
@@ -9717,7 +9725,7 @@ where
9717
9725
debug_assert!(self.context.minimum_depth.unwrap_or(1) > 0);
9718
9726
return true;
9719
9727
}
9720
- if self.holder_commitment_point .transaction_number() == INITIAL_COMMITMENT_NUMBER - 1 &&
9728
+ if self.next_holder_commitment_point .transaction_number() == INITIAL_COMMITMENT_NUMBER - 1 &&
9721
9729
self.context.cur_counterparty_commitment_transaction_number == INITIAL_COMMITMENT_NUMBER - 1 {
9722
9730
// If we're a 0-conf channel, we'll move beyond AwaitingChannelReady immediately even while
9723
9731
// waiting for the initial monitor persistence. Thus, we check if our commitment
@@ -9851,11 +9859,11 @@ where
9851
9859
fn get_channel_ready<L: Deref>(
9852
9860
&mut self, logger: &L
9853
9861
) -> Option<msgs::ChannelReady> where L::Target: Logger {
9854
- if self.holder_commitment_point .can_advance() {
9862
+ if self.next_holder_commitment_point .can_advance() {
9855
9863
self.context.signer_pending_channel_ready = false;
9856
9864
Some(msgs::ChannelReady {
9857
9865
channel_id: self.context.channel_id(),
9858
- next_per_commitment_point: self.holder_commitment_point .point(),
9866
+ next_per_commitment_point: self.next_holder_commitment_point .point(),
9859
9867
short_channel_id_alias: Some(self.context.outbound_scid_alias),
9860
9868
})
9861
9869
} else {
@@ -10527,8 +10535,8 @@ where
10527
10535
assert_ne!(self.context.cur_counterparty_commitment_transaction_number, INITIAL_COMMITMENT_NUMBER);
10528
10536
// This is generally the first function which gets called on any given channel once we're
10529
10537
// up and running normally. Thus, we take this opportunity to attempt to resolve the
10530
- // `holder_commitment_point ` to get any keys which we are currently missing.
10531
- self.holder_commitment_point .try_resolve_pending(
10538
+ // `next_holder_commitment_point ` to get any keys which we are currently missing.
10539
+ self.next_holder_commitment_point .try_resolve_pending(
10532
10540
&self.context.holder_signer, &self.context.secp_ctx, logger,
10533
10541
);
10534
10542
// Prior to static_remotekey, my_current_per_commitment_point was critical to claiming
@@ -10558,7 +10566,7 @@ where
10558
10566
10559
10567
// next_local_commitment_number is the next commitment_signed number we expect to
10560
10568
// receive (indicating if they need to resend one that we missed).
10561
- next_local_commitment_number: INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point .transaction_number(),
10569
+ next_local_commitment_number: INITIAL_COMMITMENT_NUMBER - self.next_holder_commitment_point .transaction_number(),
10562
10570
// We have to set next_remote_commitment_number to the next revoke_and_ack we expect to
10563
10571
// receive, however we track it by the next commitment number for a remote transaction
10564
10572
// (which is one further, as they always revoke previous commitment transaction, not
@@ -12055,7 +12063,7 @@ where
12055
12063
pending_funding: vec![],
12056
12064
context: self.context,
12057
12065
interactive_tx_signing_session: None,
12058
- holder_commitment_point : initial_holder_commitment_point,
12066
+ next_holder_commitment_point : initial_holder_commitment_point,
12059
12067
#[cfg(splicing)]
12060
12068
pending_splice: None,
12061
12069
};
@@ -12341,7 +12349,7 @@ where
12341
12349
pending_funding: vec![],
12342
12350
context: self.context,
12343
12351
interactive_tx_signing_session: None,
12344
- holder_commitment_point : initial_holder_commitment_point,
12352
+ next_holder_commitment_point : initial_holder_commitment_point,
12345
12353
#[cfg(splicing)]
12346
12354
pending_splice: None,
12347
12355
};
@@ -12869,7 +12877,7 @@ where
12869
12877
}
12870
12878
self.context.destination_script.write(writer)?;
12871
12879
12872
- self.holder_commitment_point .transaction_number().write(writer)?;
12880
+ self.next_holder_commitment_point .transaction_number().write(writer)?;
12873
12881
self.context.cur_counterparty_commitment_transaction_number.write(writer)?;
12874
12882
self.funding.value_to_self_msat.write(writer)?;
12875
12883
@@ -13201,8 +13209,9 @@ where
13201
13209
let is_manual_broadcast = Some(self.context.is_manual_broadcast);
13202
13210
13203
13211
// `HolderCommitmentPoint::point` will become optional when async signing is implemented.
13204
- let holder_commitment_point = Some(self.holder_commitment_point.point());
13205
- let holder_commitment_point_next_advance = self.holder_commitment_point.next_point();
13212
+ let next_holder_commitment_point = Some(self.next_holder_commitment_point.point());
13213
+ let next_holder_commitment_point_next_advance =
13214
+ self.next_holder_commitment_point.next_point();
13206
13215
13207
13216
write_tlv_fields!(writer, {
13208
13217
(0, self.context.announcement_sigs, option),
@@ -13240,8 +13249,8 @@ where
13240
13249
(39, pending_outbound_blinding_points, optional_vec),
13241
13250
(41, holding_cell_blinding_points, optional_vec),
13242
13251
(43, malformed_htlcs, optional_vec), // Added in 0.0.119
13243
- (45, holder_commitment_point , option),
13244
- (47, holder_commitment_point_next_advance , option),
13252
+ (45, next_holder_commitment_point , option),
13253
+ (47, next_holder_commitment_point_next_advance , option),
13245
13254
(49, self.context.local_initiated_shutdown, option), // Added in 0.0.122
13246
13255
(51, is_manual_broadcast, option), // Added in 0.0.124
13247
13256
(53, funding_tx_broadcast_safe_event_emitted, option), // Added in 0.0.124
@@ -13298,7 +13307,7 @@ where
13298
13307
};
13299
13308
let destination_script = Readable::read(reader)?;
13300
13309
13301
- let holder_commitment_transaction_number = Readable::read(reader)?;
13310
+ let next_holder_commitment_transaction_number = Readable::read(reader)?;
13302
13311
let cur_counterparty_commitment_transaction_number = Readable::read(reader)?;
13303
13312
let value_to_self_msat = Readable::read(reader)?;
13304
13313
@@ -13601,8 +13610,8 @@ where
13601
13610
let mut malformed_htlcs: Option<Vec<(u64, u16, [u8; 32])>> = None;
13602
13611
let mut monitor_pending_update_adds: Option<Vec<msgs::UpdateAddHTLC>> = None;
13603
13612
13604
- let mut holder_commitment_point_opt : Option<PublicKey> = None;
13605
- let mut holder_commitment_point_next_advance_opt : Option<PublicKey> = None;
13613
+ let mut next_holder_commitment_point_opt : Option<PublicKey> = None;
13614
+ let mut next_holder_commitment_point_next_advance_opt : Option<PublicKey> = None;
13606
13615
let mut is_manual_broadcast = None;
13607
13616
13608
13617
let mut pending_funding = Some(Vec::new());
@@ -13642,8 +13651,8 @@ where
13642
13651
(39, pending_outbound_blinding_points_opt, optional_vec),
13643
13652
(41, holding_cell_blinding_points_opt, optional_vec),
13644
13653
(43, malformed_htlcs, optional_vec), // Added in 0.0.119
13645
- (45, holder_commitment_point_opt , option),
13646
- (47, holder_commitment_point_next_advance_opt , option),
13654
+ (45, next_holder_commitment_point_opt , option),
13655
+ (47, next_holder_commitment_point_next_advance_opt , option),
13647
13656
(49, local_initiated_shutdown, option),
13648
13657
(51, is_manual_broadcast, option),
13649
13658
(53, funding_tx_broadcast_safe_event_emitted, option),
@@ -13831,31 +13840,33 @@ where
13831
13840
// If we're restoring this channel for the first time after an upgrade, then we require that the
13832
13841
// signer be available so that we can immediately populate the current commitment point. Channel
13833
13842
// restoration will fail if this is not possible.
13834
- let holder_commitment_point =
13835
- match (holder_commitment_point_opt, holder_commitment_point_next_advance_opt) {
13836
- (Some(point), next_point) => HolderCommitmentPoint {
13837
- transaction_number: holder_commitment_transaction_number,
13838
- point,
13839
- next_point,
13840
- },
13841
- (_, _) => {
13842
- let point = holder_signer.get_per_commitment_point(holder_commitment_transaction_number, &secp_ctx)
13843
+ let next_holder_commitment_point = match (
13844
+ next_holder_commitment_point_opt,
13845
+ next_holder_commitment_point_next_advance_opt,
13846
+ ) {
13847
+ (Some(point), next_point) => HolderCommitmentPoint {
13848
+ transaction_number: next_holder_commitment_transaction_number,
13849
+ point,
13850
+ next_point,
13851
+ },
13852
+ (_, _) => {
13853
+ let point = holder_signer.get_per_commitment_point(next_holder_commitment_transaction_number, &secp_ctx)
13843
13854
.expect("Must be able to derive the current commitment point upon channel restoration");
13844
- let next_point = holder_signer
13845
- .get_per_commitment_point(
13846
- holder_commitment_transaction_number - 1,
13847
- &secp_ctx,
13848
- )
13849
- .expect(
13850
- "Must be able to derive the next commitment point upon channel restoration",
13851
- );
13852
- HolderCommitmentPoint {
13853
- transaction_number: holder_commitment_transaction_number ,
13854
- point,
13855
- next_point: Some(next_point),
13856
- }
13857
- },
13858
- };
13855
+ let next_point = holder_signer
13856
+ .get_per_commitment_point(
13857
+ next_holder_commitment_transaction_number - 1,
13858
+ &secp_ctx,
13859
+ )
13860
+ .expect(
13861
+ "Must be able to derive the next commitment point upon channel restoration",
13862
+ );
13863
+ HolderCommitmentPoint {
13864
+ transaction_number: next_holder_commitment_transaction_number ,
13865
+ point,
13866
+ next_point: Some(next_point),
13867
+ }
13868
+ },
13869
+ };
13859
13870
13860
13871
Ok(FundedChannel {
13861
13872
funding: FundingScope {
@@ -13994,7 +14005,7 @@ where
13994
14005
is_holder_quiescence_initiator: None,
13995
14006
},
13996
14007
interactive_tx_signing_session,
13997
- holder_commitment_point ,
14008
+ next_holder_commitment_point ,
13998
14009
#[cfg(splicing)]
13999
14010
pending_splice: None,
14000
14011
})
0 commit comments