17
17
use std:: collections:: { BTreeMap , HashMap , HashSet } ;
18
18
use std:: ops:: Deref ;
19
19
20
- use bitcoin:: util:: bip32:: {
21
- ChildNumber , DerivationPath , ExtendedPrivKey , ExtendedPubKey , Fingerprint , KeySource ,
22
- } ;
20
+ use bitcoin:: util:: bip32:: { ChildNumber , DerivationPath , ExtendedPubKey , Fingerprint , KeySource } ;
23
21
use bitcoin:: util:: psbt;
24
22
use bitcoin:: { Network , PublicKey , Script , TxOut } ;
25
23
26
- use miniscript:: descriptor:: { DescriptorPublicKey , DescriptorType , DescriptorXKey , Wildcard } ;
24
+ use miniscript:: descriptor:: {
25
+ DescriptorPublicKey , DescriptorType , DescriptorXKey , InnerXKey , Wildcard ,
26
+ } ;
27
27
pub use miniscript:: { descriptor:: KeyMap , Descriptor , Legacy , Miniscript , ScriptContext , Segwitv0 } ;
28
28
use miniscript:: { DescriptorTrait , ForEachKey , TranslatePk } ;
29
29
@@ -267,41 +267,10 @@ pub(crate) trait XKeyUtils {
267
267
fn root_fingerprint ( & self , secp : & SecpCtx ) -> Fingerprint ;
268
268
}
269
269
270
- // FIXME: `InnerXKey` was made private in rust-miniscript, so we have to implement this manually on
271
- // both `ExtendedPubKey` and `ExtendedPrivKey`.
272
- //
273
- // Revert back to using the trait once https://github.com/rust-bitcoin/rust-miniscript/pull/230 is
274
- // released
275
- impl XKeyUtils for DescriptorXKey < ExtendedPubKey > {
276
- fn full_path ( & self , append : & [ ChildNumber ] ) -> DerivationPath {
277
- let full_path = match self . origin {
278
- Some ( ( _, ref path) ) => path
279
- . into_iter ( )
280
- . chain ( self . derivation_path . into_iter ( ) )
281
- . cloned ( )
282
- . collect ( ) ,
283
- None => self . derivation_path . clone ( ) ,
284
- } ;
285
-
286
- if self . wildcard != Wildcard :: None {
287
- full_path
288
- . into_iter ( )
289
- . chain ( append. iter ( ) )
290
- . cloned ( )
291
- . collect ( )
292
- } else {
293
- full_path
294
- }
295
- }
296
-
297
- fn root_fingerprint ( & self , _: & SecpCtx ) -> Fingerprint {
298
- match self . origin {
299
- Some ( ( fingerprint, _) ) => fingerprint,
300
- None => self . xkey . fingerprint ( ) ,
301
- }
302
- }
303
- }
304
- impl XKeyUtils for DescriptorXKey < ExtendedPrivKey > {
270
+ impl < T > XKeyUtils for DescriptorXKey < T >
271
+ where
272
+ T : InnerXKey ,
273
+ {
305
274
fn full_path ( & self , append : & [ ChildNumber ] ) -> DerivationPath {
306
275
let full_path = match self . origin {
307
276
Some ( ( _, ref path) ) => path
@@ -326,7 +295,7 @@ impl XKeyUtils for DescriptorXKey<ExtendedPrivKey> {
326
295
fn root_fingerprint ( & self , secp : & SecpCtx ) -> Fingerprint {
327
296
match self . origin {
328
297
Some ( ( fingerprint, _) ) => fingerprint,
329
- None => self . xkey . fingerprint ( secp) ,
298
+ None => self . xkey . xkey_fingerprint ( secp) ,
330
299
}
331
300
}
332
301
}
0 commit comments