Use proper sighash flag for remote HTLCs with anchor outputs

This commit is contained in:
Wilmer Paulino 2022-08-25 13:27:00 -07:00
parent a82fb62856
commit 2f4a1f7f79
No known key found for this signature in database
GPG key ID: 6DF57B9F9514972F

View 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();
}