'amount ever received minus amount ever sent by a given address.'

def q_addressbalance(abe, page, chain):

    addr = wsgiref.util.shift_path_info(page['env'])
    if ((chain is None) or (addr is None)):
        return 'returns    amount    of    money    at    the    given    address\n/chain/CHAIN/q/addressbalance/ADDRESS\n'
    if (not util.possible_address(addr)):
        return 'ERROR:    address    invalid'
    (version, hash) = util.decode_address(addr)
    total = abe.store.get_balance(chain.id, hash)
    return ('ERROR:    please    try    again' if (total is None) else format_satoshis(total, chain))
