Skip to content

Commit 6f2ffc4

Browse files
committed
Rename payment_point to payment_basepoint
.. to align the field naming with the spec for clarity.
1 parent f9f7ba7 commit 6f2ffc4

File tree

4 files changed

+35
-33
lines changed

4 files changed

+35
-33
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
13471347

13481348
assert!(commitment_transaction_number_obscure_factor <= (1 << 48));
13491349
let counterparty_payment_script = chan_utils::get_counterparty_payment_script(
1350-
&channel_parameters.channel_type_features, &keys.pubkeys().payment_point
1350+
&channel_parameters.channel_type_features, &keys.pubkeys().payment_basepoint
13511351
);
13521352

13531353
let counterparty_channel_parameters = channel_parameters.counterparty_parameters.as_ref().unwrap();
@@ -4977,9 +4977,9 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
49774977
if onchain_tx_handler.channel_type_features().supports_anchors_zero_fee_htlc_tx() &&
49784978
counterparty_payment_script.is_p2wpkh()
49794979
{
4980-
let payment_point = onchain_tx_handler.channel_transaction_parameters.holder_pubkeys.payment_point;
4980+
let payment_basepoint = onchain_tx_handler.channel_transaction_parameters.holder_pubkeys.payment_basepoint;
49814981
counterparty_payment_script =
4982-
chan_utils::get_to_countersignatory_with_anchors_redeemscript(&payment_point).to_p2wsh();
4982+
chan_utils::get_to_countersignatory_with_anchors_redeemscript(&payment_basepoint).to_p2wsh();
49834983
}
49844984

49854985
Ok((best_block.block_hash, ChannelMonitor::from_impl(ChannelMonitorImpl {
@@ -5249,7 +5249,7 @@ mod tests {
52495249
let counterparty_pubkeys = ChannelPublicKeys {
52505250
funding_pubkey: PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[44; 32]).unwrap()),
52515251
revocation_basepoint: RevocationBasepoint::from(PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[45; 32]).unwrap())),
5252-
payment_point: PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[46; 32]).unwrap()),
5252+
payment_basepoint: PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[46; 32]).unwrap()),
52535253
delayed_payment_basepoint: DelayedPaymentBasepoint::from(PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[47; 32]).unwrap())),
52545254
htlc_basepoint: HtlcBasepoint::from(PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[48; 32]).unwrap()))
52555255
};
@@ -5501,7 +5501,7 @@ mod tests {
55015501
let counterparty_pubkeys = ChannelPublicKeys {
55025502
funding_pubkey: PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[44; 32]).unwrap()),
55035503
revocation_basepoint: RevocationBasepoint::from(PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[45; 32]).unwrap())),
5504-
payment_point: PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[46; 32]).unwrap()),
5504+
payment_basepoint: PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[46; 32]).unwrap()),
55055505
delayed_payment_basepoint: DelayedPaymentBasepoint::from(PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[47; 32]).unwrap())),
55065506
htlc_basepoint: HtlcBasepoint::from(PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[48; 32]).unwrap())),
55075507
};

lightning/src/ln/chan_utils.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ pub struct ChannelPublicKeys {
478478
/// The public key on which the non-broadcaster (ie the countersignatory) receives an immediately
479479
/// spendable primary channel balance on the broadcaster's commitment transaction. This key is
480480
/// static across every commitment transaction.
481-
pub payment_point: PublicKey,
481+
pub payment_basepoint: PublicKey,
482482
/// The base point which is used (with derive_public_key) to derive a per-commitment payment
483483
/// public key which receives non-HTLC-encumbered funds which are only available for spending
484484
/// after some delay (or can be claimed via the revocation path).
@@ -491,7 +491,7 @@ pub struct ChannelPublicKeys {
491491
impl_writeable_tlv_based!(ChannelPublicKeys, {
492492
(0, funding_pubkey, required),
493493
(2, revocation_basepoint, required),
494-
(4, payment_point, required),
494+
(4, payment_basepoint, required),
495495
(6, delayed_payment_basepoint, required),
496496
(8, htlc_basepoint, required),
497497
});
@@ -816,9 +816,9 @@ pub(crate) fn legacy_deserialization_prevention_marker_for_channel_type_features
816816

817817
/// Gets the witnessScript for the to_remote output when anchors are enabled.
818818
#[inline]
819-
pub fn get_to_countersignatory_with_anchors_redeemscript(payment_point: &PublicKey) -> ScriptBuf {
819+
pub fn get_to_countersignatory_with_anchors_redeemscript(payment_basepoint: &PublicKey) -> ScriptBuf {
820820
Builder::new()
821-
.push_slice(payment_point.serialize())
821+
.push_slice(payment_basepoint.serialize())
822822
.push_opcode(opcodes::all::OP_CHECKSIGVERIFY)
823823
.push_int(1)
824824
.push_opcode(opcodes::all::OP_CSV)
@@ -933,7 +933,7 @@ impl ChannelTransactionParameters {
933933
let dummy_keys = ChannelPublicKeys {
934934
funding_pubkey: PublicKey::from_slice(&[2; 33]).unwrap(),
935935
revocation_basepoint: PublicKey::from_slice(&[2; 33]).unwrap().into(),
936-
payment_point: PublicKey::from_slice(&[2; 33]).unwrap(),
936+
payment_basepoint: PublicKey::from_slice(&[2; 33]).unwrap(),
937937
delayed_payment_basepoint: PublicKey::from_slice(&[2; 33]).unwrap().into(),
938938
htlc_basepoint: PublicKey::from_slice(&[2; 33]).unwrap().into(),
939939
};
@@ -1119,7 +1119,7 @@ impl HolderCommitmentTransaction {
11191119
let channel_pubkeys = ChannelPublicKeys {
11201120
funding_pubkey: dummy_key.clone(),
11211121
revocation_basepoint: RevocationBasepoint::from(dummy_key),
1122-
payment_point: dummy_key.clone(),
1122+
payment_basepoint: dummy_key.clone(),
11231123
delayed_payment_basepoint: DelayedPaymentBasepoint::from(dummy_key.clone()),
11241124
htlc_basepoint: HtlcBasepoint::from(dummy_key.clone())
11251125
};
@@ -1515,9 +1515,9 @@ impl CommitmentTransaction {
15151515

15161516
if to_countersignatory_value_sat > Amount::ZERO {
15171517
let script = if channel_parameters.channel_type_features().supports_anchors_zero_fee_htlc_tx() {
1518-
get_to_countersignatory_with_anchors_redeemscript(&countersignatory_pubkeys.payment_point).to_p2wsh()
1518+
get_to_countersignatory_with_anchors_redeemscript(&countersignatory_pubkeys.payment_basepoint).to_p2wsh()
15191519
} else {
1520-
ScriptBuf::new_p2wpkh(&Hash160::hash(&countersignatory_pubkeys.payment_point.serialize()).into())
1520+
ScriptBuf::new_p2wpkh(&Hash160::hash(&countersignatory_pubkeys.payment_basepoint.serialize()).into())
15211521
};
15221522
txouts.push((
15231523
TxOut {
@@ -1608,8 +1608,8 @@ impl CommitmentTransaction {
16081608
let broadcaster_pubkeys = channel_parameters.broadcaster_pubkeys();
16091609
let countersignatory_pubkeys = channel_parameters.countersignatory_pubkeys();
16101610
let commitment_transaction_number_obscure_factor = get_commitment_transaction_number_obscure_factor(
1611-
&broadcaster_pubkeys.payment_point,
1612-
&countersignatory_pubkeys.payment_point,
1611+
&broadcaster_pubkeys.payment_basepoint,
1612+
&countersignatory_pubkeys.payment_basepoint,
16131613
channel_parameters.is_outbound(),
16141614
);
16151615

@@ -1974,13 +1974,13 @@ mod tests {
19741974
// Generate broadcaster and counterparty outputs
19751975
let tx = builder.build(1000, 2000);
19761976
assert_eq!(tx.built.transaction.output.len(), 2);
1977-
assert_eq!(tx.built.transaction.output[1].script_pubkey, bitcoin::address::Address::p2wpkh(&CompressedPublicKey(builder.counterparty_pubkeys.payment_point), Network::Testnet).script_pubkey());
1977+
assert_eq!(tx.built.transaction.output[1].script_pubkey, bitcoin::address::Address::p2wpkh(&CompressedPublicKey(builder.counterparty_pubkeys.payment_basepoint), Network::Testnet).script_pubkey());
19781978

19791979
// Generate broadcaster and counterparty outputs as well as two anchors
19801980
builder.channel_parameters.channel_type_features = ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies();
19811981
let tx = builder.build(1000, 2000);
19821982
assert_eq!(tx.built.transaction.output.len(), 4);
1983-
assert_eq!(tx.built.transaction.output[3].script_pubkey, get_to_countersignatory_with_anchors_redeemscript(&builder.counterparty_pubkeys.payment_point).to_p2wsh());
1983+
assert_eq!(tx.built.transaction.output[3].script_pubkey, get_to_countersignatory_with_anchors_redeemscript(&builder.counterparty_pubkeys.payment_basepoint).to_p2wsh());
19841984

19851985
// Generate broadcaster output and anchor
19861986
let tx = builder.build(3000, 0);

lightning/src/ln/channel.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,7 @@ trait InitialRemoteCommitmentReceiver<SP: Deref> where SP::Target: SignerProvide
15881588
let funding_redeemscript = context.get_funding_redeemscript();
15891589
let funding_txo = context.get_funding_txo().unwrap();
15901590
let funding_txo_script = funding_redeemscript.to_p2wsh();
1591-
let obscure_factor = get_commitment_transaction_number_obscure_factor(&context.get_holder_pubkeys().payment_point, &context.get_counterparty_pubkeys().payment_point, context.is_outbound());
1591+
let obscure_factor = get_commitment_transaction_number_obscure_factor(&context.get_holder_pubkeys().payment_basepoint, &context.get_counterparty_pubkeys().payment_basepoint, context.is_outbound());
15921592
let shutdown_script = context.shutdown_scriptpubkey.clone().map(|script| script.into_inner());
15931593
let mut monitor_signer = signer_provider.derive_channel_signer(context.channel_value_satoshis, context.channel_keys_id);
15941594
monitor_signer.provide_channel_parameters(&context.channel_transaction_parameters);
@@ -2483,7 +2483,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
24832483
let counterparty_pubkeys = ChannelPublicKeys {
24842484
funding_pubkey: common_fields.funding_pubkey,
24852485
revocation_basepoint: RevocationBasepoint::from(common_fields.revocation_basepoint),
2486-
payment_point: common_fields.payment_basepoint,
2486+
payment_basepoint: common_fields.payment_basepoint,
24872487
delayed_payment_basepoint: DelayedPaymentBasepoint::from(common_fields.delayed_payment_basepoint),
24882488
htlc_basepoint: HtlcBasepoint::from(common_fields.htlc_basepoint)
24892489
};
@@ -2749,7 +2749,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
27492749

27502750
log_trace!(logger, "Building commitment transaction number {} (really {} xor {}) for channel {} for {}, generated by {} with fee {}...",
27512751
commitment_number, (INITIAL_COMMITMENT_NUMBER - commitment_number),
2752-
get_commitment_transaction_number_obscure_factor(&self.get_holder_pubkeys().payment_point, &self.get_counterparty_pubkeys().payment_point, self.is_outbound()),
2752+
get_commitment_transaction_number_obscure_factor(&self.get_holder_pubkeys().payment_basepoint, &self.get_counterparty_pubkeys().payment_basepoint, self.is_outbound()),
27532753
&self.channel_id,
27542754
if local { "us" } else { "remote" }, if generated_by_local { "us" } else { "remote" }, feerate_per_kw);
27552755

@@ -7975,7 +7975,7 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
79757975
max_accepted_htlcs: self.context.holder_max_accepted_htlcs,
79767976
funding_pubkey: keys.funding_pubkey,
79777977
revocation_basepoint: keys.revocation_basepoint.to_public_key(),
7978-
payment_basepoint: keys.payment_point,
7978+
payment_basepoint: keys.payment_basepoint,
79797979
delayed_payment_basepoint: keys.delayed_payment_basepoint.to_public_key(),
79807980
htlc_basepoint: keys.htlc_basepoint.to_public_key(),
79817981
first_per_commitment_point,
@@ -8116,7 +8116,7 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
81168116
let counterparty_pubkeys = ChannelPublicKeys {
81178117
funding_pubkey: msg.common_fields.funding_pubkey,
81188118
revocation_basepoint: RevocationBasepoint::from(msg.common_fields.revocation_basepoint),
8119-
payment_point: msg.common_fields.payment_basepoint,
8119+
payment_basepoint: msg.common_fields.payment_basepoint,
81208120
delayed_payment_basepoint: DelayedPaymentBasepoint::from(msg.common_fields.delayed_payment_basepoint),
81218121
htlc_basepoint: HtlcBasepoint::from(msg.common_fields.htlc_basepoint)
81228122
};
@@ -8189,7 +8189,7 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
81898189
max_accepted_htlcs: self.context.holder_max_accepted_htlcs,
81908190
funding_pubkey: keys.funding_pubkey,
81918191
revocation_basepoint: keys.revocation_basepoint.to_public_key(),
8192-
payment_basepoint: keys.payment_point,
8192+
payment_basepoint: keys.payment_basepoint,
81938193
delayed_payment_basepoint: keys.delayed_payment_basepoint.to_public_key(),
81948194
htlc_basepoint: keys.htlc_basepoint.to_public_key(),
81958195
first_per_commitment_point,
@@ -8381,7 +8381,7 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
83818381
max_accepted_htlcs: self.context.holder_max_accepted_htlcs,
83828382
funding_pubkey: keys.funding_pubkey,
83838383
revocation_basepoint: keys.revocation_basepoint.to_public_key(),
8384-
payment_basepoint: keys.payment_point,
8384+
payment_basepoint: keys.payment_basepoint,
83858385
delayed_payment_basepoint: keys.delayed_payment_basepoint.to_public_key(),
83868386
htlc_basepoint: keys.htlc_basepoint.to_public_key(),
83878387
first_per_commitment_point,
@@ -8439,7 +8439,7 @@ impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
84398439
let counterparty_pubkeys = ChannelPublicKeys {
84408440
funding_pubkey: msg.common_fields.funding_pubkey,
84418441
revocation_basepoint: RevocationBasepoint(msg.common_fields.revocation_basepoint),
8442-
payment_point: msg.common_fields.payment_basepoint,
8442+
payment_basepoint: msg.common_fields.payment_basepoint,
84438443
delayed_payment_basepoint: DelayedPaymentBasepoint(msg.common_fields.delayed_payment_basepoint),
84448444
htlc_basepoint: HtlcBasepoint(msg.common_fields.htlc_basepoint)
84458445
};
@@ -8530,7 +8530,7 @@ impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
85308530
max_accepted_htlcs: self.context.holder_max_accepted_htlcs,
85318531
funding_pubkey: keys.funding_pubkey,
85328532
revocation_basepoint: keys.revocation_basepoint.to_public_key(),
8533-
payment_basepoint: keys.payment_point,
8533+
payment_basepoint: keys.payment_basepoint,
85348534
delayed_payment_basepoint: keys.delayed_payment_basepoint.to_public_key(),
85358535
htlc_basepoint: keys.htlc_basepoint.to_public_key(),
85368536
first_per_commitment_point,
@@ -10367,7 +10367,7 @@ mod tests {
1036710367
let counterparty_pubkeys = ChannelPublicKeys {
1036810368
funding_pubkey: public_from_secret_hex(&secp_ctx, "1552dfba4f6cf29a62a0af13c8d6981d36d0ef8d61ba10fb0fe90da7634d7e13"),
1036910369
revocation_basepoint: RevocationBasepoint::from(PublicKey::from_slice(&<Vec<u8>>::from_hex("02466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f27").unwrap()[..]).unwrap()),
10370-
payment_point: public_from_secret_hex(&secp_ctx, "4444444444444444444444444444444444444444444444444444444444444444"),
10370+
payment_basepoint: public_from_secret_hex(&secp_ctx, "4444444444444444444444444444444444444444444444444444444444444444"),
1037110371
delayed_payment_basepoint: DelayedPaymentBasepoint::from(public_from_secret_hex(&secp_ctx, "1552dfba4f6cf29a62a0af13c8d6981d36d0ef8d61ba10fb0fe90da7634d7e13")),
1037210372
htlc_basepoint: HtlcBasepoint::from(public_from_secret_hex(&secp_ctx, "4444444444444444444444444444444444444444444444444444444444444444"))
1037310373
};
@@ -10379,7 +10379,7 @@ mod tests {
1037910379
chan.context.channel_transaction_parameters.funding_outpoint = Some(funding_info);
1038010380
signer.provide_channel_parameters(&chan.context.channel_transaction_parameters);
1038110381

10382-
assert_eq!(counterparty_pubkeys.payment_point.serialize()[..],
10382+
assert_eq!(counterparty_pubkeys.payment_basepoint.serialize()[..],
1038310383
<Vec<u8>>::from_hex("032c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991").unwrap()[..]);
1038410384

1038510385
assert_eq!(counterparty_pubkeys.funding_pubkey.serialize()[..],

lightning/src/sign/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,10 @@ impl StaticPaymentOutputDescriptor {
178178
pub fn witness_script(&self) -> Option<ScriptBuf> {
179179
self.channel_transaction_parameters.as_ref().and_then(|channel_params| {
180180
if channel_params.supports_anchors() {
181-
let payment_point = channel_params.holder_pubkeys.payment_point;
182-
Some(chan_utils::get_to_countersignatory_with_anchors_redeemscript(&payment_point))
181+
let payment_basepoint = channel_params.holder_pubkeys.payment_basepoint;
182+
Some(chan_utils::get_to_countersignatory_with_anchors_redeemscript(
183+
&payment_basepoint,
184+
))
183185
} else {
184186
None
185187
}
@@ -282,7 +284,7 @@ pub enum SpendableOutputDescriptor {
282284
/// [`chan_utils::get_revokeable_redeemscript`].
283285
DelayedPaymentOutput(DelayedPaymentOutputDescriptor),
284286
/// An output spendable exclusively by our payment key (i.e., the private key that corresponds
285-
/// to the `payment_point` in [`ChannelSigner::pubkeys`]). The output type depends on the
287+
/// to the `payment_basepoint` in [`ChannelSigner::pubkeys`]). The output type depends on the
286288
/// channel type negotiated.
287289
///
288290
/// On an anchor outputs channel, the witness in the spending input is:
@@ -1125,7 +1127,7 @@ impl InMemorySigner {
11251127
ChannelPublicKeys {
11261128
funding_pubkey: from_secret(&funding_key),
11271129
revocation_basepoint: RevocationBasepoint::from(from_secret(&revocation_base_key)),
1128-
payment_point: from_secret(&payment_key),
1130+
payment_basepoint: from_secret(&payment_key),
11291131
delayed_payment_basepoint: DelayedPaymentBasepoint::from(from_secret(
11301132
&delayed_payment_base_key,
11311133
)),
@@ -1226,7 +1228,7 @@ impl InMemorySigner {
12261228
return Err(());
12271229
}
12281230

1229-
let remotepubkey = bitcoin::PublicKey::new(self.pubkeys().payment_point);
1231+
let remotepubkey = bitcoin::PublicKey::new(self.pubkeys().payment_basepoint);
12301232
// We cannot always assume that `channel_parameters` is set, so can't just call
12311233
// `self.channel_parameters()` or anything that relies on it
12321234
let supports_anchors_zero_fee_htlc_tx = self

0 commit comments

Comments
 (0)