'checks an address for validity.'

def q_checkaddress(abe, page, chain):

    addr = wsgiref.util.shift_path_info(page['env'])
    if (addr is None):
        return 'Returns    the    version    encoded    in    ADDRESS    as    a    hex    string.\nIf    ADDRESS    is    invalid,    returns    either    X5,    SZ,    or    CK    for    BBE    compatibility.\n/q/checkaddress/ADDRESS\n'
    if util.possible_address(addr):
        (version, hash) = util.decode_address(addr)
        if (util.hash_to_address(version, hash) == addr):
            return version.encode('hex').upper()
        return 'CK'
    if (len(addr) >= 26):
        return 'X5'
    return 'SZ'
