]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Cache commitment point on ExternalHTLCClaim to drop a signer call
authorAlec Chen <alecchendev@gmail.com>
Wed, 5 Jun 2024 21:08:41 +0000 (16:08 -0500)
committerAlec Chen <alecchendev@gmail.com>
Wed, 5 Jun 2024 21:10:12 +0000 (16:10 -0500)
lightning/src/chain/channelmonitor.rs
lightning/src/chain/onchaintx.rs

index 3ca15e48337f3bb2da922814be39f0acde240818..3a289226907e3f8d9d659f2731bcab7c3fe25ee2 100644 (file)
@@ -3104,9 +3104,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
                                                        },
                                                        commitment_txid: htlc.commitment_txid,
                                                        per_commitment_number: htlc.per_commitment_number,
-                                                       per_commitment_point: self.onchain_tx_handler.signer.get_per_commitment_point(
-                                                               htlc.per_commitment_number, &self.onchain_tx_handler.secp_ctx,
-                                                       ),
+                                                       per_commitment_point: htlc.per_commitment_point,
                                                        feerate_per_kw: 0,
                                                        htlc: htlc.htlc,
                                                        preimage: htlc.preimage,
index f66258c2c764d72d884b9670ab13ab511b2ce833..6bbd2439e507257a7acaa6c115167e18e8345bd8 100644 (file)
@@ -19,6 +19,7 @@ use bitcoin::blockdata::script::{Script, ScriptBuf};
 use bitcoin::hashes::{Hash, HashEngine};
 use bitcoin::hashes::sha256::Hash as Sha256;
 use bitcoin::hash_types::{Txid, BlockHash};
+use bitcoin::secp256k1::PublicKey;
 use bitcoin::secp256k1::{Secp256k1, ecdsa::Signature};
 use bitcoin::secp256k1;
 
@@ -179,6 +180,7 @@ pub(crate) struct ExternalHTLCClaim {
        pub(crate) htlc: HTLCOutputInCommitment,
        pub(crate) preimage: Option<PaymentPreimage>,
        pub(crate) counterparty_sig: Signature,
+       pub(crate) per_commitment_point: PublicKey,
 }
 
 // Represents the different types of claims for which events are yielded externally to satisfy said
@@ -1230,6 +1232,7 @@ impl<ChannelSigner: EcdsaChannelSigner> OnchainTxHandler<ChannelSigner> {
                                                htlc: htlc.clone(),
                                                preimage: *preimage,
                                                counterparty_sig: counterparty_htlc_sig,
+                                               per_commitment_point: trusted_tx.per_commitment_point(),
                                        }
                                })
                };