Skip to content

Commit

Permalink
Merge pull request #30 from cheeseandcereal/remove_pywallet
Browse files Browse the repository at this point in the history
Remove pywallet and replace with pycoin for bip32
  • Loading branch information
sammchardy committed Apr 29, 2021
2 parents 12c32ea + 3792a8b commit 57f84f7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions binance_chain/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from secp256k1 import PrivateKey
from mnemonic import Mnemonic
from pywallet.utils.bip32 import Wallet as Bip32Wallet
from pycoin.symbols.btc import network

from binance_chain.utils.segwit_addr import address_from_public_key, decode_address
from binance_chain.environment import BinanceEnvironment
Expand Down Expand Up @@ -131,9 +131,11 @@ def create_wallet_from_mnemonic(cls, mnemonic: str, env: Optional[BinanceEnviron
:return:
"""
seed = Mnemonic.to_seed(mnemonic)
new_wallet = Bip32Wallet.from_master_secret(seed=seed, network='BTC')
child = new_wallet.get_child_for_path(Wallet.HD_PATH)
return cls(child.get_private_key_hex().decode(), env=env)
parent_wallet = network.keys.bip32_seed(seed)
child_wallet = parent_wallet.subkey_for_path(Wallet.HD_PATH)
# convert secret exponent (private key) int to hex
key_hex = format(child_wallet.secret_exponent(), 'x')
return cls(key_hex, env=env)

@property
def private_key(self):
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pywallet>=0.1.0
pycoin>=0.90.20201031
requests>=2.21.0
aiohttp>=3.5.4
websockets>=7.0
secp256k1>=0.13.2
mnemonic>=0.18
protobuf>=3.6.1
protobuf>=3.6.1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def find_version(*file_paths):
def install_requires():

requires = [
'pywallet>=0.1.0', 'requests>=2.21.0', 'websockets>=7.0', 'aiohttp>=3.5.4',
'pycoin>=0.90.20201031', 'requests>=2.21.0', 'websockets>=7.0', 'aiohttp>=3.5.4',
'secp256k1>=0.13.2', 'protobuf>=3.6.1', 'mnemonic>=0.18', 'ujson>=1.35'
]
return requires
Expand Down

0 comments on commit 57f84f7

Please sign in to comment.