@@ -47,8 +47,8 @@ mod sh;
47
47
mod sortedmulti;
48
48
// Descriptor Exports
49
49
pub use self :: bare:: { Bare , Pkh } ;
50
- pub use self :: segwitv0:: { Wpkh , Wsh } ;
51
- pub use self :: sh:: Sh ;
50
+ pub use self :: segwitv0:: { Wpkh , Wsh , WshInner } ;
51
+ pub use self :: sh:: { Sh , ShInner } ;
52
52
pub use self :: sortedmulti:: SortedMultiVec ;
53
53
54
54
mod checksum;
@@ -168,6 +168,31 @@ pub enum Descriptor<Pk: MiniscriptKey> {
168
168
Wsh ( Wsh < Pk > ) ,
169
169
}
170
170
171
+ /// Descriptor Type of the descriptor
172
+ #[ derive( Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash , Debug ) ]
173
+ pub enum DescriptorType {
174
+ /// Bare descriptor(Contains the native P2pk)
175
+ Bare ,
176
+ /// Pure Sh Descriptor. Does not contain nested Wsh/Wpkh
177
+ Sh ,
178
+ /// Pkh Descriptor
179
+ Pkh ,
180
+ /// Wpkh Descriptor
181
+ Wpkh ,
182
+ /// Wsh
183
+ Wsh ,
184
+ /// Sh Wrapped Wsh
185
+ ShWsh ,
186
+ /// Sh wrapped Wpkh
187
+ ShWpkh ,
188
+ /// Sh Sorted Multi
189
+ ShSortedMulti ,
190
+ /// Wsh Sorted Multi
191
+ WshSortedMulti ,
192
+ /// Sh Wsh Sorted Multi
193
+ ShWshSortedMulti ,
194
+ }
195
+
171
196
impl < Pk : MiniscriptKey > Descriptor < Pk > {
172
197
// Keys
173
198
@@ -251,6 +276,28 @@ impl<Pk: MiniscriptKey> Descriptor<Pk> {
251
276
pub fn new_wsh_sortedmulti ( k : usize , pks : Vec < Pk > ) -> Result < Self , Error > {
252
277
Ok ( Descriptor :: Wsh ( Wsh :: new_sortedmulti ( k, pks) ?) )
253
278
}
279
+
280
+ /// Get the [DescriptorType] of [Descriptor]
281
+ pub fn desc_type ( & self ) -> DescriptorType {
282
+ match * self {
283
+ Descriptor :: Bare ( ref _bare) => DescriptorType :: Bare ,
284
+ Descriptor :: Pkh ( ref _pkh) => DescriptorType :: Pkh ,
285
+ Descriptor :: Wpkh ( ref _wpkh) => DescriptorType :: Wpkh ,
286
+ Descriptor :: Sh ( ref sh) => match sh. as_inner ( ) {
287
+ ShInner :: Wsh ( ref wsh) => match wsh. as_inner ( ) {
288
+ WshInner :: SortedMulti ( ref _smv) => DescriptorType :: ShWshSortedMulti ,
289
+ WshInner :: Ms ( ref _ms) => DescriptorType :: ShWsh ,
290
+ } ,
291
+ ShInner :: Wpkh ( ref _wpkh) => DescriptorType :: ShWpkh ,
292
+ ShInner :: SortedMulti ( ref _smv) => DescriptorType :: ShSortedMulti ,
293
+ ShInner :: Ms ( ref _ms) => DescriptorType :: Sh ,
294
+ } ,
295
+ Descriptor :: Wsh ( ref wsh) => match wsh. as_inner ( ) {
296
+ WshInner :: SortedMulti ( ref _smv) => DescriptorType :: WshSortedMulti ,
297
+ WshInner :: Ms ( ref _ms) => DescriptorType :: Wsh ,
298
+ } ,
299
+ }
300
+ }
254
301
}
255
302
256
303
impl < P : MiniscriptKey , Q : MiniscriptKey > TranslatePk < P , Q > for Descriptor < P > {
0 commit comments