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.
BitcoinPublicKey("wrong")result:
ValueError: Public key is not in proper formatBitcoinPrivateKey("wrong")result:
AssertionErrorExplanation:
Unless there are some reasons why this has been implemented this way, I believe
BitcoinPrivateKeyshould follow the same behavior ofBitcoinPublicKey.try/exception of invalid keys should look the same, while (as it is now) different exceptions are being presented.
Reason:
While the file
publickey.pypresents aget_public_key_formatfunction (which handles invalid formats with a ValueError), its counterpartget_privkey_formatinmain.pyleaves this job to the functionb58check_to_bin.Possible solution:
the call to
b58check_to_bininget_privkey_formatshould be wrapped in a try block, theAssertionErrorshould be caught and aValueErrorshould be raised instead.Impact:
I have not considered the impact of such a change nor possible regressions.