coinaddr icon indicating copy to clipboard operation
coinaddr copied to clipboard

Exception when wrong network

Open delchiv opened this issue 6 years ago • 1 comments

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

delchiv avatar Apr 30 '18 11:04 delchiv

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.

tarceri avatar Feb 19 '21 05:02 tarceri