Esempio n. 1
0
def split_coins(amount_to_send, txid_to_spend, utxo_index, n, network):
    txin_scriptPubKey = address.to_scriptPubKey()
    txin = create_txin(txid_to_spend, utxo_index)
    txout_scriptPubKey = address.to_scriptPubKey()
    txout = create_txout(amount_to_send / n, txout_scriptPubKey)
    tx = CMutableTransaction([txin], [txout] * n)
    sighash = SignatureHash(txin_scriptPubKey, tx, 0, SIGHASH_ALL)
    txin.scriptSig = CScript(
        [private_key.sign(sighash) + bytes([SIGHASH_ALL]), public_key])
    VerifyScript(txin.scriptSig, txin_scriptPubKey, tx, 0,
                 (SCRIPT_VERIFY_P2SH, ))
    response = broadcast_transaction(tx, network)
    print(response.status_code, response.reason)
    print(response.text)
Esempio n. 2
0
def send_from_P2PKH_transaction(amount_to_send, txid_to_spend, utxo_index,
                                txout_scriptPubKey, sender_private_key,
                                network):

    sender_public_key = sender_private_key.pub
    sender_address = P2PKHBitcoinAddress.from_pubkey(sender_public_key)

    txout = create_txout(amount_to_send, txout_scriptPubKey)

    txin_scriptPubKey = P2PKH_scriptPubKey(sender_address)
    txin = create_txin(txid_to_spend, utxo_index)
    txin_scriptSig = P2PKH_scriptSig(txin, txout, txin_scriptPubKey,
                                     sender_private_key, sender_public_key)

    new_tx = create_signed_transaction(txin, txout, txin_scriptPubKey,
                                       txin_scriptSig)

    return broadcast_transaction(new_tx, network)
Esempio n. 3
0
def broadcast_BCY(tx):
    response = broadcast_transaction(tx, 'bcy-test')
    print(response.status_code, response.reason)
    print(response.text)
Esempio n. 4
0
def broadcast_BTC(tx):
    response = broadcast_transaction(tx, 'btc-test3')
    print(response.status_code, response.reason)
    print(response.text)