Skip to content

Commit 587f006

Browse files
OttoAllmendingerllm-git
andcommitted
feat(wasm-utxo): add support for signing P2TR script path inputs
Support adding user signatures to P2TR script path inputs using the tap_script_sigs field for both legacy script path and Musig2 script path formats. Issue: BTC-2652 Co-authored-by: llm-git <[email protected]>
1 parent 39936c1 commit 587f006

File tree

1 file changed

+26
-11
lines changed
  • packages/wasm-utxo/src/bitgo_psbt

1 file changed

+26
-11
lines changed

packages/wasm-utxo/src/bitgo_psbt/mod.rs

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ mod tests {
451451

452452
// ensure we can put the first signature (user signature) on an unsigned PSBT
453453
fn assert_half_sign(
454+
script_type: fixtures::ScriptType,
454455
unsigned_bitgo_psbt: &BitGoPsbt,
455456
halfsigned_bitgo_psbt: &BitGoPsbt,
456457
wallet_keys: &fixtures::XprvTriple,
@@ -474,14 +475,30 @@ mod tests {
474475
return Err("Zcash signing not yet implemented".to_string());
475476
}
476477
};
477-
let actual_partial_sigs = signed_input.partial_sigs.clone();
478-
479-
// Get expected partial signatures from halfsigned fixture
480-
let expected_partial_sigs = halfsigned_bitgo_psbt.clone().into_psbt().inputs[input_index]
481-
.partial_sigs
482-
.clone();
483478

484-
assert_eq_partial_signatures(&actual_partial_sigs, &expected_partial_sigs)?;
479+
match script_type {
480+
fixtures::ScriptType::P2trLegacyScriptPath
481+
| fixtures::ScriptType::P2trMusig2ScriptPath => {
482+
assert_eq!(signed_input.tap_script_sigs.len(), 1);
483+
// Get expected tap script sig from halfsigned fixture
484+
let expected_tap_script_sig = halfsigned_bitgo_psbt.clone().into_psbt().inputs
485+
[input_index]
486+
.tap_script_sigs
487+
.clone();
488+
assert_eq!(signed_input.tap_script_sigs, expected_tap_script_sig);
489+
}
490+
_ => {
491+
let actual_partial_sigs = signed_input.partial_sigs.clone();
492+
// Get expected partial signatures from halfsigned fixture
493+
let expected_partial_sigs = halfsigned_bitgo_psbt.clone().into_psbt().inputs
494+
[input_index]
495+
.partial_sigs
496+
.clone();
497+
498+
assert_eq!(actual_partial_sigs.len(), 1);
499+
assert_eq_partial_signatures(&actual_partial_sigs, &expected_partial_sigs)?;
500+
}
501+
}
485502

486503
Ok(())
487504
}
@@ -614,11 +631,9 @@ mod tests {
614631

615632
let psbt_input_stages = psbt_input_stages.unwrap();
616633

617-
if script_type != fixtures::ScriptType::P2trMusig2TaprootKeypath
618-
&& script_type != fixtures::ScriptType::P2trMusig2ScriptPath
619-
&& script_type != fixtures::ScriptType::P2trLegacyScriptPath
620-
{
634+
if script_type != fixtures::ScriptType::P2trMusig2TaprootKeypath {
621635
assert_half_sign(
636+
script_type,
622637
&psbt_stages
623638
.unsigned
624639
.to_bitgo_psbt(network)

0 commit comments

Comments
 (0)