mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-20 14:39:22 +00:00
feat(tests): Add fee bump device test for Taproot.
This commit is contained in:
parent
f0d6e961a9
commit
5837750aaa
@ -77,6 +77,15 @@ TXHASH_408397 = bytes.fromhex(
|
||||
TXHASH_ba917a = bytes.fromhex(
|
||||
"ba917a2b563966e324ab37ed7de5f5cd7503b970b0f0bb9a5208f5835557e99c"
|
||||
)
|
||||
TXHASH_a4e274 = bytes.fromhex(
|
||||
"a4e2745235250cc223b42004769338f5837e9290caf546da33ab117e4d011c92"
|
||||
)
|
||||
TXHASH_ccd7ea = bytes.fromhex(
|
||||
"ccd7eaacc9f6902b89c00a6c221391bd41c8b78e7935ff3e1130d13644393ff2"
|
||||
)
|
||||
TXHASH_8e4af7 = bytes.fromhex(
|
||||
"8e4af74cee65dac2615f7befea76bab4955707cd216011d918b526f5e86d85ba"
|
||||
)
|
||||
|
||||
|
||||
def test_p2pkh_fee_bump(client):
|
||||
@ -194,6 +203,77 @@ def test_p2wpkh_op_return_fee_bump(client):
|
||||
)
|
||||
|
||||
|
||||
# txid 48bc29fc42a64b43d043b0b7b99b21aa39654234754608f791c60bcbd91a8e92
|
||||
@pytest.mark.skip_t1
|
||||
def test_p2tr_fee_bump(client):
|
||||
inp1 = messages.TxInputType(
|
||||
# tb1p8tvmvsvhsee73rhym86wt435qrqm92psfsyhy6a3n5gw455znnpqm8wald
|
||||
address_n=parse_path("86'/1'/0'/0/1"),
|
||||
amount=13000,
|
||||
orig_hash=TXHASH_8e4af7,
|
||||
orig_index=0,
|
||||
prev_hash=TXHASH_a4e274,
|
||||
prev_index=1,
|
||||
script_type=messages.InputScriptType.SPENDTAPROOT,
|
||||
)
|
||||
inp2 = messages.TxInputType(
|
||||
# tb1pswrqtykue8r89t9u4rprjs0gt4qzkdfuursfnvqaa3f2yql07zmq8s8a5u
|
||||
address_n=parse_path("86'/1'/0'/0/0"),
|
||||
amount=6800,
|
||||
orig_hash=TXHASH_8e4af7,
|
||||
orig_index=1,
|
||||
prev_hash=TXHASH_ccd7ea,
|
||||
prev_index=0,
|
||||
script_type=messages.InputScriptType.SPENDTAPROOT,
|
||||
)
|
||||
out1 = messages.TxOutputType(
|
||||
address="tb1qq0rurzt04d76hk7pjxhqggk7ad4zj7c9u369kt",
|
||||
amount=15000,
|
||||
orig_hash=TXHASH_8e4af7,
|
||||
orig_index=0,
|
||||
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
||||
)
|
||||
out2 = messages.TxOutputType(
|
||||
# tb1pn2d0yjeedavnkd8z8lhm566p0f2utm3lgvxrsdehnl94y34txmts5s7t4c
|
||||
address_n=parse_path("86'/1'/0'/1/0"),
|
||||
amount=4600 - 250, # bump the fee by 250
|
||||
orig_hash=TXHASH_8e4af7,
|
||||
orig_index=1,
|
||||
script_type=messages.OutputScriptType.PAYTOTAPROOT,
|
||||
)
|
||||
with client:
|
||||
client.set_expected_responses(
|
||||
[
|
||||
request_input(0),
|
||||
request_meta(TXHASH_8e4af7),
|
||||
request_orig_input(0, TXHASH_8e4af7),
|
||||
request_input(1),
|
||||
request_orig_input(1, TXHASH_8e4af7),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_output(0),
|
||||
request_orig_output(0, TXHASH_8e4af7),
|
||||
request_output(1),
|
||||
request_orig_output(1, TXHASH_8e4af7),
|
||||
messages.ButtonRequest(code=B.SignTx),
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_output(0),
|
||||
request_output(1),
|
||||
request_input(0),
|
||||
request_input(1),
|
||||
request_finished(),
|
||||
]
|
||||
)
|
||||
_, serialized_tx = btc.sign_tx(
|
||||
client, "Testnet", [inp1, inp2], [out1, out2], prev_txes=TX_CACHE_TESTNET
|
||||
)
|
||||
|
||||
assert (
|
||||
serialized_tx.hex()
|
||||
== "01000000000102921c014d7e11ab33da46f5ca90927e83f53893760420b423c20c25355274e2a40100000000fffffffff23f394436d130113eff35798eb7c841bd9113226c0ac0892b90f6c9acead7cc0000000000ffffffff02983a00000000000016001403c7c1896fab7dabdbc191ae0422deeb6a297b05fe100000000000002251209a9af24b396f593b34e23fefba6b417a55c5ee3f430c3837379fcb5246ab36d70140b0eef4af1291a31e3416e9daaf05457e5b14447663ef8137a250fe3eca24e2fc85e0d0a001a8035fa272d78b104761b05040ffa0b7d6f9a902c23aa8b521687e0140775b82068243545e9327725c56681c78bd7da0934bfdac2cc9cc06a1511379ff28e539c2538fe26f7e2c7385e51d650c4af8dc2c35baa7161c36d6919c83ff5c00000000"
|
||||
)
|
||||
|
||||
|
||||
def test_p2wpkh_finalize(client):
|
||||
# Original input with disabled RBF opt-in, i.e. we finalize the transaction.
|
||||
inp1 = messages.TxInputType(
|
||||
|
@ -0,0 +1,36 @@
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"address_n": [2147483734, 2147483649, 2147483648, 0, 1],
|
||||
"amount": 13000,
|
||||
"prev_hash": "a4e2745235250cc223b42004769338f5837e9290caf546da33ab117e4d011c92",
|
||||
"prev_index": 1,
|
||||
"script_sig": "",
|
||||
"script_type": "SPENDTAPROOT",
|
||||
"sequence": 4294967293,
|
||||
"witness": "01402c1c2352ec3eceb7d337710520a548c5c6f35cd6c9c539d94d4d8452a084137c06f69c5e6f042c45b635567b46303e936463b62bdf70422497fc0ae2208bcb40"
|
||||
},
|
||||
{
|
||||
"address_n": [2147483734, 2147483649, 2147483648, 0, 0],
|
||||
"amount": 6800,
|
||||
"prev_hash": "ccd7eaacc9f6902b89c00a6c221391bd41c8b78e7935ff3e1130d13644393ff2",
|
||||
"prev_index": 0,
|
||||
"script_sig": "",
|
||||
"script_type": "SPENDTAPROOT",
|
||||
"sequence": 4294967293
|
||||
}
|
||||
],
|
||||
"lock_time": 0,
|
||||
"outputs": [
|
||||
{
|
||||
"address": "tb1qq0rurzt04d76hk7pjxhqggk7ad4zj7c9u369kt",
|
||||
"amount": 15000
|
||||
},
|
||||
{
|
||||
"address_n": [2147483734, 2147483649, 2147483648, 1, 0],
|
||||
"amount": 4600,
|
||||
"script_type": "PAYTOTAPROOT"
|
||||
}
|
||||
],
|
||||
"version": 1
|
||||
}
|
@ -688,6 +688,7 @@
|
||||
"test_msg_signtx_replacement.py::test_attack_false_internal": "1c100ce4b7c1e47e72428f390de0846c1ff933e9f07894872644a369a9422738",
|
||||
"test_msg_signtx_replacement.py::test_attack_steal_change": "04ba3e05862eef616957f9f0c67f7a1d841a3bc7278c5fd999dfba4ebeee5314",
|
||||
"test_msg_signtx_replacement.py::test_p2pkh_fee_bump": "9521ab8dcf72d514103ec16410e3ad7d8e384084c3a645178ab191315911cd13",
|
||||
"test_msg_signtx_replacement.py::test_p2tr_fee_bump": "d2adcdaf62181c703628e355ba84ff979a81426429ee487c0059a9f161fbeb25",
|
||||
"test_msg_signtx_replacement.py::test_p2wpkh_finalize": "66d0c98fe05fab4e77a516434883f81fa9516464373374097e91a8e3c278a6b3",
|
||||
"test_msg_signtx_replacement.py::test_p2wpkh_in_p2sh_fee_bump_from_external": "d3d97e310fb2d1d29b351bdc35b359aab75b4bba7afd257eb85100031edaacbf",
|
||||
"test_msg_signtx_replacement.py::test_p2wpkh_in_p2sh_remove_change": "ae9e7bc83227cf6187fb5c689515b66da7bf8fcc58a43128389f6eb7ab35240d",
|
||||
|
Loading…
Reference in New Issue
Block a user