def create_deposit_tx(self, hash160): """Return a mocked deposit transaction. This uses the hex from some transaction I had lying around and then modifies the outputs to pay to the multisig script hash. I basically just needed some UTXO's to pay for this thing. """ tx_bytes = codecs.decode( "010000000295c5ca7c5d339d476456e5798bc5d483c37234adedeea1d6d58bd7" "4dcb3ab488000000006b483045022100bdb985c42ff8db57bd936fd2c7567e0b" "4220012b568a956c8b1dcfdef049effb0220637c5f5aad734f3fe42f8a5e2879" "174d219dcda516a370d8fd9d2a8d97193668012102a00465ffe29a8a3abd021b" "8037fb4467c0a734588449694dda8309495de5dc8affffffff1443c6572f221d" "02e072b5efd3af62833ade83c681e8c1ed6620a4020c300aac000000006b4830" "4502210086414fe8cc24bbcdebc4238201c3d021d4cd0b0a39b69538227fcfd5" "cca8df8c0220540cd8d8ab4f7a03a89fb686cec4f4a47f0b4d9d477c383b040b" "a1d7f0b5313c01210237c3846c8f7f86c86078344ff0e09c73d48bec4a1e60dd" "99df1ddb2816d1196dffffffff02b0ad01000000000017a9147487cdfa3235a3" "479dc05a10504bd8127aa0bab08780380100000000001976a914928f936fc8f9" "5dc733d64ebef37d7f57ea70813a88ac00000000", "hex_codec", ) tx = Transaction.from_bytes(tx_bytes)[0] # Modify the transaction to use the hash160 of a redeem script tx.outputs[0].script = Script.build_p2sh(hash160) return tx
def verify_half_signed_tx(self, tx_from_user): """Verify a half-signed refund is a valid transaction.""" redeem_script = get_redeem_script(tx_from_user) # Verify partial signature in refund transaction script_pubkey = Script.build_p2sh(redeem_script.hash160()) if not tx_from_user.verify_partial_multisig(0, script_pubkey): raise TransactionVerificationError("Half-signed transaction could not be verified.") return True