11use crate :: error:: { Bip32Error , Bip39Error , DescriptorKeyError } ;
2+ use crate :: { impl_from_core_type, impl_into_core_type} ;
23
3- use bdk_wallet:: bitcoin:: Network ;
44use bdk_wallet:: bitcoin:: bip32:: DerivationPath as BdkDerivationPath ;
55use bdk_wallet:: bitcoin:: key:: Secp256k1 ;
66use bdk_wallet:: bitcoin:: secp256k1:: rand;
77use bdk_wallet:: bitcoin:: secp256k1:: rand:: Rng ;
8+ use bdk_wallet:: bitcoin:: Network ;
89use bdk_wallet:: keys:: bip39:: WordCount ;
910use bdk_wallet:: keys:: bip39:: { Language , Mnemonic as BdkMnemonic } ;
1011use bdk_wallet:: keys:: {
1112 DerivableKey , DescriptorPublicKey as BdkDescriptorPublicKey ,
1213 DescriptorSecretKey as BdkDescriptorSecretKey , ExtendedKey , GeneratableKey , GeneratedKey ,
1314} ;
14- use bdk_wallet:: miniscript:: BareCtx ;
1515use bdk_wallet:: miniscript:: descriptor:: { DescriptorXKey , Wildcard } ;
16+ use bdk_wallet:: miniscript:: BareCtx ;
1617
1718use std:: fmt:: Display ;
1819use std:: str:: FromStr ;
@@ -64,7 +65,7 @@ impl Display for Mnemonic {
6465}
6566
6667/// A BIP-32 derivation path.
67- #[ derive( uniffi:: Object ) ]
68+ #[ derive( Clone , Debug , Hash , Eq , PartialEq , uniffi:: Object ) ]
6869pub struct DerivationPath ( pub ( crate ) BdkDerivationPath ) ;
6970
7071#[ uniffi:: export]
@@ -80,40 +81,34 @@ impl DerivationPath {
8081 /// Returns derivation path for a master key (i.e. empty derivation path)
8182 #[ uniffi:: constructor]
8283 pub fn master ( ) -> Arc < Self > {
83- Arc :: new ( DerivationPath {
84- inner_mutex : Mutex :: new ( BdkDerivationPath :: master ( ) ) ,
85- } )
84+ Arc :: new ( BdkDerivationPath :: master ( ) . into ( ) )
8685 }
8786
8887 /// Returns whether derivation path represents master key (i.e. it's length
8988 /// is empty). True for `m` path.
9089 pub fn is_master ( & self ) -> bool {
91- self . get_derivation_path ( ) . is_master ( )
90+ self . 0 . is_master ( )
9291 }
9392
9493 /// Returns length of the derivation path
9594 pub fn len ( & self ) -> u64 {
96- self . get_derivation_path ( ) . len ( ) as u64
95+ self . 0 . len ( ) as u64
9796 }
9897
9998 /// Returns `true` if the derivation path is empty
10099 pub fn is_empty ( & self ) -> bool {
101- self . get_derivation_path ( ) . is_empty ( )
100+ self . 0 . is_empty ( )
102101 }
103102}
104103
105104impl Display for DerivationPath {
106105 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
107- let path = self . get_derivation_path ( ) ;
108- write ! ( f, "{}" , path)
106+ write ! ( f, "{}" , self . 0 )
109107 }
110108}
111109
112- impl DerivationPath {
113- pub ( crate ) fn get_derivation_path ( & self ) -> MutexGuard < ' _ , BdkDerivationPath > {
114- self . inner_mutex . lock ( ) . expect ( "derivation path" )
115- }
116- }
110+ impl_from_core_type ! ( BdkDerivationPath , DerivationPath ) ;
111+ impl_into_core_type ! ( DerivationPath , BdkDerivationPath ) ;
117112
118113/// A descriptor containing secret data.
119114#[ derive( Debug , uniffi:: Object ) ]
0 commit comments