1212from typing import Optional
1313
1414from hdwallet import HDWallet as ext_HDWallet # type: ignore
15- from hdwallet .symbols import BTC , BTCTEST # type: ignore
15+ from hdwallet .cryptocurrencies import Bitcoin
16+ from hdwallet .derivations import CustomDerivation
17+ from hdwallet .hds import BIP32HD
18+ from hdwallet .mnemonics import BIP39Mnemonic
1619
1720from bitcoinutils .setup import is_mainnet
1821from bitcoinutils .keys import PrivateKey
@@ -40,20 +43,14 @@ def __init__(
4043 ):
4144 """Instantiate a hdwallet object using the corresponding library with BTC"""
4245
43- symbol = None
44- if is_mainnet ():
45- symbol = BTC
46- else :
47- symbol = BTCTEST
48-
49- self .hdw = ext_HDWallet (symbol )
46+ self .hdw = ext_HDWallet (cryptocurrency = Bitcoin , network = 'mainnet' if is_mainnet () else 'testnet' , hd = BIP32HD )
5047
5148 if mnemonic :
52- self .hdw .from_mnemonic (mnemonic = mnemonic )
49+ self .hdw .from_mnemonic (mnemonic = BIP39Mnemonic ( mnemonic = mnemonic ) )
5350
5451 if xprivate_key and path :
5552 self .hdw .from_xprivate_key (xprivate_key = xprivate_key )
56- self .hdw .from_path ( path = path )
53+ self .hdw .from_derivation ( CustomDerivation ( path ) )
5754
5855 @classmethod
5956 def from_mnemonic (cls , mnemonic : str ):
@@ -72,7 +69,7 @@ def from_path(self, path: str):
7269 """Set/update the path"""
7370
7471 self .hdw .clean_derivation () # type: ignore
75- self .hdw .from_path ( path = path )
72+ self .hdw .from_derivation ( CustomDerivation ( path ) )
7673
7774 def get_private_key (self ):
7875 """Return a PrivateKey object used throughout bitcoinutils library"""
0 commit comments