@@ -46,6 +46,7 @@ mod segwitv0;
46
46
mod sh;
47
47
mod sortedmulti;
48
48
mod tr;
49
+
49
50
// Descriptor Exports
50
51
pub use self :: bare:: { Bare , Pkh } ;
51
52
pub use self :: segwitv0:: { Wpkh , Wsh , WshInner } ;
@@ -168,6 +169,9 @@ pub enum Descriptor<Pk: MiniscriptKey> {
168
169
Sh ( Sh < Pk > ) ,
169
170
/// Pay-to-Witness-ScriptHash with Segwitv0 context
170
171
Wsh ( Wsh < Pk > ) ,
172
+ // /// Pay-to-Taproot with Segwitv0 context
173
+ // /// TODO: Update context to Segwitv1
174
+ // Tr(Tr<Pk>)
171
175
}
172
176
173
177
/// Descriptor Type of the descriptor
@@ -193,6 +197,8 @@ pub enum DescriptorType {
193
197
WshSortedMulti ,
194
198
/// Sh Wsh Sorted Multi
195
199
ShWshSortedMulti ,
200
+ // /// Tr Descriptor
201
+ // Tr
196
202
}
197
203
198
204
impl < Pk : MiniscriptKey > Descriptor < Pk > {
@@ -279,6 +285,12 @@ impl<Pk: MiniscriptKey> Descriptor<Pk> {
279
285
Ok ( Descriptor :: Wsh ( Wsh :: new_sortedmulti ( k, pks) ?) )
280
286
}
281
287
288
+ // /// Create new tr descriptor
289
+ // /// Errors when miniscript exceeds resource limits under Segwitv0 context
290
+ // pub fn new_tr(key: Pk, script: Option<tr::TapTree<Pk>>) -> Result<Self, Error> {
291
+ // Ok(Descriptor::Tr(Tr::new(key, script)?))
292
+ // }
293
+
282
294
/// Get the [DescriptorType] of [Descriptor]
283
295
pub fn desc_type ( & self ) -> DescriptorType {
284
296
match * self {
@@ -298,6 +310,7 @@ impl<Pk: MiniscriptKey> Descriptor<Pk> {
298
310
WshInner :: SortedMulti ( ref _smv) => DescriptorType :: WshSortedMulti ,
299
311
WshInner :: Ms ( ref _ms) => DescriptorType :: Wsh ,
300
312
} ,
313
+ // Descriptor::Tr(_) => DescriptorType::Tr,
301
314
}
302
315
}
303
316
}
@@ -624,6 +637,7 @@ serde_string_impl_pk!(Descriptor, "a script descriptor");
624
637
#[ cfg( test) ]
625
638
mod tests {
626
639
use super :: checksum:: desc_checksum;
640
+ use super :: tr:: Tr ;
627
641
use super :: DescriptorTrait ;
628
642
use bitcoin:: blockdata:: opcodes:: all:: { OP_CLTV , OP_CSV } ;
629
643
use bitcoin:: blockdata:: script:: Instruction ;
@@ -1088,6 +1102,30 @@ mod tests {
1088
1102
assert_eq ! ( check, & Ok ( Instruction :: Op ( OP_CSV ) ) )
1089
1103
}
1090
1104
1105
+ #[ test]
1106
+ fn tr_roundtrip_key ( ) {
1107
+ let script = Tr :: < DummyKey > :: from_str ( "tr()" ) . unwrap ( ) . to_string ( ) ;
1108
+ assert_eq ! ( script, format!( "tr()#x4ml3kxd" ) )
1109
+ }
1110
+
1111
+ #[ test]
1112
+ fn tr_roundtrip_script ( ) {
1113
+ let descriptor = Tr :: < DummyKey > :: from_str ( "tr(,{pk(),pk()})" )
1114
+ . unwrap ( )
1115
+ . to_string ( ) ;
1116
+
1117
+ assert_eq ! ( descriptor, "tr(,{pk(),pk()})#7dqr6v8r" )
1118
+ }
1119
+
1120
+ #[ test]
1121
+ fn tr_roundtrip_tree ( ) {
1122
+ let descriptor = Tr :: < DummyKey > :: from_str ( "tr(,{pk(),{pk(),or_d(pk(),pkh())}})" )
1123
+ . unwrap ( )
1124
+ . to_string ( ) ;
1125
+
1126
+ assert_eq ! ( descriptor, "tr(,{pk(),{pk(),or_d(pk(),pkh())}})#39ke346g" )
1127
+ }
1128
+
1091
1129
#[ test]
1092
1130
fn roundtrip_tests ( ) {
1093
1131
let descriptor = Descriptor :: < bitcoin:: PublicKey > :: from_str ( "multi" ) ;
0 commit comments