Skip to content

Commit

Permalink
spending_reqs: Add sighash type option for p2tr_check.
Browse files Browse the repository at this point in the history
  • Loading branch information
ceyhunsen committed Aug 30, 2024
1 parent e6179ab commit 95e0d0f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/ledger/spending_requirements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use bitcoin::{
taproot::{ControlBlock, LeafVersion},
TapLeafHash, XOnlyPublicKey,
};
use bitcoin::{Script, WitnessProgram};
use bitcoin::{Script, TapSighashType, WitnessProgram};
use secp256k1::Message;

#[derive(Default)]
Expand Down Expand Up @@ -159,7 +159,13 @@ impl Ledger {
let h = sighashcache
.taproot_key_spend_signature_hash(
input_idx,
&Prevouts::All(txouts),
&match signature.sighash_type {
TapSighashType::SinglePlusAnyoneCanPay => {
Prevouts::One(input_idx, txouts[input_idx].clone())
}
// TODO: Implement others.
_ => Prevouts::All(txouts),
},
signature.sighash_type,
)
.unwrap();
Expand Down

0 comments on commit 95e0d0f

Please sign in to comment.