mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-24 23:08:36 +01:00
Drop requirement that all ChannelKeys expose the payment_point
This commit is contained in:
parent
9f7bcfb1ed
commit
1a574d2055
5 changed files with 7 additions and 14 deletions
|
@ -197,10 +197,6 @@ impl Readable for SpendableOutputDescriptor {
|
|||
pub trait ChannelKeys : Send+Clone {
|
||||
/// Gets the local secret key for blinded revocation pubkey
|
||||
fn revocation_base_key<'a>(&'a self) -> &'a SecretKey;
|
||||
/// Gets the local secret key used in the to_remote output of remote commitment tx (ie the
|
||||
/// output to us in transactions our counterparty broadcasts).
|
||||
/// Also as part of obscured commitment number.
|
||||
fn payment_key<'a>(&'a self) -> &'a SecretKey;
|
||||
/// Gets the local secret key used in HTLC-Success/HTLC-Timeout txn and to_local output
|
||||
fn delayed_payment_base_key<'a>(&'a self) -> &'a SecretKey;
|
||||
/// Gets the local htlc secret key used in commitment tx htlc outputs
|
||||
|
@ -415,7 +411,6 @@ impl InMemoryChannelKeys {
|
|||
|
||||
impl ChannelKeys for InMemoryChannelKeys {
|
||||
fn revocation_base_key(&self) -> &SecretKey { &self.revocation_base_key }
|
||||
fn payment_key(&self) -> &SecretKey { &self.payment_key }
|
||||
fn delayed_payment_base_key(&self) -> &SecretKey { &self.delayed_payment_base_key }
|
||||
fn htlc_base_key(&self) -> &SecretKey { &self.htlc_base_key }
|
||||
fn commitment_seed(&self) -> &[u8; 32] { &self.commitment_seed }
|
||||
|
|
|
@ -766,15 +766,14 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
|
|||
|
||||
fn get_commitment_transaction_number_obscure_factor(&self) -> u64 {
|
||||
let mut sha = Sha256::engine();
|
||||
let our_payment_point = PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.payment_key());
|
||||
|
||||
let their_payment_point = &self.their_pubkeys.as_ref().unwrap().payment_point.serialize();
|
||||
if self.channel_outbound {
|
||||
sha.input(&our_payment_point.serialize());
|
||||
sha.input(&self.local_keys.pubkeys().payment_point.serialize());
|
||||
sha.input(their_payment_point);
|
||||
} else {
|
||||
sha.input(their_payment_point);
|
||||
sha.input(&our_payment_point.serialize());
|
||||
sha.input(&self.local_keys.pubkeys().payment_point.serialize());
|
||||
}
|
||||
let res = Sha256::from_engine(sha).into_inner();
|
||||
|
||||
|
@ -3317,7 +3316,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
|
|||
max_accepted_htlcs: OUR_MAX_HTLCS,
|
||||
funding_pubkey: local_keys.funding_pubkey,
|
||||
revocation_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.revocation_base_key()),
|
||||
payment_point: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.payment_key()),
|
||||
payment_point: local_keys.payment_point,
|
||||
delayed_payment_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.delayed_payment_base_key()),
|
||||
htlc_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.htlc_base_key()),
|
||||
first_per_commitment_point: PublicKey::from_secret_key(&self.secp_ctx, &local_commitment_secret),
|
||||
|
@ -3351,7 +3350,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
|
|||
max_accepted_htlcs: OUR_MAX_HTLCS,
|
||||
funding_pubkey: local_keys.funding_pubkey,
|
||||
revocation_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.revocation_base_key()),
|
||||
payment_point: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.payment_key()),
|
||||
payment_point: local_keys.payment_point,
|
||||
delayed_payment_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.delayed_payment_base_key()),
|
||||
htlc_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.htlc_base_key()),
|
||||
first_per_commitment_point: PublicKey::from_secret_key(&self.secp_ctx, &local_commitment_secret),
|
||||
|
|
|
@ -1641,7 +1641,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
|
|||
self.remote_payment_script = {
|
||||
// Note that the Network here is ignored as we immediately drop the address for the
|
||||
// script_pubkey version
|
||||
let payment_hash160 = WPubkeyHash::hash(&PublicKey::from_secret_key(&self.secp_ctx, &self.keys.payment_key()).serialize());
|
||||
let payment_hash160 = WPubkeyHash::hash(&self.keys.pubkeys().payment_point.serialize());
|
||||
Builder::new().push_opcode(opcodes::all::OP_PUSHBYTES_0).push_slice(&payment_hash160[..]).into_script()
|
||||
};
|
||||
|
||||
|
|
|
@ -4293,10 +4293,10 @@ macro_rules! check_spendable_outputs {
|
|||
};
|
||||
let secp_ctx = Secp256k1::new();
|
||||
let keys = $keysinterface.derive_channel_keys($chan_value, key_derivation_params.0, key_derivation_params.1);
|
||||
let remotepubkey = PublicKey::from_secret_key(&secp_ctx, &keys.payment_key());
|
||||
let remotepubkey = keys.pubkeys().payment_point;
|
||||
let witness_script = Address::p2pkh(&::bitcoin::PublicKey{compressed: true, key: remotepubkey}, Network::Testnet).script_pubkey();
|
||||
let sighash = Message::from_slice(&bip143::SighashComponents::new(&spend_tx).sighash_all(&spend_tx.input[0], &witness_script, output.value)[..]).unwrap();
|
||||
let remotesig = secp_ctx.sign(&sighash, &keys.payment_key());
|
||||
let remotesig = secp_ctx.sign(&sighash, &keys.inner.payment_key);
|
||||
spend_tx.input[0].witness.push(remotesig.serialize_der().to_vec());
|
||||
spend_tx.input[0].witness[0].push(SigHashType::All as u8);
|
||||
spend_tx.input[0].witness.push(remotepubkey.serialize().to_vec());
|
||||
|
|
|
@ -52,7 +52,6 @@ impl EnforcingChannelKeys {
|
|||
|
||||
impl ChannelKeys for EnforcingChannelKeys {
|
||||
fn revocation_base_key(&self) -> &SecretKey { self.inner.revocation_base_key() }
|
||||
fn payment_key(&self) -> &SecretKey { self.inner.payment_key() }
|
||||
fn delayed_payment_base_key(&self) -> &SecretKey { self.inner.delayed_payment_base_key() }
|
||||
fn htlc_base_key(&self) -> &SecretKey { self.inner.htlc_base_key() }
|
||||
fn commitment_seed(&self) -> &[u8; 32] { self.inner.commitment_seed() }
|
||||
|
|
Loading…
Add table
Reference in a new issue