Skip to content

Commit acdd6d8

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 8b3276b commit acdd6d8

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
@@ -280,7 +280,7 @@ pub struct ChannelPublicKeys {
280280
pub revocation_basepoint: PublicKey,
281281
/// The base point which is used (with derive_public_key) to derive a per-commitment payment
282282
/// public key which receives immediately-spendable non-HTLC-encumbered funds.
283-
pub payment_basepoint: PublicKey,
283+
pub payment_point: PublicKey,
284284
/// The base point which is used (with derive_public_key) to derive a per-commitment payment
285285
/// public key which receives non-HTLC-encumbered funds which are only available for spending
286286
/// after some delay (or can be claimed via the revocation path).
@@ -293,7 +293,7 @@ pub struct ChannelPublicKeys {
293293
impl_writeable!(ChannelPublicKeys, 33*5, {
294294
funding_pubkey,
295295
revocation_basepoint,
296-
payment_basepoint,
296+
payment_point,
297297
delayed_payment_basepoint,
298298
htlc_basepoint
299299
});

lightning/src/ln/channel.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
557557
let their_pubkeys = ChannelPublicKeys {
558558
funding_pubkey: msg.funding_pubkey,
559559
revocation_basepoint: msg.revocation_basepoint,
560-
payment_basepoint: msg.payment_basepoint,
560+
payment_point: msg.payment_point,
561561
delayed_payment_basepoint: msg.delayed_payment_basepoint,
562562
htlc_basepoint: msg.htlc_basepoint
563563
};
@@ -773,15 +773,15 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
773773

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

778-
let their_payment_basepoint = &self.their_pubkeys.as_ref().unwrap().payment_basepoint.serialize();
778+
let their_payment_point = &self.their_pubkeys.as_ref().unwrap().payment_point.serialize();
779779
if self.channel_outbound {
780-
sha.input(&our_payment_basepoint.serialize());
781-
sha.input(their_payment_basepoint);
780+
sha.input(&our_payment_point.serialize());
781+
sha.input(their_payment_point);
782782
} else {
783-
sha.input(their_payment_basepoint);
784-
sha.input(&our_payment_basepoint.serialize());
783+
sha.input(their_payment_point);
784+
sha.input(&our_payment_point.serialize());
785785
}
786786
let res = Sha256::from_engine(sha).into_inner();
787787

@@ -981,8 +981,8 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
981981
txouts.push((TxOut {
982982
script_pubkey: Builder::new().push_opcode(opcodes::all::OP_PUSHBYTES_0)
983983
.push_slice(&Hash160::hash(&if local {
984-
self.their_pubkeys.as_ref().unwrap().payment_basepoint
985-
} else { self.local_keys.pubkeys().payment_basepoint }.serialize())[..])
984+
self.their_pubkeys.as_ref().unwrap().payment_point
985+
} else { self.local_keys.pubkeys().payment_point }.serialize())[..])
986986
.into_script(),
987987
value: value_to_b as u64
988988
}, None));
@@ -1432,7 +1432,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
14321432
let their_pubkeys = ChannelPublicKeys {
14331433
funding_pubkey: msg.funding_pubkey,
14341434
revocation_basepoint: msg.revocation_basepoint,
1435-
payment_basepoint: msg.payment_basepoint,
1435+
payment_point: msg.payment_point,
14361436
delayed_payment_basepoint: msg.delayed_payment_basepoint,
14371437
htlc_basepoint: msg.htlc_basepoint
14381438
};
@@ -3319,7 +3319,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
33193319
max_accepted_htlcs: OUR_MAX_HTLCS,
33203320
funding_pubkey: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.funding_key()),
33213321
revocation_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.revocation_base_key()),
3322-
payment_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.payment_base_key()),
3322+
payment_point: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.payment_key()),
33233323
delayed_payment_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.delayed_payment_base_key()),
33243324
htlc_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.htlc_base_key()),
33253325
first_per_commitment_point: PublicKey::from_secret_key(&self.secp_ctx, &local_commitment_secret),
@@ -3352,7 +3352,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
33523352
max_accepted_htlcs: OUR_MAX_HTLCS,
33533353
funding_pubkey: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.funding_key()),
33543354
revocation_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.revocation_base_key()),
3355-
payment_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.payment_base_key()),
3355+
payment_point: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.payment_key()),
33563356
delayed_payment_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.delayed_payment_base_key()),
33573357
htlc_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.htlc_base_key()),
33583358
first_per_commitment_point: PublicKey::from_secret_key(&self.secp_ctx, &local_commitment_secret),
@@ -4456,13 +4456,13 @@ mod tests {
44564456
let their_pubkeys = ChannelPublicKeys {
44574457
funding_pubkey: public_from_secret_hex(&secp_ctx, "1552dfba4f6cf29a62a0af13c8d6981d36d0ef8d61ba10fb0fe90da7634d7e13"),
44584458
revocation_basepoint: PublicKey::from_slice(&hex::decode("02466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f27").unwrap()[..]).unwrap(),
4459-
payment_basepoint: public_from_secret_hex(&secp_ctx, "4444444444444444444444444444444444444444444444444444444444444444"),
4459+
payment_point: public_from_secret_hex(&secp_ctx, "4444444444444444444444444444444444444444444444444444444444444444"),
44604460
delayed_payment_basepoint: public_from_secret_hex(&secp_ctx, "1552dfba4f6cf29a62a0af13c8d6981d36d0ef8d61ba10fb0fe90da7634d7e13"),
44614461
htlc_basepoint: public_from_secret_hex(&secp_ctx, "4444444444444444444444444444444444444444444444444444444444444444")
44624462
};
44634463
chan_keys.set_remote_channel_pubkeys(&their_pubkeys);
44644464

4465-
assert_eq!(their_pubkeys.payment_basepoint.serialize()[..],
4465+
assert_eq!(their_pubkeys.payment_point.serialize()[..],
44664466
hex::decode("032c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991").unwrap()[..]);
44674467

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

lightning/src/ln/channelmonitor.rs

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

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

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

lightning/src/ln/functional_tests.rs

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

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)