'returns an address\'s firstbits.'

def q_fb(abe, page, chain):

    if (not abe.store.use_firstbits):
        raise PageNotFound()
    addr = wsgiref.util.shift_path_info(page['env'])
    if (addr is None):
        return "Shows    ADDRESS's    firstbits:    the    shortest    initial    substring    that    uniquely    and    case-insensitively    distinguishes    ADDRESS    from    all    others    first    appearing    before    it    or    in    the    same    block.\nSee    http://firstbits.com/.\nReturns    empty    if    ADDRESS    has    no    firstbits.\n/chain/CHAIN/q/fb/ADDRESS\n/q/fb/ADDRESS\n"
    if (not util.possible_address(addr)):
        return 'ERROR:    address    invalid'
    (version, dbhash) = util.decode_address(addr)
    ret = abe.store.get_firstbits(address_version=version, db_pubkey_hash=abe.store.binin(dbhash), chain_id=(chain and chain.id))
    if (ret is None):
        return 'ERROR:    address    not    in    the    chain.'
    return ret
