Decode a Base58 encoded string as an integer

def b58decode_int(v):
    '''Decode a Base58 encoded string as an integer'''

    if not isinstance(v, str):
        v = v.decode('ascii')

    decimal = 0
    for char in v:
        decimal = decimal * 58 + alphabet.index(char)
    return decimal