Skip to content

Commit 40a55f4

Browse files
committed
Rename UnfundedChannelContext::holder_commitment_point
The previous commitment point will be tracked in an upcoming commit. Rename existing HolderCommitmentPoint fields to avoid ambiguity.
1 parent 183c0be commit 40a55f4

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

lightning/src/ln/channel.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,7 +1836,7 @@ where
18361836
let phase = core::mem::replace(&mut self.phase, ChannelPhase::Undefined);
18371837
match phase {
18381838
ChannelPhase::UnfundedV2(chan) => {
1839-
let holder_commitment_point = match chan.unfunded_context.holder_commitment_point {
1839+
let initial_holder_commitment_point = match chan.unfunded_context.initial_holder_commitment_point {
18401840
Some(point) => point,
18411841
None => {
18421842
let channel_id = chan.context.channel_id();
@@ -1851,7 +1851,7 @@ where
18511851
pending_funding: vec![],
18521852
context: chan.context,
18531853
interactive_tx_signing_session: chan.interactive_tx_signing_session,
1854-
holder_commitment_point,
1854+
holder_commitment_point: initial_holder_commitment_point,
18551855
#[cfg(splicing)]
18561856
pending_splice: None,
18571857
};
@@ -1988,7 +1988,7 @@ pub(super) struct UnfundedChannelContext {
19881988
/// in a timely manner.
19891989
unfunded_channel_age_ticks: usize,
19901990
/// Tracks the commitment number and commitment point before the channel is funded.
1991-
holder_commitment_point: Option<HolderCommitmentPoint>,
1991+
initial_holder_commitment_point: Option<HolderCommitmentPoint>,
19921992
}
19931993

19941994
impl UnfundedChannelContext {
@@ -2002,7 +2002,7 @@ impl UnfundedChannelContext {
20022002
}
20032003

20042004
fn transaction_number(&self) -> u64 {
2005-
self.holder_commitment_point
2005+
self.initial_holder_commitment_point
20062006
.as_ref()
20072007
.map(|point| point.transaction_number())
20082008
.unwrap_or(INITIAL_COMMITMENT_NUMBER)
@@ -11832,7 +11832,7 @@ where
1183211832
)?;
1183311833
let unfunded_context = UnfundedChannelContext {
1183411834
unfunded_channel_age_ticks: 0,
11835-
holder_commitment_point: HolderCommitmentPoint::new(&context.holder_signer, &context.secp_ctx),
11835+
initial_holder_commitment_point: HolderCommitmentPoint::new(&context.holder_signer, &context.secp_ctx),
1183611836
};
1183711837

1183811838
// We initialize `signer_pending_open_channel` to false, and leave setting the flag
@@ -11963,7 +11963,7 @@ where
1196311963
panic!("Tried to send an open_channel for a channel that has already advanced");
1196411964
}
1196511965

11966-
let first_per_commitment_point = match self.unfunded_context.holder_commitment_point {
11966+
let first_per_commitment_point = match self.unfunded_context.initial_holder_commitment_point {
1196711967
Some(holder_commitment_point) if holder_commitment_point.can_advance() => {
1196811968
self.signer_pending_open_channel = false;
1196911969
holder_commitment_point.point()
@@ -12034,15 +12034,15 @@ where
1203412034
if !matches!(self.context.channel_state, ChannelState::FundingNegotiated(_)) {
1203512035
return Err((self, ChannelError::close("Received funding_signed in strange state!".to_owned())));
1203612036
}
12037-
let mut holder_commitment_point = match self.unfunded_context.holder_commitment_point {
12037+
let mut initial_holder_commitment_point = match self.unfunded_context.initial_holder_commitment_point {
1203812038
Some(point) => point,
1203912039
None => return Err((self, ChannelError::close("Received funding_signed before our first commitment point was available".to_owned()))),
1204012040
};
12041-
self.context.assert_no_commitment_advancement(holder_commitment_point.transaction_number(), "funding_signed");
12041+
self.context.assert_no_commitment_advancement(initial_holder_commitment_point.transaction_number(), "funding_signed");
1204212042

1204312043
let (channel_monitor, _) = match self.initial_commitment_signed(
1204412044
self.context.channel_id(), msg.signature,
12045-
&mut holder_commitment_point, best_block, signer_provider, logger
12045+
&mut initial_holder_commitment_point, best_block, signer_provider, logger
1204612046
) {
1204712047
Ok(channel_monitor) => channel_monitor,
1204812048
Err(err) => return Err((self, err)),
@@ -12055,7 +12055,7 @@ where
1205512055
pending_funding: vec![],
1205612056
context: self.context,
1205712057
interactive_tx_signing_session: None,
12058-
holder_commitment_point,
12058+
holder_commitment_point: initial_holder_commitment_point,
1205912059
#[cfg(splicing)]
1206012060
pending_splice: None,
1206112061
};
@@ -12074,10 +12074,10 @@ where
1207412074
) -> (Option<msgs::OpenChannel>, Option<msgs::FundingCreated>) where L::Target: Logger {
1207512075
// If we were pending a commitment point, retry the signer and advance to an
1207612076
// available state.
12077-
if self.unfunded_context.holder_commitment_point.is_none() {
12078-
self.unfunded_context.holder_commitment_point = HolderCommitmentPoint::new(&self.context.holder_signer, &self.context.secp_ctx);
12077+
if self.unfunded_context.initial_holder_commitment_point.is_none() {
12078+
self.unfunded_context.initial_holder_commitment_point = HolderCommitmentPoint::new(&self.context.holder_signer, &self.context.secp_ctx);
1207912079
}
12080-
if let Some(ref mut point) = self.unfunded_context.holder_commitment_point {
12080+
if let Some(ref mut point) = self.unfunded_context.initial_holder_commitment_point {
1208112081
if !point.can_advance() {
1208212082
point.try_resolve_pending(&self.context.holder_signer, &self.context.secp_ctx, logger);
1208312083
}
@@ -12198,7 +12198,7 @@ where
1219812198
)?;
1219912199
let unfunded_context = UnfundedChannelContext {
1220012200
unfunded_channel_age_ticks: 0,
12201-
holder_commitment_point: HolderCommitmentPoint::new(&context.holder_signer, &context.secp_ctx),
12201+
initial_holder_commitment_point: HolderCommitmentPoint::new(&context.holder_signer, &context.secp_ctx),
1220212202
};
1220312203
let chan = Self { funding, context, unfunded_context, signer_pending_accept_channel: false };
1220412204
Ok(chan)
@@ -12237,7 +12237,7 @@ where
1223712237
fn generate_accept_channel_message<L: Deref>(
1223812238
&mut self, _logger: &L
1223912239
) -> Option<msgs::AcceptChannel> where L::Target: Logger {
12240-
let first_per_commitment_point = match self.unfunded_context.holder_commitment_point {
12240+
let first_per_commitment_point = match self.unfunded_context.initial_holder_commitment_point {
1224112241
Some(holder_commitment_point) if holder_commitment_point.can_advance() => {
1224212242
self.signer_pending_accept_channel = false;
1224312243
holder_commitment_point.point()
@@ -12310,18 +12310,18 @@ where
1231012310
// channel.
1231112311
return Err((self, ChannelError::close("Received funding_created after we got the channel!".to_owned())));
1231212312
}
12313-
let mut holder_commitment_point = match self.unfunded_context.holder_commitment_point {
12313+
let mut initial_holder_commitment_point = match self.unfunded_context.initial_holder_commitment_point {
1231412314
Some(point) => point,
1231512315
None => return Err((self, ChannelError::close("Received funding_created before our first commitment point was available".to_owned()))),
1231612316
};
12317-
self.context.assert_no_commitment_advancement(holder_commitment_point.transaction_number(), "funding_created");
12317+
self.context.assert_no_commitment_advancement(initial_holder_commitment_point.transaction_number(), "funding_created");
1231812318

1231912319
let funding_txo = OutPoint { txid: msg.funding_txid, index: msg.funding_output_index };
1232012320
self.funding.channel_transaction_parameters.funding_outpoint = Some(funding_txo);
1232112321

1232212322
let (channel_monitor, counterparty_initial_commitment_tx) = match self.initial_commitment_signed(
1232312323
ChannelId::v1_from_funding_outpoint(funding_txo), msg.signature,
12324-
&mut holder_commitment_point, best_block, signer_provider, logger
12324+
&mut initial_holder_commitment_point, best_block, signer_provider, logger
1232512325
) {
1232612326
Ok(channel_monitor) => channel_monitor,
1232712327
Err(err) => return Err((self, err)),
@@ -12341,7 +12341,7 @@ where
1234112341
pending_funding: vec![],
1234212342
context: self.context,
1234312343
interactive_tx_signing_session: None,
12344-
holder_commitment_point,
12344+
holder_commitment_point: initial_holder_commitment_point,
1234512345
#[cfg(splicing)]
1234612346
pending_splice: None,
1234712347
};
@@ -12358,10 +12358,10 @@ where
1235812358
pub fn signer_maybe_unblocked<L: Deref>(
1235912359
&mut self, logger: &L
1236012360
) -> Option<msgs::AcceptChannel> where L::Target: Logger {
12361-
if self.unfunded_context.holder_commitment_point.is_none() {
12362-
self.unfunded_context.holder_commitment_point = HolderCommitmentPoint::new(&self.context.holder_signer, &self.context.secp_ctx);
12361+
if self.unfunded_context.initial_holder_commitment_point.is_none() {
12362+
self.unfunded_context.initial_holder_commitment_point = HolderCommitmentPoint::new(&self.context.holder_signer, &self.context.secp_ctx);
1236312363
}
12364-
if let Some(ref mut point) = self.unfunded_context.holder_commitment_point {
12364+
if let Some(ref mut point) = self.unfunded_context.initial_holder_commitment_point {
1236512365
if !point.can_advance() {
1236612366
point.try_resolve_pending(&self.context.holder_signer, &self.context.secp_ctx, logger);
1236712367
}
@@ -12442,7 +12442,7 @@ where
1244212442
)?;
1244312443
let unfunded_context = UnfundedChannelContext {
1244412444
unfunded_channel_age_ticks: 0,
12445-
holder_commitment_point: HolderCommitmentPoint::new(&context.holder_signer, &context.secp_ctx),
12445+
initial_holder_commitment_point: HolderCommitmentPoint::new(&context.holder_signer, &context.secp_ctx),
1244612446
};
1244712447
let funding_negotiation_context = FundingNegotiationContext {
1244812448
is_initiator: true,
@@ -12637,7 +12637,7 @@ where
1263712637

1263812638
let unfunded_context = UnfundedChannelContext {
1263912639
unfunded_channel_age_ticks: 0,
12640-
holder_commitment_point: HolderCommitmentPoint::new(&context.holder_signer, &context.secp_ctx),
12640+
initial_holder_commitment_point: HolderCommitmentPoint::new(&context.holder_signer, &context.secp_ctx),
1264112641
};
1264212642
Ok(Self {
1264312643
funding,

0 commit comments

Comments
 (0)