You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 26, 2025. It is now read-only.
BitcoinPublicKey("wrong")
result: ValueError: Public key is not in proper format
BitcoinPrivateKey("wrong")
result: AssertionError
Explanation:
Unless there are some reasons why this has been implemented this way, I believe BitcoinPrivateKey should follow the same behavior of BitcoinPublicKey.
try/exception of invalid keys should look the same, while (as it is now) different exceptions are being presented.
Reason:
While the file publickey.py presents a get_public_key_format function (which handles invalid formats with a ValueError), its counterpart get_privkey_format in main.py leaves this job to the function b58check_to_bin.
Possible solution:
the call to b58check_to_bin in get_privkey_format should be wrapped in a try block, the AssertionError should be caught and a ValueError should be raised instead.
Impact:
I have not considered the impact of such a change nor possible regressions.