예제 #1
0
def test_bip32_vector(vector):
    master = btc.bip32_master_key(vector['seed'])
    assert master == vector['keys'][0][0], 'failed: master xpriv'
    masterpub = btc.bip32_privtopub(master)
    assert masterpub == vector['keys'][0][1], 'failed: master xpub'
    currentkey = master
    for i in range(1, len(vector['depths'])):
        currentkey = btc.bip32_ckd(currentkey, vector['depths'][i])
        print(currentkey)
        print(vector['keys'][i][0])
        assert currentkey == vector['keys'][i][
            0], 'failed: child priv key, should be: ' + vector['keys'][i][0]
        pub = btc.bip32_privtopub(currentkey)
        print(pub)
        print(vector['keys'][i][1])
        assert pub == vector['keys'][i][
            1], 'failed: child pub key, should be: ' + vector['keys'][i][1]
예제 #2
0
    print(json.dumps(unsp, indent=4))
    sys.exit(0)

if method == 'display' or method == 'displayall' or method == 'summary':

    def cus_print(s):
        if method != 'summary':
            print(s)

    total_balance = 0
    for m in range(wallet.max_mix_depth):
        cus_print('mixing depth %d m/0/%d/' % (m, m))
        balance_depth = 0
        for forchange in [0, 1]:
            if forchange == 0:
                xpub_key = btc.bip32_privtopub(wallet.keys[m][forchange])
            else:
                xpub_key = ''
            cus_print(' ' + ('external' if forchange == 0 else 'internal') +
                      ' addresses m/0/%d/%d' % (m, forchange) + ' ' + xpub_key)

            for k in range(wallet.index[m][forchange] + options.gaplimit):
                addr = wallet.get_addr(m, forchange, k)
                balance = 0.0
                for addrvalue in wallet.unspent.values():
                    if addr == addrvalue['address']:
                        balance += addrvalue['value']
                balance_depth += balance
                used = ('used' if k < wallet.index[m][forchange] else ' new')
                if options.showprivkey:
                    privkey = btc.wif_compressed_privkey(