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

Inconsistent management of invalid values in BitcoinPrivateKey #48

Open
Saturnix opened this issue Dec 30, 2015 · 0 comments
Open

Inconsistent management of invalid values in BitcoinPrivateKey #48

Saturnix opened this issue Dec 30, 2015 · 0 comments

Comments

@Saturnix
Copy link

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.

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

1 participant