@@ -11,7 +11,6 @@ use bitcoin::amount::Amount;
11
11
use bitcoin::constants::ChainHash;
12
12
use bitcoin::script::{Script, ScriptBuf, Builder, WScriptHash};
13
13
use bitcoin::transaction::{Transaction, TxIn};
14
- use bitcoin::sighash;
15
14
use bitcoin::sighash::EcdsaSighashType;
16
15
use bitcoin::consensus::encode;
17
16
use bitcoin::absolute::LockTime;
@@ -5254,7 +5253,7 @@ impl<SP: Deref> FundedChannel<SP> where
5254
5253
}
5255
5254
5256
5255
let holder_commitment_tx = HolderCommitmentTransaction::new(
5257
- commitment_stats.tx.clone() ,
5256
+ commitment_stats.tx,
5258
5257
msg.signature,
5259
5258
msg.htlc_signatures.clone(),
5260
5259
&self.context.get_holder_pubkeys().funding_pubkey,
@@ -5264,11 +5263,6 @@ impl<SP: Deref> FundedChannel<SP> where
5264
5263
self.context.holder_signer.as_ref().validate_holder_commitment(&holder_commitment_tx, commitment_stats.outbound_htlc_preimages, &self.context.secp_ctx)
5265
5264
.map_err(|_| ChannelError::close("Failed to validate our commitment".to_owned()))?;
5266
5265
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
- };
5272
5266
let mut htlcs_cloned: Vec<_> = commitment_stats.htlcs_included.iter().map(|htlc| (htlc.0.clone(), htlc.1.map(|h| h.clone()))).collect();
5273
5267
5274
5268
// If our counterparty updated the channel fee in this commitment transaction, check that
@@ -5318,21 +5312,8 @@ impl<SP: Deref> FundedChannel<SP> where
5318
5312
5319
5313
let mut nondust_htlc_sources = Vec::with_capacity(htlcs_cloned.len());
5320
5314
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);
5322
5315
for (idx, (htlc, mut source_opt)) in htlcs_cloned.drain(..).enumerate() {
5323
5316
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
- }
5336
5317
if !separate_nondust_htlc_sources {
5337
5318
htlcs_and_sigs.push((htlc, Some(msg.htlc_signatures[idx]), source_opt.take()));
5338
5319
}
0 commit comments