Skip to content

Commit 1a574d2

Browse files
committed
Drop requirement that all ChannelKeys expose the payment_point
1 parent 9f7bcfb commit 1a574d2

File tree

5 files changed

+7
-14
lines changed

5 files changed

+7
-14
lines changed

lightning/src/chain/keysinterface.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,6 @@ impl Readable for SpendableOutputDescriptor {
197197
pub trait ChannelKeys : Send+Clone {
198198
/// Gets the local secret key for blinded revocation pubkey
199199
fn revocation_base_key<'a>(&'a self) -> &'a SecretKey;
200-
/// Gets the local secret key used in the to_remote output of remote commitment tx (ie the
201-
/// output to us in transactions our counterparty broadcasts).
202-
/// Also as part of obscured commitment number.
203-
fn payment_key<'a>(&'a self) -> &'a SecretKey;
204200
/// Gets the local secret key used in HTLC-Success/HTLC-Timeout txn and to_local output
205201
fn delayed_payment_base_key<'a>(&'a self) -> &'a SecretKey;
206202
/// Gets the local htlc secret key used in commitment tx htlc outputs
@@ -415,7 +411,6 @@ impl InMemoryChannelKeys {
415411

416412
impl ChannelKeys for InMemoryChannelKeys {
417413
fn revocation_base_key(&self) -> &SecretKey { &self.revocation_base_key }
418-
fn payment_key(&self) -> &SecretKey { &self.payment_key }
419414
fn delayed_payment_base_key(&self) -> &SecretKey { &self.delayed_payment_base_key }
420415
fn htlc_base_key(&self) -> &SecretKey { &self.htlc_base_key }
421416
fn commitment_seed(&self) -> &[u8; 32] { &self.commitment_seed }

lightning/src/ln/channel.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -766,15 +766,14 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
766766

767767
fn get_commitment_transaction_number_obscure_factor(&self) -> u64 {
768768
let mut sha = Sha256::engine();
769-
let our_payment_point = PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.payment_key());
770769

771770
let their_payment_point = &self.their_pubkeys.as_ref().unwrap().payment_point.serialize();
772771
if self.channel_outbound {
773-
sha.input(&our_payment_point.serialize());
772+
sha.input(&self.local_keys.pubkeys().payment_point.serialize());
774773
sha.input(their_payment_point);
775774
} else {
776775
sha.input(their_payment_point);
777-
sha.input(&our_payment_point.serialize());
776+
sha.input(&self.local_keys.pubkeys().payment_point.serialize());
778777
}
779778
let res = Sha256::from_engine(sha).into_inner();
780779

@@ -3317,7 +3316,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
33173316
max_accepted_htlcs: OUR_MAX_HTLCS,
33183317
funding_pubkey: local_keys.funding_pubkey,
33193318
revocation_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.revocation_base_key()),
3320-
payment_point: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.payment_key()),
3319+
payment_point: local_keys.payment_point,
33213320
delayed_payment_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.delayed_payment_base_key()),
33223321
htlc_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.htlc_base_key()),
33233322
first_per_commitment_point: PublicKey::from_secret_key(&self.secp_ctx, &local_commitment_secret),
@@ -3351,7 +3350,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
33513350
max_accepted_htlcs: OUR_MAX_HTLCS,
33523351
funding_pubkey: local_keys.funding_pubkey,
33533352
revocation_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.revocation_base_key()),
3354-
payment_point: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.payment_key()),
3353+
payment_point: local_keys.payment_point,
33553354
delayed_payment_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.delayed_payment_base_key()),
33563355
htlc_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.htlc_base_key()),
33573356
first_per_commitment_point: PublicKey::from_secret_key(&self.secp_ctx, &local_commitment_secret),

lightning/src/ln/channelmonitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
16411641
self.remote_payment_script = {
16421642
// Note that the Network here is ignored as we immediately drop the address for the
16431643
// script_pubkey version
1644-
let payment_hash160 = WPubkeyHash::hash(&PublicKey::from_secret_key(&self.secp_ctx, &self.keys.payment_key()).serialize());
1644+
let payment_hash160 = WPubkeyHash::hash(&self.keys.pubkeys().payment_point.serialize());
16451645
Builder::new().push_opcode(opcodes::all::OP_PUSHBYTES_0).push_slice(&payment_hash160[..]).into_script()
16461646
};
16471647

lightning/src/ln/functional_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4293,10 +4293,10 @@ macro_rules! check_spendable_outputs {
42934293
};
42944294
let secp_ctx = Secp256k1::new();
42954295
let keys = $keysinterface.derive_channel_keys($chan_value, key_derivation_params.0, key_derivation_params.1);
4296-
let remotepubkey = PublicKey::from_secret_key(&secp_ctx, &keys.payment_key());
4296+
let remotepubkey = keys.pubkeys().payment_point;
42974297
let witness_script = Address::p2pkh(&::bitcoin::PublicKey{compressed: true, key: remotepubkey}, Network::Testnet).script_pubkey();
42984298
let sighash = Message::from_slice(&bip143::SighashComponents::new(&spend_tx).sighash_all(&spend_tx.input[0], &witness_script, output.value)[..]).unwrap();
4299-
let remotesig = secp_ctx.sign(&sighash, &keys.payment_key());
4299+
let remotesig = secp_ctx.sign(&sighash, &keys.inner.payment_key);
43004300
spend_tx.input[0].witness.push(remotesig.serialize_der().to_vec());
43014301
spend_tx.input[0].witness[0].push(SigHashType::All as u8);
43024302
spend_tx.input[0].witness.push(remotepubkey.serialize().to_vec());

lightning/src/util/enforcing_trait_impls.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ impl EnforcingChannelKeys {
5252

5353
impl ChannelKeys for EnforcingChannelKeys {
5454
fn revocation_base_key(&self) -> &SecretKey { self.inner.revocation_base_key() }
55-
fn payment_key(&self) -> &SecretKey { self.inner.payment_key() }
5655
fn delayed_payment_base_key(&self) -> &SecretKey { self.inner.delayed_payment_base_key() }
5756
fn htlc_base_key(&self) -> &SecretKey { self.inner.htlc_base_key() }
5857
fn commitment_seed(&self) -> &[u8; 32] { self.inner.commitment_seed() }

0 commit comments

Comments
 (0)