Skip to content

Commit b007a68

Browse files
committed
Rename payment_basepoint/key to simply payment_point/key.
We no longer derive any keys from the payment point, so they aren't a "base" but simply a point/key.
1 parent daf2aa6 commit b007a68

7 files changed

+46
-45
lines changed

lightning/src/chain/keysinterface.rs

+19-18
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,10 @@ pub trait ChannelKeys : Send+Clone {
196196
fn funding_key<'a>(&'a self) -> &'a SecretKey;
197197
/// Gets the local secret key for blinded revocation pubkey
198198
fn revocation_base_key<'a>(&'a self) -> &'a SecretKey;
199-
/// Gets the local secret key used in to_remote output of remote commitment tx
200-
/// (and also as part of obscured commitment number)
201-
fn payment_base_key<'a>(&'a self) -> &'a SecretKey;
199+
/// Gets the local secret key used in the to_remote output of remote commitment tx (ie the
200+
/// output to us in transactions our counterparty broadcasts).
201+
/// Also as part of obscured commitment number.
202+
fn payment_key<'a>(&'a self) -> &'a SecretKey;
202203
/// Gets the local secret key used in HTLC-Success/HTLC-Timeout txn and to_local output
203204
fn delayed_payment_base_key<'a>(&'a self) -> &'a SecretKey;
204205
/// Gets the local htlc secret key used in commitment tx htlc outputs
@@ -275,8 +276,8 @@ pub struct InMemoryChannelKeys {
275276
funding_key: SecretKey,
276277
/// Local secret key for blinded revocation pubkey
277278
revocation_base_key: SecretKey,
278-
/// Local secret key used in commitment tx htlc outputs
279-
payment_base_key: SecretKey,
279+
/// Local secret key used in commitment txn generated by us (for broadcast by our counterparty)
280+
payment_key: SecretKey,
280281
/// Local secret key used in HTLC tx
281282
delayed_payment_base_key: SecretKey,
282283
/// Local htlc secret key used in commitment tx htlc outputs
@@ -297,19 +298,19 @@ impl InMemoryChannelKeys {
297298
secp_ctx: &Secp256k1<C>,
298299
funding_key: SecretKey,
299300
revocation_base_key: SecretKey,
300-
payment_base_key: SecretKey,
301+
payment_key: SecretKey,
301302
delayed_payment_base_key: SecretKey,
302303
htlc_base_key: SecretKey,
303304
commitment_seed: [u8; 32],
304305
channel_value_satoshis: u64) -> InMemoryChannelKeys {
305306
let local_channel_pubkeys =
306307
InMemoryChannelKeys::make_local_keys(secp_ctx, &funding_key, &revocation_base_key,
307-
&payment_base_key, &delayed_payment_base_key,
308+
&payment_key, &delayed_payment_base_key,
308309
&htlc_base_key);
309310
InMemoryChannelKeys {
310311
funding_key,
311312
revocation_base_key,
312-
payment_base_key,
313+
payment_key,
313314
delayed_payment_base_key,
314315
htlc_base_key,
315316
commitment_seed,
@@ -322,14 +323,14 @@ impl InMemoryChannelKeys {
322323
fn make_local_keys<C: Signing>(secp_ctx: &Secp256k1<C>,
323324
funding_key: &SecretKey,
324325
revocation_base_key: &SecretKey,
325-
payment_base_key: &SecretKey,
326+
payment_key: &SecretKey,
326327
delayed_payment_base_key: &SecretKey,
327328
htlc_base_key: &SecretKey) -> ChannelPublicKeys {
328329
let from_secret = |s: &SecretKey| PublicKey::from_secret_key(secp_ctx, s);
329330
ChannelPublicKeys {
330331
funding_pubkey: from_secret(&funding_key),
331332
revocation_basepoint: from_secret(&revocation_base_key),
332-
payment_basepoint: from_secret(&payment_base_key),
333+
payment_point: from_secret(&payment_key),
333334
delayed_payment_basepoint: from_secret(&delayed_payment_base_key),
334335
htlc_basepoint: from_secret(&htlc_base_key),
335336
}
@@ -339,7 +340,7 @@ impl InMemoryChannelKeys {
339340
impl ChannelKeys for InMemoryChannelKeys {
340341
fn funding_key(&self) -> &SecretKey { &self.funding_key }
341342
fn revocation_base_key(&self) -> &SecretKey { &self.revocation_base_key }
342-
fn payment_base_key(&self) -> &SecretKey { &self.payment_base_key }
343+
fn payment_key(&self) -> &SecretKey { &self.payment_key }
343344
fn delayed_payment_base_key(&self) -> &SecretKey { &self.delayed_payment_base_key }
344345
fn htlc_base_key(&self) -> &SecretKey { &self.htlc_base_key }
345346
fn commitment_seed(&self) -> &[u8; 32] { &self.commitment_seed }
@@ -424,7 +425,7 @@ impl Writeable for InMemoryChannelKeys {
424425
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), Error> {
425426
self.funding_key.write(writer)?;
426427
self.revocation_base_key.write(writer)?;
427-
self.payment_base_key.write(writer)?;
428+
self.payment_key.write(writer)?;
428429
self.delayed_payment_base_key.write(writer)?;
429430
self.htlc_base_key.write(writer)?;
430431
self.commitment_seed.write(writer)?;
@@ -439,7 +440,7 @@ impl Readable for InMemoryChannelKeys {
439440
fn read<R: ::std::io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
440441
let funding_key = Readable::read(reader)?;
441442
let revocation_base_key = Readable::read(reader)?;
442-
let payment_base_key = Readable::read(reader)?;
443+
let payment_key = Readable::read(reader)?;
443444
let delayed_payment_base_key = Readable::read(reader)?;
444445
let htlc_base_key = Readable::read(reader)?;
445446
let commitment_seed = Readable::read(reader)?;
@@ -448,13 +449,13 @@ impl Readable for InMemoryChannelKeys {
448449
let secp_ctx = Secp256k1::signing_only();
449450
let local_channel_pubkeys =
450451
InMemoryChannelKeys::make_local_keys(&secp_ctx, &funding_key, &revocation_base_key,
451-
&payment_base_key, &delayed_payment_base_key,
452+
&payment_key, &delayed_payment_base_key,
452453
&htlc_base_key);
453454

454455
Ok(InMemoryChannelKeys {
455456
funding_key,
456457
revocation_base_key,
457-
payment_base_key,
458+
payment_key,
458459
delayed_payment_base_key,
459460
htlc_base_key,
460461
commitment_seed,
@@ -600,15 +601,15 @@ impl KeysInterface for KeysManager {
600601
}
601602
let funding_key = key_step!(b"funding key", commitment_seed);
602603
let revocation_base_key = key_step!(b"revocation base key", funding_key);
603-
let payment_base_key = key_step!(b"payment base key", revocation_base_key);
604-
let delayed_payment_base_key = key_step!(b"delayed payment base key", payment_base_key);
604+
let payment_key = key_step!(b"payment base key", revocation_base_key);
605+
let delayed_payment_base_key = key_step!(b"delayed payment base key", payment_key);
605606
let htlc_base_key = key_step!(b"HTLC base key", delayed_payment_base_key);
606607

607608
InMemoryChannelKeys::new(
608609
&self.secp_ctx,
609610
funding_key,
610611
revocation_base_key,
611-
payment_base_key,
612+
payment_key,
612613
delayed_payment_base_key,
613614
htlc_base_key,
614615
commitment_seed,

lightning/src/ln/chan_utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ pub struct ChannelPublicKeys {
279279
pub revocation_basepoint: PublicKey,
280280
/// The base point which is used (with derive_public_key) to derive a per-commitment payment
281281
/// public key which receives immediately-spendable non-HTLC-encumbered funds.
282-
pub payment_basepoint: PublicKey,
282+
pub payment_point: PublicKey,
283283
/// The base point which is used (with derive_public_key) to derive a per-commitment payment
284284
/// public key which receives non-HTLC-encumbered funds which are only available for spending
285285
/// after some delay (or can be claimed via the revocation path).
@@ -292,7 +292,7 @@ pub struct ChannelPublicKeys {
292292
impl_writeable!(ChannelPublicKeys, 33*5, {
293293
funding_pubkey,
294294
revocation_basepoint,
295-
payment_basepoint,
295+
payment_point,
296296
delayed_payment_basepoint,
297297
htlc_basepoint
298298
});

lightning/src/ln/channel.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
556556
let their_pubkeys = ChannelPublicKeys {
557557
funding_pubkey: msg.funding_pubkey,
558558
revocation_basepoint: msg.revocation_basepoint,
559-
payment_basepoint: msg.payment_basepoint,
559+
payment_point: msg.payment_point,
560560
delayed_payment_basepoint: msg.delayed_payment_basepoint,
561561
htlc_basepoint: msg.htlc_basepoint
562562
};
@@ -772,15 +772,15 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
772772

773773
fn get_commitment_transaction_number_obscure_factor(&self) -> u64 {
774774
let mut sha = Sha256::engine();
775-
let our_payment_basepoint = PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.payment_base_key());
775+
let our_payment_point = PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.payment_key());
776776

777-
let their_payment_basepoint = &self.their_pubkeys.as_ref().unwrap().payment_basepoint.serialize();
777+
let their_payment_point = &self.their_pubkeys.as_ref().unwrap().payment_point.serialize();
778778
if self.channel_outbound {
779-
sha.input(&our_payment_basepoint.serialize());
780-
sha.input(their_payment_basepoint);
779+
sha.input(&our_payment_point.serialize());
780+
sha.input(their_payment_point);
781781
} else {
782-
sha.input(their_payment_basepoint);
783-
sha.input(&our_payment_basepoint.serialize());
782+
sha.input(their_payment_point);
783+
sha.input(&our_payment_point.serialize());
784784
}
785785
let res = Sha256::from_engine(sha).into_inner();
786786

@@ -980,8 +980,8 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
980980
txouts.push((TxOut {
981981
script_pubkey: Builder::new().push_opcode(opcodes::all::OP_PUSHBYTES_0)
982982
.push_slice(&WPubkeyHash::hash(&if local {
983-
self.their_pubkeys.as_ref().unwrap().payment_basepoint
984-
} else { self.local_keys.pubkeys().payment_basepoint }.serialize())[..])
983+
self.their_pubkeys.as_ref().unwrap().payment_point
984+
} else { self.local_keys.pubkeys().payment_point }.serialize())[..])
985985
.into_script(),
986986
value: value_to_b as u64
987987
}, None));
@@ -1431,7 +1431,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
14311431
let their_pubkeys = ChannelPublicKeys {
14321432
funding_pubkey: msg.funding_pubkey,
14331433
revocation_basepoint: msg.revocation_basepoint,
1434-
payment_basepoint: msg.payment_basepoint,
1434+
payment_point: msg.payment_point,
14351435
delayed_payment_basepoint: msg.delayed_payment_basepoint,
14361436
htlc_basepoint: msg.htlc_basepoint
14371437
};
@@ -3318,7 +3318,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
33183318
max_accepted_htlcs: OUR_MAX_HTLCS,
33193319
funding_pubkey: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.funding_key()),
33203320
revocation_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.revocation_base_key()),
3321-
payment_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.payment_base_key()),
3321+
payment_point: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.payment_key()),
33223322
delayed_payment_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.delayed_payment_base_key()),
33233323
htlc_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.htlc_base_key()),
33243324
first_per_commitment_point: PublicKey::from_secret_key(&self.secp_ctx, &local_commitment_secret),
@@ -3351,7 +3351,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
33513351
max_accepted_htlcs: OUR_MAX_HTLCS,
33523352
funding_pubkey: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.funding_key()),
33533353
revocation_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.revocation_base_key()),
3354-
payment_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.payment_base_key()),
3354+
payment_point: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.payment_key()),
33553355
delayed_payment_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.delayed_payment_base_key()),
33563356
htlc_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.htlc_base_key()),
33573357
first_per_commitment_point: PublicKey::from_secret_key(&self.secp_ctx, &local_commitment_secret),
@@ -4454,13 +4454,13 @@ mod tests {
44544454
let their_pubkeys = ChannelPublicKeys {
44554455
funding_pubkey: public_from_secret_hex(&secp_ctx, "1552dfba4f6cf29a62a0af13c8d6981d36d0ef8d61ba10fb0fe90da7634d7e13"),
44564456
revocation_basepoint: PublicKey::from_slice(&hex::decode("02466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f27").unwrap()[..]).unwrap(),
4457-
payment_basepoint: public_from_secret_hex(&secp_ctx, "4444444444444444444444444444444444444444444444444444444444444444"),
4457+
payment_point: public_from_secret_hex(&secp_ctx, "4444444444444444444444444444444444444444444444444444444444444444"),
44584458
delayed_payment_basepoint: public_from_secret_hex(&secp_ctx, "1552dfba4f6cf29a62a0af13c8d6981d36d0ef8d61ba10fb0fe90da7634d7e13"),
44594459
htlc_basepoint: public_from_secret_hex(&secp_ctx, "4444444444444444444444444444444444444444444444444444444444444444")
44604460
};
44614461
chan_keys.set_remote_channel_pubkeys(&their_pubkeys);
44624462

4463-
assert_eq!(their_pubkeys.payment_basepoint.serialize()[..],
4463+
assert_eq!(their_pubkeys.payment_point.serialize()[..],
44644464
hex::decode("032c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991").unwrap()[..]);
44654465

44664466
assert_eq!(their_pubkeys.funding_pubkey.serialize()[..],

lightning/src/ln/channelmonitor.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1042,8 +1042,8 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
10421042
assert!(commitment_transaction_number_obscure_factor <= (1 << 48));
10431043
let our_channel_close_key_hash = WPubkeyHash::hash(&shutdown_pubkey.serialize());
10441044
let shutdown_script = Builder::new().push_opcode(opcodes::all::OP_PUSHBYTES_0).push_slice(&our_channel_close_key_hash[..]).into_script();
1045-
let payment_base_key_hash = WPubkeyHash::hash(&keys.pubkeys().payment_basepoint.serialize());
1046-
let remote_payment_script = Builder::new().push_opcode(opcodes::all::OP_PUSHBYTES_0).push_slice(&payment_base_key_hash[..]).into_script();
1045+
let payment_key_hash = WPubkeyHash::hash(&keys.pubkeys().payment_point.serialize());
1046+
let remote_payment_script = Builder::new().push_opcode(opcodes::all::OP_PUSHBYTES_0).push_slice(&payment_key_hash[..]).into_script();
10471047

10481048
let mut onchain_tx_handler = OnchainTxHandler::new(destination_script.clone(), keys.clone(), their_to_self_delay, logger.clone());
10491049

@@ -2130,7 +2130,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
21302130
} else if self.remote_payment_script == outp.script_pubkey {
21312131
spendable_output = Some(SpendableOutputDescriptor::DynamicOutputP2WPKH {
21322132
outpoint: BitcoinOutPoint { txid: tx.txid(), vout: i as u32 },
2133-
key: self.keys.payment_base_key().clone(),
2133+
key: self.keys.payment_key().clone(),
21342134
output: outp.clone(),
21352135
});
21362136
break;

lightning/src/ln/functional_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5775,7 +5775,7 @@ fn bolt2_open_channel_sending_node_checks_part2() {
57755775
assert!(PublicKey::from_slice(&node0_to_1_send_open_channel.funding_pubkey.serialize()).is_ok());
57765776
assert!(PublicKey::from_slice(&node0_to_1_send_open_channel.revocation_basepoint.serialize()).is_ok());
57775777
assert!(PublicKey::from_slice(&node0_to_1_send_open_channel.htlc_basepoint.serialize()).is_ok());
5778-
assert!(PublicKey::from_slice(&node0_to_1_send_open_channel.payment_basepoint.serialize()).is_ok());
5778+
assert!(PublicKey::from_slice(&node0_to_1_send_open_channel.payment_point.serialize()).is_ok());
57795779
assert!(PublicKey::from_slice(&node0_to_1_send_open_channel.delayed_payment_basepoint.serialize()).is_ok());
57805780
}
57815781

lightning/src/ln/msgs.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub struct OpenChannel {
9797
pub(crate) max_accepted_htlcs: u16,
9898
pub(crate) funding_pubkey: PublicKey,
9999
pub(crate) revocation_basepoint: PublicKey,
100-
pub(crate) payment_basepoint: PublicKey,
100+
pub(crate) payment_point: PublicKey,
101101
pub(crate) delayed_payment_basepoint: PublicKey,
102102
pub(crate) htlc_basepoint: PublicKey,
103103
pub(crate) first_per_commitment_point: PublicKey,
@@ -118,7 +118,7 @@ pub struct AcceptChannel {
118118
pub(crate) max_accepted_htlcs: u16,
119119
pub(crate) funding_pubkey: PublicKey,
120120
pub(crate) revocation_basepoint: PublicKey,
121-
pub(crate) payment_basepoint: PublicKey,
121+
pub(crate) payment_point: PublicKey,
122122
pub(crate) delayed_payment_basepoint: PublicKey,
123123
pub(crate) htlc_basepoint: PublicKey,
124124
pub(crate) first_per_commitment_point: PublicKey,
@@ -757,7 +757,7 @@ impl_writeable_len_match!(AcceptChannel, {
757757
max_accepted_htlcs,
758758
funding_pubkey,
759759
revocation_basepoint,
760-
payment_basepoint,
760+
payment_point,
761761
delayed_payment_basepoint,
762762
htlc_basepoint,
763763
first_per_commitment_point,
@@ -884,7 +884,7 @@ impl_writeable_len_match!(OpenChannel, {
884884
max_accepted_htlcs,
885885
funding_pubkey,
886886
revocation_basepoint,
887-
payment_basepoint,
887+
payment_point,
888888
delayed_payment_basepoint,
889889
htlc_basepoint,
890890
first_per_commitment_point,
@@ -1686,7 +1686,7 @@ mod tests {
16861686
max_accepted_htlcs: 49340,
16871687
funding_pubkey: pubkey_1,
16881688
revocation_basepoint: pubkey_2,
1689-
payment_basepoint: pubkey_3,
1689+
payment_point: pubkey_3,
16901690
delayed_payment_basepoint: pubkey_4,
16911691
htlc_basepoint: pubkey_5,
16921692
first_per_commitment_point: pubkey_6,
@@ -1740,7 +1740,7 @@ mod tests {
17401740
max_accepted_htlcs: 49340,
17411741
funding_pubkey: pubkey_1,
17421742
revocation_basepoint: pubkey_2,
1743-
payment_basepoint: pubkey_3,
1743+
payment_point: pubkey_3,
17441744
delayed_payment_basepoint: pubkey_4,
17451745
htlc_basepoint: pubkey_5,
17461746
first_per_commitment_point: pubkey_6,

lightning/src/util/enforcing_trait_impls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl EnforcingChannelKeys {
5353
impl ChannelKeys for EnforcingChannelKeys {
5454
fn funding_key(&self) -> &SecretKey { self.inner.funding_key() }
5555
fn revocation_base_key(&self) -> &SecretKey { self.inner.revocation_base_key() }
56-
fn payment_base_key(&self) -> &SecretKey { self.inner.payment_base_key() }
56+
fn payment_key(&self) -> &SecretKey { self.inner.payment_key() }
5757
fn delayed_payment_base_key(&self) -> &SecretKey { self.inner.delayed_payment_base_key() }
5858
fn htlc_base_key(&self) -> &SecretKey { self.inner.htlc_base_key() }
5959
fn commitment_seed(&self) -> &[u8; 32] { self.inner.commitment_seed() }

0 commit comments

Comments
 (0)