Skip to content

Commit fb586b0

Browse files
OttoAllmendingerllm-git
andcommitted
feat(wasm-utxo): rename taproot script type enums to be more descriptive
Update ScriptType enum variants to have more consistent and descriptive naming that better reflects their purpose: - P2tr -> P2trLegacyScriptPath - P2trMusig2 -> P2trMusig2ScriptPath - TaprootKeypath -> P2trMusig2TaprootKeypath Update all test cases to use the new enum variants. Co-authored-by: llm-git <[email protected]>
1 parent 62cb38d commit fb586b0

File tree

3 files changed

+42
-34
lines changed

3 files changed

+42
-34
lines changed

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

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -579,27 +579,24 @@ mod tests {
579579
ignore: [BitcoinGold]
580580
);
581581

582-
crate::test_psbt_fixtures!(test_p2tr_script_generation_from_fixture, network, format, {
583-
test_wallet_script_type(fixtures::ScriptType::P2tr, network, format).unwrap();
582+
crate::test_psbt_fixtures!(test_p2tr_legacy_script_path_suite, network, format, {
583+
test_wallet_script_type(fixtures::ScriptType::P2trLegacyScriptPath, network, format)
584+
.unwrap();
584585
});
585586

586-
crate::test_psbt_fixtures!(
587-
test_p2tr_musig2_script_path_generation_from_fixture,
588-
network,
589-
format,
590-
{
591-
test_wallet_script_type(fixtures::ScriptType::P2trMusig2, network, format).unwrap();
592-
}
593-
);
587+
crate::test_psbt_fixtures!(test_p2tr_musig2_script_path_suite, network, format, {
588+
test_wallet_script_type(fixtures::ScriptType::P2trMusig2ScriptPath, network, format)
589+
.unwrap();
590+
});
594591

595-
crate::test_psbt_fixtures!(
596-
test_p2tr_musig2_key_path_spend_script_generation_from_fixture,
597-
network,
598-
format,
599-
{
600-
test_wallet_script_type(fixtures::ScriptType::TaprootKeypath, network, format).unwrap();
601-
}
602-
);
592+
crate::test_psbt_fixtures!(test_p2tr_musig2_key_path_suite, network, format, {
593+
test_wallet_script_type(
594+
fixtures::ScriptType::P2trMusig2TaprootKeypath,
595+
network,
596+
format,
597+
)
598+
.unwrap();
599+
});
603600

604601
crate::test_psbt_fixtures!(test_extract_transaction, network, format, {
605602
let fixture = fixtures::load_psbt_fixture_with_format(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,12 +689,12 @@ mod tests {
689689
.expect("Failed to load fixture");
690690

691691
let (input_index, input_fixture) = fixture
692-
.find_input_with_script_type(ScriptType::TaprootKeypath)
692+
.find_input_with_script_type(ScriptType::P2trMusig2TaprootKeypath)
693693
.expect("Failed to find taprootKeyPathSpend input");
694694

695695
let finalized_input_fixture = if signature_state == SignatureState::Fullsigned {
696696
let (finalized_input_index, finalized_input_fixture) = fixture
697-
.find_finalized_input_with_script_type(ScriptType::TaprootKeypath)
697+
.find_finalized_input_with_script_type(ScriptType::P2trMusig2TaprootKeypath)
698698
.expect("Failed to find taprootKeyPathSpend finalized input");
699699
assert_eq!(input_index, finalized_input_index);
700700
Some(finalized_input_fixture)

packages/wasm-utxo/src/fixed_script_wallet/test_utils/fixtures.rs

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,9 +1001,12 @@ pub enum ScriptType {
10011001
P2sh,
10021002
P2shP2wsh,
10031003
P2wsh,
1004-
P2tr,
1005-
P2trMusig2,
1006-
TaprootKeypath,
1004+
// Chain 30 and 31 - we only support script path spending for these
1005+
P2trLegacyScriptPath,
1006+
// Chain 40 and 41 - script path spend
1007+
P2trMusig2ScriptPath,
1008+
// Chain 40 and 41 - keypath spend
1009+
P2trMusig2TaprootKeypath,
10071010
}
10081011

10091012
impl ScriptType {
@@ -1013,9 +1016,9 @@ impl ScriptType {
10131016
ScriptType::P2sh => "p2sh",
10141017
ScriptType::P2shP2wsh => "p2shP2wsh",
10151018
ScriptType::P2wsh => "p2wsh",
1016-
ScriptType::P2tr => "p2tr",
1017-
ScriptType::P2trMusig2 => "p2trMusig2",
1018-
ScriptType::TaprootKeypath => "taprootKeypath",
1019+
ScriptType::P2trLegacyScriptPath => "p2tr",
1020+
ScriptType::P2trMusig2ScriptPath => "p2trMusig2",
1021+
ScriptType::P2trMusig2TaprootKeypath => "taprootKeypath",
10191022
}
10201023
}
10211024

@@ -1026,13 +1029,16 @@ impl ScriptType {
10261029
(ScriptType::P2sh, PsbtInputFixture::P2sh(_))
10271030
| (ScriptType::P2shP2wsh, PsbtInputFixture::P2shP2wsh(_))
10281031
| (ScriptType::P2wsh, PsbtInputFixture::P2wsh(_))
1029-
| (ScriptType::P2tr, PsbtInputFixture::P2trLegacy(_))
10301032
| (
1031-
ScriptType::P2trMusig2,
1033+
ScriptType::P2trLegacyScriptPath,
1034+
PsbtInputFixture::P2trLegacy(_)
1035+
)
1036+
| (
1037+
ScriptType::P2trMusig2ScriptPath,
10321038
PsbtInputFixture::P2trMusig2ScriptPath(_)
10331039
)
10341040
| (
1035-
ScriptType::TaprootKeypath,
1041+
ScriptType::P2trMusig2TaprootKeypath,
10361042
PsbtInputFixture::P2trMusig2KeyPath(_)
10371043
)
10381044
)
@@ -1045,13 +1051,16 @@ impl ScriptType {
10451051
(ScriptType::P2sh, PsbtFinalInputFixture::P2sh(_))
10461052
| (ScriptType::P2shP2wsh, PsbtFinalInputFixture::P2shP2wsh(_))
10471053
| (ScriptType::P2wsh, PsbtFinalInputFixture::P2wsh(_))
1048-
| (ScriptType::P2tr, PsbtFinalInputFixture::P2trLegacy(_))
10491054
| (
1050-
ScriptType::P2trMusig2,
1055+
ScriptType::P2trLegacyScriptPath,
1056+
PsbtFinalInputFixture::P2trLegacy(_)
1057+
)
1058+
| (
1059+
ScriptType::P2trMusig2ScriptPath,
10511060
PsbtFinalInputFixture::P2trMusig2ScriptPath(_)
10521061
)
10531062
| (
1054-
ScriptType::TaprootKeypath,
1063+
ScriptType::P2trMusig2TaprootKeypath,
10551064
PsbtFinalInputFixture::P2trMusig2KeyPath(_)
10561065
)
10571066
)
@@ -1064,7 +1073,9 @@ impl ScriptType {
10641073
pub fn is_taproot(&self) -> bool {
10651074
matches!(
10661075
self,
1067-
ScriptType::P2tr | ScriptType::P2trMusig2 | ScriptType::TaprootKeypath
1076+
ScriptType::P2trLegacyScriptPath
1077+
| ScriptType::P2trMusig2ScriptPath
1078+
| ScriptType::P2trMusig2TaprootKeypath
10681079
)
10691080
}
10701081

@@ -1382,7 +1393,7 @@ mod tests {
13821393

13831394
// Test finding taproot key path finalized input
13841395
let (index, input) = fixture
1385-
.find_finalized_input_with_script_type(ScriptType::TaprootKeypath)
1396+
.find_finalized_input_with_script_type(ScriptType::P2trMusig2TaprootKeypath)
13861397
.expect("Failed to find taproot key path finalized input");
13871398
assert_eq!(index, 5);
13881399
assert!(matches!(input, PsbtFinalInputFixture::P2trMusig2KeyPath(_)));

0 commit comments

Comments
 (0)