mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 23:08:14 +00:00
test: Add device test for replacement transaction with OP_RETURN output.
This commit is contained in:
parent
dfbdcf5b2b
commit
7436fd06b9
@ -71,6 +71,12 @@ TXHASH_927784 = bytes.fromhex(
|
||||
TXHASH_43d273 = bytes.fromhex(
|
||||
"43d273d3caf41759ad843474f960fbf80ff2ec961135d018b61e9fab3ad1fc06"
|
||||
)
|
||||
TXHASH_408397 = bytes.fromhex(
|
||||
"4083973799f05c52f556b603ab0f93d9c4c50be50da03c770a492d0990ca7809"
|
||||
)
|
||||
TXHASH_ba917a = bytes.fromhex(
|
||||
"ba917a2b563966e324ab37ed7de5f5cd7503b970b0f0bb9a5208f5835557e99c"
|
||||
)
|
||||
|
||||
|
||||
def test_p2pkh_fee_bump(client):
|
||||
@ -142,6 +148,52 @@ def test_p2pkh_fee_bump(client):
|
||||
)
|
||||
|
||||
|
||||
def test_p2wpkh_op_return_fee_bump(client):
|
||||
# Original input.
|
||||
inp1 = messages.TxInputType(
|
||||
address_n=parse_path("m/84h/1h/1h/0/14"),
|
||||
amount=1000000,
|
||||
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||
prev_hash=TXHASH_408397,
|
||||
prev_index=1,
|
||||
orig_hash=TXHASH_ba917a,
|
||||
orig_index=0,
|
||||
sequence=4294967293,
|
||||
)
|
||||
|
||||
# Original OP_RETURN output.
|
||||
out1 = messages.TxOutputType(
|
||||
amount=0,
|
||||
op_return_data=b"dead",
|
||||
script_type=messages.OutputScriptType.PAYTOOPRETURN,
|
||||
orig_hash=TXHASH_ba917a,
|
||||
orig_index=0,
|
||||
)
|
||||
|
||||
# Change-output. We bump the fee from 150 to 300.
|
||||
out2 = messages.TxOutputType(
|
||||
address_n=parse_path("m/84h/1h/1h/1/10"),
|
||||
amount=999850 - 150,
|
||||
script_type=messages.OutputScriptType.PAYTOWITNESS,
|
||||
orig_hash=TXHASH_ba917a,
|
||||
orig_index=1,
|
||||
)
|
||||
|
||||
with client:
|
||||
_, serialized_tx = btc.sign_tx(
|
||||
client,
|
||||
"Testnet",
|
||||
[inp1],
|
||||
[out1, out2],
|
||||
prev_txes=TX_CACHE_TESTNET,
|
||||
)
|
||||
|
||||
assert (
|
||||
serialized_tx.hex()
|
||||
== "010000000001010978ca90092d490a773ca00de50bc5c4d9930fab03b656f5525cf099379783400100000000fdffffff020000000000000000066a046465616414410f00000000001600141c02e2397a8a02ff71d3f26937d14a656469dd1f02483045022100f534412752c14064470d4a1f738fa01bc83598b07caaba4cd207b43b1b9702a4022071a4f0873006c07ccfeb1f82e86f3047eab208f38cfa41d7b566d6ca50dbca0f012102a269d4b8faf008074b974b6d64fa1776e17fdf65381a76d1338e9bba88983a8700000000"
|
||||
)
|
||||
|
||||
|
||||
def test_p2wpkh_finalize(client):
|
||||
# Original input with disabled RBF opt-in, i.e. we finalize the transaction.
|
||||
inp1 = messages.TxInputType(
|
||||
|
@ -0,0 +1,23 @@
|
||||
{
|
||||
"bin_outputs": [
|
||||
{
|
||||
"amount": 18171871,
|
||||
"script_pubkey": "00143d57bfcb3270a8de63fb5d187a02bd8f06c63796"
|
||||
},
|
||||
{
|
||||
"amount": 1000000,
|
||||
"script_pubkey": "0014c6f5a6a46b94c28f3179f05d35d6926617596f16"
|
||||
}
|
||||
],
|
||||
"inputs": [
|
||||
{
|
||||
"prev_hash": "0f078f343d61b1b1f9960b40a10ea5677653710f2f24546fd3e51a32c90e6477",
|
||||
"prev_index": 1,
|
||||
"script_sig": "1600146f0f93990b52934e4ecab84f0549737edc49627e",
|
||||
"script_type": "SPENDADDRESS",
|
||||
"sequence": 4294967294
|
||||
}
|
||||
],
|
||||
"lock_time": 1940846,
|
||||
"version": 2
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"address_n": [2147483732, 2147483649, 2147483649, 0, 14],
|
||||
"amount": 1000000,
|
||||
"prev_hash": "4083973799f05c52f556b603ab0f93d9c4c50be50da03c770a492d0990ca7809",
|
||||
"prev_index": 1,
|
||||
"script_sig": "",
|
||||
"script_type": "SPENDWITNESS",
|
||||
"sequence": 4294967293,
|
||||
"witness": "024730440220245e21b27caa065940d5ea4b539926598ad0af4f47f8135a41d85708b7c0df42022050f7108edc8ff3d5ebf8a621e5127133caa302af2d050b7037bdc1a486861557012102a269d4b8faf008074b974b6d64fa1776e17fdf65381a76d1338e9bba88983a87"
|
||||
}
|
||||
],
|
||||
"lock_time": 0,
|
||||
"outputs": [
|
||||
{
|
||||
"op_return_data": "64656164",
|
||||
"amount": 0,
|
||||
"script_type": "PAYTOOPRETURN"
|
||||
},
|
||||
{
|
||||
"address_n": [2147483732, 2147483649, 2147483649, 1, 10],
|
||||
"amount": 999850,
|
||||
"script_type": "PAYTOWITNESS"
|
||||
}
|
||||
],
|
||||
"version": 1
|
||||
}
|
@ -514,6 +514,7 @@
|
||||
"test_msg_signtx_replacement.py::test_p2wpkh_in_p2sh_fee_bump_from_external": "fcb907f7342b68ab12ea26555f129a5a5095c2b7c44fb1ec3bb74e0e6dd24bda",
|
||||
"test_msg_signtx_replacement.py::test_p2wpkh_in_p2sh_remove_change": "1ba9741d9a1a7b5a3fae0312c9626e407b6b80e1d3b9ec91088348ca25f5161c",
|
||||
"test_msg_signtx_replacement.py::test_p2wpkh_invalid_signature": "0581c0c3b9539789fd924841e4cf03ecd767a6692af7e41b46889bea1d7c7c07",
|
||||
"test_msg_signtx_replacement.py::test_p2wpkh_op_return_fee_bump": "1fa811be19b80d1fdd2867bd4216e7095162565f272f9aa18e1672f2fbeccdd8",
|
||||
"test_msg_signtx_replacement.py::test_p2wpkh_payjoin[19909659-90000-02483045022100aa1b91fb25-124c0968": "a5473b5f3931fb6530a991e45aa32507069a7b402878d1eda2ce6e8be1a673e1",
|
||||
"test_msg_signtx_replacement.py::test_p2wpkh_payjoin[19909718-90000-024730440220753f53049ca4-2253fa0b": "a5473b5f3931fb6530a991e45aa32507069a7b402878d1eda2ce6e8be1a673e1",
|
||||
"test_msg_signtx_replacement.py::test_p2wpkh_payjoin[19909800-89859-0248304502210097a42b35d3-89bd0d1d": "a5473b5f3931fb6530a991e45aa32507069a7b402878d1eda2ce6e8be1a673e1",
|
||||
|
Loading…
Reference in New Issue
Block a user