blockcypher / blockcypher-python

Python library for the BlockCypher web services

Home Page:https://www.blockcypher.com/dev/bitcoin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'eth' coin_symbol does not work

Blovario opened this issue · comments

Hey, here is the error I got :
Traceback (most recent call last): File "C:\Users\Blovario\Desktop\BOT\BOTGRT\ENGLISH\trojan\walletcheck_eth.py", line 110, in <module> valeur = blockcypher.get_total_balance(eth_list[i],coin_symbol='eth') File "C:\Users\Blovario\AppData\Local\Programs\Python\Python37\lib\site-packages\blockcypher\api.py", line 311, in get_total_balance coin_symbol=coin_symbol, api_key=api_key)['final_balance'] File "C:\Users\Blovario\AppData\Local\Programs\Python\Python37\lib\site-packages\blockcypher\api.py", line 293, in get_address_overview coin_symbol=coin_symbol) AssertionError

I ran into this so I dag into the code.

   ...
    assert is_valid_address_for_coinsymbol(
            b58_address=address,
            coin_symbol=coin_symbol), address


def is_valid_address_for_coinsymbol(b58_address, coin_symbol):
    '''
    Is an address both valid *and* start with the correct character
    for its coin symbol (chain/network)
    '''
    assert is_valid_coin_symbol(coin_symbol)

    # TODO deeper validation of a bech32 address
    if b58_address.startswith(COIN_SYMBOL_MAPPINGS[coin_symbol]['bech32_prefix']):
        return True

    if coin_symbol == 'eth':
        return is_valid_eth_address(b58_address)

def is_valid_eth_address(addr):
    if addr.startswith('0x'):
        addr = addr[2:].strip()

    if len(addr) != 40:
        return False

    return uses_only_hash_chars(addr)

Anyway here is what a call should look like.

    response =  blockcypher.get_address_details(
        "7a498e3a3f42a07d38d235df58a47c21a200c2b9", coin_symbol="eth"
    )

Mhm I see, so we need to put the address in lowercase and remove first two "0x" chars
Thanks !