I keep not being able to get a True when printing the following: "print(tx_obj.sign_input(1, priv))" - it keeps getting a "IndexError: list index out of range" when I run it.
Full code below:
prev_tx_1 = bytes.fromhex('8ad156e7f1975fa59984107186440b9e38095bd64e96d3e51ccb45c527611627')
prev_index_1 = 1
prev_tx_2 = bytes.fromhex('3774c6f3a0ed44541deaf14affbd072938edd820c5bc73904fc6e31dafa1166b')
prev_index_2 = 2 -- ERROR: should be should be "prev_index_2 = 1"
I keep not being able to get a True when printing the following: "print(tx_obj.sign_input(1, priv))" - it keeps getting a "IndexError: list index out of range" when I run it.
Full code below:
prev_tx_1 = bytes.fromhex('8ad156e7f1975fa59984107186440b9e38095bd64e96d3e51ccb45c527611627') prev_index_1 = 1 prev_tx_2 = bytes.fromhex('3774c6f3a0ed44541deaf14affbd072938edd820c5bc73904fc6e31dafa1166b') prev_index_2 = 2 -- ERROR: should be should be "prev_index_2 = 1"
target_address = 'mwJn1YPMq7y5F8J3LkC5Hxg9PHyZ5K4cFv' target_amount = 0.0009
secret = 113512981650047008758002226197780499457471310280049977915853650440273401034027 priv = PrivateKey(secret=secret)
tx_ins = [] tx_ins.append(TxIn(prev_tx_1, prev_index_1)) tx_ins.append(TxIn(prev_tx_2, prev_index_2))
tx_outs = [] h160 = decode_base58(target_address) script_pubkey = p2pkh_script(h160) target_satoshis = int(target_amount*100000000) tx_outs.append(TxOut(target_satoshis, script_pubkey))
tx_obj = Tx(1, tx_ins, tx_outs, 0, testnet=True) print(tx_obj.sign_input(0, priv)) print(tx_obj.sign_input(1, priv)) print(tx_obj.serialize().hex())