예제 #1
0
def check_outputs_max_index(unspents, changecode=0):
    index = -1
    for u in unspents:
        upath = u['xpub']['path']
        cdexpath = bitcoin.bip32_path_from_string(upath)
        if (cdexpath[-2] == changecode):
            cdex = cdexpath[-1]
            index = max(cdex, index)
    return index + 1
예제 #2
0
def check_outputs_max_index(unspents, changecode=0):
    index =- 1
    for u in unspents:
        upath = u['xpub']['path']
        cdexpath = bitcoin.bip32_path_from_string(upath)
        if cdexpath[-2] == changecode:
            cdex = cdexpath[-1]
            index = max(cdex, index)
    return index + 1
예제 #3
0
def sign(args):
    master_key = get_master_key()

    input_transaction = json.load(args.input_file)
    privs = input_transaction['keys']
    tx = input_transaction['tx']
    for k, p in privs.items():
        pstr = bitcoin.bip32_path_from_string(p['path'])
        xpubk = p['m']
        a = 0
        priv_key = bitcoin.hd_lookup(master_key, account=a)
        while (bitcoin.bip32_privtopub(priv_key) != xpubk):
            priv_key = bitcoin.hd_lookup(master_key, account=a)
            a += 1
        privs[k] = bitcoin.bip32_descend(priv_key, pstr[0], pstr[1])
    print(bitcoin.signall(str(tx), privs))
예제 #4
0
def sign(args):
    master_key = get_master_key()

    input_transaction = json.load(args.input_file)
    privs = input_transaction['keys']
    tx = input_transaction['tx']
    for k, p in privs.items():
        pstr = bitcoin.bip32_path_from_string(p['path'])
        xpubk = p['m']
        a = 0
        priv_key = bitcoin.hd_lookup(master_key, account = a)
        while bitcoin.bip32_privtopub(priv_key) != xpubk:
            priv_key = bitcoin.hd_lookup(master_key, account = a)
        a += 1
        privs[k] = bitcoin.bip32_descend(priv_key, pstr[0], pstr[1])
    print(bitcoin.signall(str(tx), privs))