From: Wilmer Paulino Date: Thu, 25 Aug 2022 20:27:00 +0000 (-0700) Subject: Use proper sighash flag for remote HTLCs with anchor outputs X-Git-Tag: v0.0.112~40^2~6 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=2f4a1f7f79e55d28b289f4907e019e66a251a19e;p=rust-lightning Use proper sighash flag for remote HTLCs with anchor outputs --- 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(); }