@@ -46,6 +46,7 @@ mod segwitv0;
4646mod  sh; 
4747mod  sortedmulti; 
4848mod  tr; 
49+ 
4950// Descriptor Exports 
5051pub  use  self :: bare:: { Bare ,  Pkh } ; 
5152pub  use  self :: segwitv0:: { Wpkh ,  Wsh ,  WshInner } ; 
@@ -168,6 +169,9 @@ pub enum Descriptor<Pk: MiniscriptKey> {
168169Sh ( Sh < Pk > ) , 
169170    /// Pay-to-Witness-ScriptHash with Segwitv0 context 
170171Wsh ( Wsh < Pk > ) , 
172+     // /// Pay-to-Taproot with Segwitv0 context 
173+     // /// TODO: Update context to Segwitv1 
174+     // Tr(Tr<Pk>) 
171175} 
172176
173177/// Descriptor Type of the descriptor 
@@ -193,6 +197,8 @@ pub enum DescriptorType {
193197WshSortedMulti , 
194198    /// Sh Wsh Sorted Multi 
195199ShWshSortedMulti , 
200+     // /// Tr Descriptor 
201+     // Tr 
196202} 
197203
198204impl < Pk :  MiniscriptKey >  Descriptor < Pk >  { 
@@ -279,6 +285,12 @@ impl<Pk: MiniscriptKey> Descriptor<Pk> {
279285        Ok ( Descriptor :: Wsh ( Wsh :: new_sortedmulti ( k,  pks) ?) ) 
280286    } 
281287
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+ 
282294    /// Get the [DescriptorType] of [Descriptor] 
283295pub  fn  desc_type ( & self )  -> DescriptorType  { 
284296        match  * self  { 
@@ -298,6 +310,7 @@ impl<Pk: MiniscriptKey> Descriptor<Pk> {
298310                WshInner :: SortedMulti ( ref  _smv)  => DescriptorType :: WshSortedMulti , 
299311                WshInner :: Ms ( ref  _ms)  => DescriptorType :: Wsh , 
300312            } , 
313+             // Descriptor::Tr(_) => DescriptorType::Tr, 
301314        } 
302315    } 
303316} 
@@ -624,6 +637,7 @@ serde_string_impl_pk!(Descriptor, "a script descriptor");
624637#[ cfg( test) ]  
625638mod  tests { 
626639    use  super :: checksum:: desc_checksum; 
640+     use  super :: tr:: Tr ; 
627641    use  super :: DescriptorTrait ; 
628642    use  bitcoin:: blockdata:: opcodes:: all:: { OP_CLTV ,  OP_CSV } ; 
629643    use  bitcoin:: blockdata:: script:: Instruction ; 
@@ -1088,6 +1102,30 @@ mod tests {
10881102        assert_eq ! ( check,  & Ok ( Instruction :: Op ( OP_CSV ) ) ) 
10891103    } 
10901104
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+ 
10911129    #[ test]  
10921130    fn  roundtrip_tests ( )  { 
10931131        let  descriptor = Descriptor :: < bitcoin:: PublicKey > :: from_str ( "multi" ) ; 
0 commit comments