Exemplo n.º 1
0
            "Number of cosigners (%d) is different then expected. SIG_N=%d" %
            (len(key_list), SIGS_N))
    wallet3o5 = Wallet.create(WALLET_NAME,
                              key_list,
                              sigs_required=SIGS_REQUIRED,
                              witness_type=WITNESS_TYPE,
                              network=NETWORK)
    wallet3o5.new_key()
    print("\n\nA multisig wallet with 1 key has been created on this system")
else:
    wallet3o5 = Wallet(WALLET_NAME)

print("\nUpdating UTXO's...")
wallet3o5.utxos_update()
wallet3o5.info()
utxos = wallet3o5.utxos()
wallet3o5.info()

# Creating transactions just like in a normal wallet, then send raw transaction to other cosigners. They
# can sign the transaction with there on key and pass it on to the next signer or broadcast it to the network.
# You can use bitcoinlib/tools/sign_raw.py to import and sign a raw transaction.

t = None
if utxos:
    print("\nNew unspent outputs found!")
    print(
        "Now a new transaction will be created to sweep this wallet and send bitcoins to a testnet faucet"
    )
    send_to_address = '2NGZrVvZG92qGYqzTLjCAewvPZ7JE8S8VxE'
    t = wallet3o5.sweep(send_to_address, min_confirms=0, offline=True)
    print(
                  (key.wif_private(), WITNESS_TYPE))
        else:
            print("     '%s'," % key.wif_private())
    print("]")
    print(
        "wlt = Wallet.create('%s', key_list, sigs_required=2, witness_type='%s', network='%s')"
        % (WALLET_NAME, WITNESS_TYPE, NETWORK))
    print("wlt.get_key()")
    print("wlt.info()")
else:
    from bitcoinlib.config.config import BITCOINLIB_VERSION, BCL_DATABASE_DIR
    online_wallet = Wallet(WALLET_NAME,
                           db_uri=BCL_DATABASE_DIR + '/bitcoinlib.tmp.sqlite')
    online_wallet.utxos_update()
    online_wallet.info()
    utxos = online_wallet.utxos()
    if utxos:
        print("\nNew unspent outputs found!")
        print(
            "Now a new transaction will be created to sweep this wallet and send bitcoins to a testnet faucet"
        )
        send_to_address = 'n2eMqTT929pb1RDNuqEnxdaLau1rxy3efi'
        t = online_wallet.sweep(send_to_address, min_confirms=0)
        print(t.raw_hex())
        print(
            "Now copy-and-paste the raw transaction hex to your Offline PC and sign it there with a second signature:"
        )
        print("\nfrom bitcoinlib.wallets import Wallet")
        print("")
        print("wlt = Wallet('%s')" % WALLET_NAME)
        print("utxos = ", end='')