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

is_valid_address_for_coinsymbol fails for Ethereum addresses with uppercase characters #163

Open
BrynGibson opened this issue May 13, 2024 · 0 comments

Comments

@BrynGibson
Copy link

To replicate:

import blockcypher
eth_addr = '0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed'
blockcypher.get_address_details(address=eth_addr , coin_symbol='eth', api_key=API_KEY)

after doing some digging it appears that is_valid_address_for_coinsymbol calls is_valid_eth_address which in turn calls: uses_only_hash_chars(addr).

uses_only_hash_chars is defined as:

HEX_CHARS_RE = re.compile('^[0-9a-f]*$')

def uses_only_hash_chars(string):
    return bool(HEX_CHARS_RE.match(string))

We could update this by making it a non-case sensitive regex query such as:
HEX_CHARS_RE = re.compile('^[0-9a-f]*$', re.IGNORECASE).

If we detect a mixed case eth address we could also perfom a checksum validation to ensure the address checksum validates before creating an api call. Checksum validation of eth addresses using Python is described here: https://eips.ethereum.org/EIPS/eip-55

Is checksum validation something we should be doing here, or simply adapting the regex to be case insensitive?

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