Exemplo n.º 1
0
def handle_stat_utxo(args):
    store = Storage(args.root)
    total_coin = 0
    balances = defaultdict(int)
    print('Start iterating utxos')
    for txin, txout in store.iter_utxo():
        total_coin += txout.c
        balances[txout.addr] += txout.c
    top_balances = itertools.islice(
        sorted(balances.items(), key=lambda t: t[1], reverse=True), 10)
    print('total_coin', total_coin / (10**6))
    print('top addresses:')
    for addr, c in top_balances:
        print(' ', base58.b58encode(addr).decode(), c / (10**6))
Exemplo n.º 2
0
def handle_wallet_balance(args):
    cfg = load_wallet_config(args)
    root_key = binascii.unhexlify(cfg['root_key'])
    hdpass = derive_hdpassphase(xpriv_to_xpub(root_key))

    # iterate utxo.
    print('Searching for utxo...')
    store = Storage(args.root)
    txouts = []
    for txin, txout in store.iter_utxo():
        if Address.decode(txout.addr).get_derive_path(hdpass):
            txouts.append(txout)

    balance = sum(out.c for out in txouts)
    print('balance:', balance)
    print('details:')
    for out in txouts:
        print(base58.b58encode(out.addr), out.c)