]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Use proper sighash flag for remote HTLCs with anchor outputs
authorWilmer Paulino <wilmer.paulino@gmail.com>
Thu, 25 Aug 2022 20:27:00 +0000 (13:27 -0700)
committerWilmer Paulino <wilmer.paulino@gmail.com>
Tue, 13 Sep 2022 17:58:14 +0000 (10:58 -0700)
lightning/src/util/enforcing_trait_impls.rs

index b4b66e8f5feb97d52ff52be9e046b55aa71bd532..f4450cc129d81979cedbf1580e5cc3a0450dad62 100644 (file)
@@ -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();
                }