From 8a06c0fb8a049178d2392f6ce9dd08e4ed04fe7d Mon Sep 17 00:00:00 2001 From: meherett Date: Sun, 15 Dec 2024 14:04:41 +0300 Subject: [PATCH] Add: wif_prefix parameter on init HD class --- clients/bip32.py | 2 +- clients/bip44.py | 15 +++++++++++---- clients/bip49.py | 15 +++++++++++---- clients/bip84.py | 15 +++++++++++---- clients/bip86.py | 15 +++++++++++---- 5 files changed, 45 insertions(+), 17 deletions(-) diff --git a/clients/bip32.py b/clients/bip32.py index 7d2dcc4..dd9f076 100644 --- a/clients/bip32.py +++ b/clients/bip32.py @@ -37,7 +37,7 @@ # Initialize BIP32 HD bip32_hd: BIP32HD = BIP32HD( - ecc=Cryptocurrency.ECC + ecc=Cryptocurrency.ECC, wif_prefix=Cryptocurrency.NETWORKS.MAINNET.WIF_PREFIX ) # Update BIP32 HD root keys from seed bip32_hd.from_seed( diff --git a/clients/bip44.py b/clients/bip44.py index 52a41e9..588fff2 100644 --- a/clients/bip44.py +++ b/clients/bip44.py @@ -8,7 +8,9 @@ ) from hdwallet.seeds.bip39 import BIP39Seed from hdwallet.cryptocurrencies import Bitcoin as Cryptocurrency -from hdwallet.derivations import BIP44Derivation +from hdwallet.derivations import ( + BIP44Derivation, CHANGES +) from hdwallet.hds import BIP44HD @@ -37,7 +39,12 @@ # Initialize BIP44 HD bip44_hd: BIP44HD = BIP44HD( - ecc=Cryptocurrency.ECC, coin_type=Cryptocurrency.COIN_TYPE, account=0, change="external-chain", address=0 + ecc=Cryptocurrency.ECC, + wif_prefix=Cryptocurrency.NETWORKS.MAINNET.WIF_PREFIX, + coin_type=Cryptocurrency.COIN_TYPE, + account=0, + change=CHANGES.EXTERNAL_CHAIN, + address=0 ) # Update BIP44 HD root keys from seed bip44_hd.from_seed( @@ -57,7 +64,7 @@ coin_type=Cryptocurrency.COIN_TYPE ) bip44_derivation.from_account(account=0) -bip44_derivation.from_change(change="internal-chain") +bip44_derivation.from_change(change=CHANGES.INTERNAL_CHAIN) bip44_derivation.from_address(address=0) # Update current BIP44 HD derivation @@ -67,7 +74,7 @@ # Or update current BIP44 HD derivation by changing indexes # bip44_hd.from_coin_type(coin_type=Cryptocurrency.COIN_TYPE) # bip44_hd.from_account(account=0) -# bip44_hd.from_change(change="internal-chain") +# bip44_hd.from_change(change=CHANGES.INTERNAL_CHAIN) # bip44_hd.from_address(address=0) # Dump derived keys diff --git a/clients/bip49.py b/clients/bip49.py index 0e2daf9..94032f5 100644 --- a/clients/bip49.py +++ b/clients/bip49.py @@ -8,7 +8,9 @@ ) from hdwallet.seeds.bip39 import BIP39Seed from hdwallet.cryptocurrencies import Bitcoin as Cryptocurrency -from hdwallet.derivations import BIP49Derivation +from hdwallet.derivations import ( + BIP49Derivation, CHANGES +) from hdwallet.hds import BIP49HD @@ -37,7 +39,12 @@ # Initialize BIP49 HD bip49_hd: BIP49HD = BIP49HD( - ecc=Cryptocurrency.ECC, coin_type=Cryptocurrency.COIN_TYPE, account=0, change="external-chain", address=0 + ecc=Cryptocurrency.ECC, + wif_prefix=Cryptocurrency.NETWORKS.MAINNET.WIF_PREFIX, + coin_type=Cryptocurrency.COIN_TYPE, + account=0, + change=CHANGES.EXTERNAL_CHAIN, + address=0 ) # Update BIP49 HD root keys from seed bip49_hd.from_seed( @@ -57,7 +64,7 @@ coin_type=Cryptocurrency.COIN_TYPE ) bip49_derivation.from_account(account=0) -bip49_derivation.from_change(change="internal-chain") +bip49_derivation.from_change(change=CHANGES.INTERNAL_CHAIN) bip49_derivation.from_address(address=0) # Update current BIP49 HD derivation @@ -67,7 +74,7 @@ # Or update current BIP49 HD derivation by changing indexes # bip49_hd.from_coin_type(coin_type=Cryptocurrency.COIN_TYPE) # bip49_hd.from_account(account=0) -# bip49_hd.from_change(change="internal-chain") +# bip49_hd.from_change(change=CHANGES.INTERNAL_CHAIN) # bip49_hd.from_address(address=0) # Dump derived keys diff --git a/clients/bip84.py b/clients/bip84.py index c378b12..cee947b 100644 --- a/clients/bip84.py +++ b/clients/bip84.py @@ -8,7 +8,9 @@ ) from hdwallet.seeds.bip39 import BIP39Seed from hdwallet.cryptocurrencies import Bitcoin as Cryptocurrency -from hdwallet.derivations import BIP84Derivation +from hdwallet.derivations import ( + BIP84Derivation, CHANGES +) from hdwallet.hds import BIP84HD @@ -37,7 +39,12 @@ # Initialize BIP84 HD bip84_hd: BIP84HD = BIP84HD( - ecc=Cryptocurrency.ECC, coin_type=Cryptocurrency.COIN_TYPE, account=0, change="external-chain", address=0 + ecc=Cryptocurrency.ECC, + wif_prefix=Cryptocurrency.NETWORKS.MAINNET.WIF_PREFIX, + coin_type=Cryptocurrency.COIN_TYPE, + account=0, + change=CHANGES.EXTERNAL_CHAIN, + address=0 ) # Update BIP84 HD root keys from seed bip84_hd.from_seed( @@ -57,7 +64,7 @@ coin_type=Cryptocurrency.COIN_TYPE ) bip84_derivation.from_account(account=0) -bip84_derivation.from_change(change="internal-chain") +bip84_derivation.from_change(change=CHANGES.INTERNAL_CHAIN) bip84_derivation.from_address(address=0) # Update current BIP84 HD derivation @@ -67,7 +74,7 @@ # Or update current BIP84 HD derivation by changing indexes # bip84_hd.from_coin_type(coin_type=Cryptocurrency.COIN_TYPE) # bip84_hd.from_account(account=0) -# bip84_hd.from_change(change="internal-chain") +# bip84_hd.from_change(change=CHANGES.INTERNAL_CHAIN) # bip84_hd.from_address(address=0) # Dump derived keys diff --git a/clients/bip86.py b/clients/bip86.py index 296d086..ea1085c 100644 --- a/clients/bip86.py +++ b/clients/bip86.py @@ -8,7 +8,9 @@ ) from hdwallet.seeds.bip39 import BIP39Seed from hdwallet.cryptocurrencies import Bitcoin as Cryptocurrency -from hdwallet.derivations import BIP86Derivation +from hdwallet.derivations import ( + BIP86Derivation, CHANGES +) from hdwallet.hds import BIP86HD @@ -37,7 +39,12 @@ # Initialize BIP86 HD bip86_hd: BIP86HD = BIP86HD( - ecc=Cryptocurrency.ECC, coin_type=Cryptocurrency.COIN_TYPE, account=0, change="external-chain", address=0 + ecc=Cryptocurrency.ECC, + wif_prefix=Cryptocurrency.NETWORKS.MAINNET.WIF_PREFIX, + coin_type=Cryptocurrency.COIN_TYPE, + account=0, + change=CHANGES.EXTERNAL_CHAIN, + address=0 ) # Update BIP86 HD root keys from seed bip86_hd.from_seed( @@ -57,7 +64,7 @@ coin_type=Cryptocurrency.COIN_TYPE ) bip86_derivation.from_account(account=0) -bip86_derivation.from_change(change="external-chain") +bip86_derivation.from_change(change=CHANGES.INTERNAL_CHAIN) bip86_derivation.from_address(address=1) # Update current BIP86 HD derivation @@ -67,7 +74,7 @@ # Or update current BIP86 HD derivation by changing indexes # bip86_hd.from_coin_type(coin_type=Cryptocurrency.COIN_TYPE) # bip86_hd.from_account(account=0) -# bip86_hd.from_change(change="internal-chain") +# bip86_hd.from_change(change=CHANGES.INTERNAL_CHAIN) # bip86_hd.from_address(address=0) # Dump derived keys