From 2f4a1f7f79e55d28b289f4907e019e66a251a19e Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Thu, 25 Aug 2022 13:27:00 -0700 Subject: [PATCH] Use proper sighash flag for remote HTLCs with anchor outputs --- lightning/src/util/enforcing_trait_impls.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lightning/src/util/enforcing_trait_impls.rs b/lightning/src/util/enforcing_trait_impls.rs index b4b66e8f5..f4450cc12 100644 --- a/lightning/src/util/enforcing_trait_impls.rs +++ b/lightning/src/util/enforcing_trait_impls.rs @@ -160,7 +160,16 @@ impl BaseSign for EnforcingSigner { let htlc_redeemscript = chan_utils::get_htlc_redeemscript(&this_htlc, self.opt_anchors(), &keys); - let sighash = hash_to_message!(&sighash::SighashCache::new(&htlc_tx).segwit_signature_hash(0, &htlc_redeemscript, this_htlc.amount_msat / 1000, EcdsaSighashType::All).unwrap()[..]); + let sighash_type = if self.opt_anchors() { + EcdsaSighashType::SinglePlusAnyoneCanPay + } else { + EcdsaSighashType::All + }; + let sighash = hash_to_message!( + &sighash::SighashCache::new(&htlc_tx).segwit_signature_hash( + 0, &htlc_redeemscript, this_htlc.amount_msat / 1000, sighash_type, + ).unwrap()[..] + ); secp_ctx.verify_ecdsa(&sighash, sig, &keys.countersignatory_htlc_key).unwrap(); } -- 2.39.5