'shows the amount of currency ever mined.'

def q_totalbc(abe, page, chain):

    if (chain is None):
        return 'Shows    the    amount    of    currency    ever    mined.\nThis    differs    from    the    amount    in    circulation    when    coins    are    destroyed,    as    happens    frequently    in    Namecoin.\nUnlike    http://blockexplorer.com/q/totalbc,    this    does    not    support    future    block    numbers,    and    it    returns    a    sum    of    observed    generations    rather    than    a    calculated    value.\n/chain/CHAIN/q/totalbc[/HEIGHT]\n'
    height = path_info_uint(page, None)
    if (height is None):
        row = abe.store.selectrow('\n                                                                SELECT    b.block_total_satoshis\n                                                                        FROM    chain    c\n                                                                        LEFT    JOIN    block    b    ON    (c.chain_last_block_id    =    b.block_id)\n                                                                    WHERE    c.chain_id    =    ?\n                                                ', (chain.id,))
    else:
        row = abe.store.selectrow('\n                                                                SELECT    b.block_total_satoshis\n                                                                        FROM    chain_candidate    cc\n                                                                        LEFT    JOIN    block    b    ON    (b.block_id    =    cc.block_id)\n                                                                    WHERE    cc.chain_id    =    ?\n                                                                            AND    cc.block_height    =    ?\n                                                                            AND    cc.in_longest    =    1\n                                                ', (chain.id, height))
        if (not row):
            return ('ERROR:    block    %d    not    seen    yet' % (height,))
    return (format_satoshis(row[0], chain) if row else 0)
