Skip to content

Commit 862ae60

Browse files
committed
Merge branch 'feature/seeds' into python-slip39
2 parents fd10274 + 51723f8 commit 862ae60

File tree

242 files changed

+955
-724
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

242 files changed

+955
-724
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ experiment/
1212
# Setuptools stuff
1313
build/
1414
dist/
15-
hdwallet.egg-info/
15+
hdwallet*.egg-info/
1616

1717
# Python stuff
1818
__pycache__/

clients/brave_legacy.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from hdwallet import HDWallet
44
from hdwallet.mnemonics import BIP39Mnemonic
5-
from hdwallet.seeds import BIP39Seed
5+
from hdwallet.seeds import BIP39Seed, SLIP39Seed
66
from hdwallet.cryptocurrencies import Ethereum as Cryptocurrency
77
from hdwallet.hds import BIP44HD
88
from hdwallet.derivations import (
@@ -15,14 +15,14 @@
1515
MNEMONIC: str = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon " \
1616
"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art"
1717

18-
# Initialize Ethereum HDWallet
18+
# Initialize Ethereum HDWallet using BIP-39 Entropy as Seed
1919
hdwallet: HDWallet = HDWallet(
2020
cryptocurrency=Cryptocurrency,
2121
hd=BIP44HD,
2222
network=Cryptocurrency.NETWORKS.MAINNET,
2323
passphrase=None
2424
).from_seed( # Get Ethereum HDWallet from seed
25-
seed=BIP39Seed(
25+
seed=SLIP39Seed(
2626
seed=BIP39Mnemonic.decode(mnemonic=MNEMONIC) # Use decoded mnemonic (entropy) directly as seed
2727
)
2828
).from_derivation( # Drive from BIP44 derivation
@@ -36,4 +36,28 @@
3636

3737
# Same address of Brave crypto wallets extension
3838
# print(json.dumps(hdwallet.dump(exclude={"indexes"}), indent=4, ensure_ascii=False))
39+
print(f"Path: {hdwallet.path()}")
3940
print(f"Address: {hdwallet.address()}")
41+
42+
assert hdwallet.address() == "0xACA6302EcBde40120cb8A08361D8BD461282Bd18"
43+
44+
# Initialize Ethereum HDWallet using BIP-39 Seed (confirmed current Brave Wallet behavior)
45+
hdwallet: HDWallet = HDWallet(
46+
cryptocurrency=Cryptocurrency,
47+
hd=BIP44HD,
48+
network=Cryptocurrency.NETWORKS.MAINNET,
49+
passphrase=None
50+
).from_seed( # Get Ethereum HDWallet from seed
51+
seed=BIP39Seed.from_mnemonic(mnemonic=MNEMONIC) # Use BIP-39 encoded mnemonic as seed
52+
).from_derivation( # Drive from BIP44 derivation
53+
derivation=BIP44Derivation(
54+
coin_type=Cryptocurrency.COIN_TYPE,
55+
account=0,
56+
change=CHANGES.EXTERNAL_CHAIN,
57+
address=0
58+
)
59+
)
60+
61+
# print(json.dumps(hdwallet.dump(exclude={"indexes"}), indent=4, ensure_ascii=False))
62+
print(f"Address: {hdwallet.address()}")
63+
assert hdwallet.address() == "0xF278cF59F82eDcf871d630F28EcC8056f25C1cdb"

clients/cardano/byron_icarus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
seed: str = CardanoSeed.from_mnemonic(
3939
mnemonic=bip39_mnemonic, cardano_type=Cardano.TYPES.BYRON_ICARUS
4040
)
41-
cardano_seed: CardanoSeed = CardanoSeed(seed=seed)
41+
cardano_seed: CardanoSeed = CardanoSeed(seed=seed, cardano_type=Cardano.TYPES.BYRON_ICARUS)
4242

4343
# Update Byron-Icarus Cardano HD root keys from seed
4444
cardano_hd.from_seed(

clients/cardano/byron_ledger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
seed: str = CardanoSeed.from_mnemonic(
3939
mnemonic=bip39_mnemonic, cardano_type=Cardano.TYPES.BYRON_LEDGER
4040
)
41-
cardano_seed: CardanoSeed = CardanoSeed(seed=seed)
41+
cardano_seed: CardanoSeed = CardanoSeed(seed=seed, cardano_type=Cardano.TYPES.BYRON_LEDGER)
4242

4343
# Update Byron-Ledger Cardano HD root keys from seed
4444
cardano_hd.from_seed(

clients/cardano/byron_legacy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
seed: str = CardanoSeed.from_mnemonic(
3939
mnemonic=bip39_mnemonic, cardano_type=Cardano.TYPES.BYRON_LEGACY
4040
)
41-
cardano_seed: CardanoSeed = CardanoSeed(seed=seed)
41+
cardano_seed: CardanoSeed = CardanoSeed(seed=seed, cardano_type=Cardano.TYPES.BYRON_LEGACY)
4242

4343
# Update Byron-Legacy Cardano HD root keys from seed
4444
cardano_hd.from_seed(

clients/cardano/shelley_icarus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
seed: str = CardanoSeed.from_mnemonic(
4040
mnemonic=bip39_mnemonic, cardano_type=Cardano.TYPES.SHELLEY_ICARUS
4141
)
42-
cardano_seed: CardanoSeed = CardanoSeed(seed=seed)
42+
cardano_seed: CardanoSeed = CardanoSeed(seed=seed, cardano_type=Cardano.TYPES.SHELLEY_ICARUS)
4343

4444
# Update Shelley-Icarus Cardano HD root keys from seed
4545
cardano_hd.from_seed(

clients/cardano/shelley_ledger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
seed: str = CardanoSeed.from_mnemonic(
4040
mnemonic=bip39_mnemonic, cardano_type=Cardano.TYPES.SHELLEY_LEDGER
4141
)
42-
cardano_seed: CardanoSeed = CardanoSeed(seed=seed)
42+
cardano_seed: CardanoSeed = CardanoSeed(seed=seed, cardano_type=Cardano.TYPES.SHELLEY_LEDGER)
4343

4444
# Update Shelley-Ledger Cardano HD root keys from seed
4545
cardano_hd.from_seed(

examples/hdwallet/algorand/from_seed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
hd=AlgorandHD
1515
).from_seed(
1616
seed=AlgorandSeed(
17-
seed="fca87b68fdffa968895901c894f678f6"
17+
seed="a27436e742dafe27428b84925d4be6a1c40856d14dc73d54431a94bd6b95264b"
1818
)
1919
).from_derivation(
2020
derivation=CustomDerivation(

examples/hdwallet/cardano/from_entropy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
).from_entropy(
2525
entropy=BIP39Entropy(
2626
entropy=BIP39Entropy.generate(
27-
strength=BIP39_ENTROPY_STRENGTHS.TWO_HUNDRED_TWENTY_FOUR
27+
strength=BIP39_ENTROPY_STRENGTHS.ONE_HUNDRED_TWENTY_EIGHT
2828
)
2929
)
3030
).from_derivation(

examples/hdwallet/cardano/from_seed.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
passphrase="talonlab"
2121
).from_seed(
2222
seed=CardanoSeed(
23-
seed="fca87b68fdffa968895901c894f678f6"
23+
seed="fca87b68fdffa968895901c894f678f6",
24+
cardano_type=Cryptocurrency.TYPES.SHELLEY_ICARUS,
2425
)
2526
).from_derivation(
2627
derivation=CIP1852Derivation(

0 commit comments

Comments
 (0)