예제 #1
0
def main():
    env = Env()
    bp = DB(env)
    coin = env.coin
    if len(sys.argv) == 1:
        count_entries(bp.hist_db, bp.utxo_db)
        return
    argc = 1
    try:
        limit = int(sys.argv[argc])
        argc += 1
    except Exception:
        limit = 10
    for addr in sys.argv[argc:]:
        print('Address: ', addr)
        hashX = coin.address_to_hashX(addr)

        for n, (tx_hash, height) in enumerate(bp.get_history(hashX, limit)):
            print('History #{:d}: hash: {} height: {:d}'
                  .format(n + 1, hash_to_str(tx_hash), height))
        n = None
        for n, utxo in enumerate(bp.get_utxos(hashX, limit)):
            print('UTXOs #{:d}: hash: {} pos: {:d} height: {:d} value: {:d}'
                  .format(n + 1, hash_to_str(utxo.tx_hash),
                          utxo.tx_pos, utxo.height, utxo.value))
        if n is None:
            print('No UTXOs')
        balance = bp.get_balance(hashX)
        print('Balance: {} {}'.format(coin.decimal_value(balance),
                                      coin.SHORTNAME))
예제 #2
0
파일: query.py 프로젝트: mmitech/electrumx
def main():
    env = Env()
    os.chdir(env.db_dir)
    db = DB(env)
    coin = db.coin
    argc = 1
    try:
        limit = int(sys.argv[argc])
        argc += 1
    except:
        limit = 10
    for addr in sys.argv[argc:]:
        print('Address: ', addr)
        hash168 = coin.address_to_hash168(addr)
        n = None
        for n, (tx_hash, height) in enumerate(db.get_history(hash168, limit)):
            print('History #{:d}: hash: {} height: {:d}'.format(
                n + 1,
                bytes(reversed(tx_hash)).hex(), height))
        if n is None:
            print('No history')
        n = None
        for n, utxo in enumerate(db.get_utxos(hash168, limit)):
            print('UTXOs #{:d}: hash: {} pos: {:d} height: {:d} value: {:d}'.
                  format(n + 1,
                         bytes(reversed(utxo.tx_hash)).hex(), utxo.tx_pos,
                         utxo.height, utxo.value))
        if n is None:
            print('No UTXOs')
        balance = db.get_balance(hash168)
        print('Balance: {} {}'.format(coin.decimal_value(balance),
                                      coin.SHORTNAME))