@@ -11,7 +11,6 @@ use bitcoin::amount::Amount;
1111use bitcoin::constants::ChainHash;
1212use bitcoin::script::{Script, ScriptBuf, Builder, WScriptHash};
1313use bitcoin::transaction::{Transaction, TxIn};
14- use bitcoin::sighash;
1514use bitcoin::sighash::EcdsaSighashType;
1615use bitcoin::consensus::encode;
1716use bitcoin::absolute::LockTime;
@@ -5254,7 +5253,7 @@ impl<SP: Deref> FundedChannel<SP> where
52545253 }
52555254
52565255 let holder_commitment_tx = HolderCommitmentTransaction::new(
5257- commitment_stats.tx.clone() ,
5256+ commitment_stats.tx,
52585257 msg.signature,
52595258 msg.htlc_signatures.clone(),
52605259 &self.context.get_holder_pubkeys().funding_pubkey,
@@ -5264,11 +5263,6 @@ impl<SP: Deref> FundedChannel<SP> where
52645263 self.context.holder_signer.as_ref().validate_holder_commitment(&holder_commitment_tx, commitment_stats.outbound_htlc_preimages, &self.context.secp_ctx)
52655264 .map_err(|_| ChannelError::close("Failed to validate our commitment".to_owned()))?;
52665265
5267- let commitment_txid = {
5268- let trusted_tx = commitment_stats.tx.trust();
5269- let bitcoin_tx = trusted_tx.built_transaction();
5270- bitcoin_tx.txid
5271- };
52725266 let mut htlcs_cloned: Vec<_> = commitment_stats.htlcs_included.iter().map(|htlc| (htlc.0.clone(), htlc.1.map(|h| h.clone()))).collect();
52735267
52745268 // If our counterparty updated the channel fee in this commitment transaction, check that
@@ -5318,21 +5312,8 @@ impl<SP: Deref> FundedChannel<SP> where
53185312
53195313 let mut nondust_htlc_sources = Vec::with_capacity(htlcs_cloned.len());
53205314 let mut htlcs_and_sigs = Vec::with_capacity(htlcs_cloned.len());
5321- let revokeable_spk = self.context.holder_signer.as_ref().get_revokeable_spk(true, commitment_stats.tx.commitment_number(), &commitment_stats.tx.per_commitment_point(), &self.context.secp_ctx);
53225315 for (idx, (htlc, mut source_opt)) in htlcs_cloned.drain(..).enumerate() {
53235316 if let Some(_) = htlc.transaction_output_index {
5324- let htlc_tx = chan_utils::build_htlc_transaction(&commitment_txid, commitment_stats.feerate_per_kw,
5325- &htlc, &self.context.channel_type, revokeable_spk.clone());
5326-
5327- let htlc_redeemscript = chan_utils::get_htlc_redeemscript(&htlc, &self.context.channel_type, &keys);
5328- let htlc_sighashtype = if self.context.channel_type.supports_anchors_zero_fee_htlc_tx() { EcdsaSighashType::SinglePlusAnyoneCanPay } else { EcdsaSighashType::All };
5329- let htlc_sighash = hash_to_message!(&sighash::SighashCache::new(&htlc_tx).p2wsh_signature_hash(0, &htlc_redeemscript, htlc.to_bitcoin_amount(), htlc_sighashtype).unwrap()[..]);
5330- log_trace!(logger, "Checking HTLC tx signature {} by key {} against tx {} (sighash {}) with redeemscript {} in channel {}.",
5331- log_bytes!(msg.htlc_signatures[idx].serialize_compact()[..]), log_bytes!(keys.countersignatory_htlc_key.to_public_key().serialize()),
5332- encode::serialize_hex(&htlc_tx), log_bytes!(htlc_sighash[..]), encode::serialize_hex(&htlc_redeemscript), &self.context.channel_id());
5333- if let Err(_) = self.context.secp_ctx.verify_ecdsa(&htlc_sighash, &msg.htlc_signatures[idx], &keys.countersignatory_htlc_key.to_public_key()) {
5334- return Err(ChannelError::close("Invalid HTLC tx signature from peer".to_owned()));
5335- }
53365317 if !separate_nondust_htlc_sources {
53375318 htlcs_and_sigs.push((htlc, Some(msg.htlc_signatures[idx]), source_opt.take()));
53385319 }
0 commit comments