Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.10.4 | AttributeError: 'mpz' object has no attribute 'to_bytes' #31

Open
Alkia opened this issue Apr 24, 2022 · 1 comment
Open

Comments

@Alkia
Copy link

Alkia commented Apr 24, 2022

Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32

from cosmospy import BIP32DerivationError, seed_to_privkey

seed = ("angry mouse")

try:

privkey = seed_to_privkey(seed,"m/44'/118'/1'/0/0")

except BIP32DerivationError:

print("No valid private key in this derivation path!")

AttributeError Traceback (most recent call last)
in
9 seed = ("angry mouse")
10 try:
---> 11 privkey = seed_to_privkey(seed,"m/44'/118'/2'/0/0")
12 except BIP32DerivationError:
13 print("No valid private key in this derivation path!")

C:\ProgramData\Anaconda3\lib\site-packages\cosmospy_wallet.py in seed_to_privkey(seed, path)
45 # This can raise a hdwallets.BIP32DerivationError (which we alias so
46 # that the same exception type is also in the cosmospy namespace).
---> 47 derived_privkey = hd_wallet.get_privkey_from_path(path)
48
49 return derived_privkey

C:\ProgramData\Anaconda3\lib\site-packages\hdwallets_bip32.py in get_privkey_from_path(self, path)
78 :return: privkey (bytes)
79 """
---> 80 return self.get_extended_privkey_from_path(path)[1]
81
82 def get_extended_pubkey_from_path(

C:\ProgramData\Anaconda3\lib\site-packages\hdwallets_bip32.py in get_extended_privkey_from_path(self, path)
68 assert isinstance(privkey, bytes)
69 for index in path:
---> 70 privkey, chaincode = _derive_private_child(privkey, chaincode, index)
71 return chaincode, privkey
72

C:\ProgramData\Anaconda3\lib\site-packages\hdwallets_utils.py in _derive_private_child(privkey, chaincode, index)
60 f"Invalid private key at index {index}, try the next one!"
61 )
---> 62 secret = k_int.to_bytes(32, "big")
63
64 return secret, payload[32:]

AttributeError: 'mpz' object has no attribute 'to_bytes'

@hukkin
Copy link
Owner

hukkin commented Apr 24, 2022

Thanks for the issue!

It's not very clear to me what your issue is. An 'mpz' object is not part of cosmospy API so I assume this belongs in another issue tracker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants