coinaddr
coinaddr copied to clipboard
Exception when wrong network
Hi, thanks for useful library.
One issue, when checking address with wrong currency, we have exception due to strong typing. Here:
@property
def network(self):
"""Return network derived from network version bytes."""
abytes = base58check.b58decode(
self.request.address, **self.request.extras)
nbyte = abytes[0]
for name, networks in self.request.currency.networks.items():
if nbyte in networks:
return name
In case of wrong networks you return None, but expecting string. So we have valid=False and exception.
P.S. more currency structures you can find here: https://github.com/ognus/wallet-address-validator/blob/master/src/currencies.js
Yeah the function should end with:
return ''
To return an empty network string for when the address is invalid. Seems almost all bug reports are about this same issue.