1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-29 09:38:08 +00:00

tests: Fix device tests for streamimg prev_tx after confirmation.

This commit is contained in:
Andrew Kozlik 2020-07-14 20:43:53 +02:00 committed by Andrew Kozlik
parent 9774c99e90
commit 4fc4152741
22 changed files with 505 additions and 381 deletions

View File

@ -62,7 +62,7 @@ def test_autolock_interrupts_signing(device_handler):
# try to sign a transaction
inp1 = messages.TxInputType(
address_n=parse_path("44h/0h/0h/0/0"),
# amount=390000,
amount=390000,
prev_hash=TXHASH_d5f65e,
prev_index=0,
)

View File

@ -142,10 +142,6 @@ def test_sign_tx(client):
messages.PreauthorizedRequest(),
request_input(0),
request_input(1),
request_meta(TXHASH_65b811),
request_input(0, TXHASH_65b811),
request_output(0, TXHASH_65b811),
request_output(1, TXHASH_65b811),
request_output(0),
request_output(1),
request_output(2),
@ -156,6 +152,11 @@ def test_sign_tx(client):
request_input(0, TXHASH_e5b7e2),
request_output(0, TXHASH_e5b7e2),
request_output(1, TXHASH_e5b7e2),
request_input(1),
request_meta(TXHASH_65b811),
request_input(0, TXHASH_65b811),
request_output(0, TXHASH_65b811),
request_output(1, TXHASH_65b811),
request_input(0),
request_input(1),
request_output(0),

View File

@ -80,7 +80,7 @@ class TestMsgSigntx:
inp1 = messages.TxInputType(
address_n=parse_path("44h/0h/0h/0/0"),
# amount=390000,
amount=390000,
prev_hash=TXHASH_d5f65e,
prev_index=0,
)
@ -94,14 +94,15 @@ class TestMsgSigntx:
with client:
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_d5f65e),
request_input(0, TXHASH_d5f65e),
request_input(1, TXHASH_d5f65e),
request_output(0, TXHASH_d5f65e),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
request_output(0),
@ -125,7 +126,7 @@ class TestMsgSigntx:
# input 0: 0.31 BTC
inp1 = messages.TxInputType(
address_n=parse_path("44'/1'/0'/0/0"),
# amount=31000000,
amount=31000000,
prev_hash=TXHASH_e5040e,
prev_index=0,
)
@ -146,15 +147,16 @@ class TestMsgSigntx:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_e5040e),
request_input(0, TXHASH_e5040e),
request_output(0, TXHASH_e5040e),
request_output(1, TXHASH_e5040e),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_e5040e),
request_input(0, TXHASH_e5040e),
request_output(0, TXHASH_e5040e),
request_output(1, TXHASH_e5040e),
request_input(0),
request_output(0),
request_output(1),
request_output(0),
@ -176,7 +178,7 @@ class TestMsgSigntx:
# input 1: 10.00000000 BTC
inp1 = messages.TxInputType(
address_n=parse_path("44'/1'/0'/0/0"),
# amount=1000000000,
amount=1000000000,
prev_hash=TXHASH_6f90f3,
prev_index=1,
)
@ -197,17 +199,18 @@ class TestMsgSigntx:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_6f90f3),
request_input(0, TXHASH_6f90f3),
request_input(1, TXHASH_6f90f3),
request_output(0, TXHASH_6f90f3),
request_output(1, TXHASH_6f90f3),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
messages.ButtonRequest(code=B.FeeOverThreshold),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_6f90f3),
request_input(0, TXHASH_6f90f3),
request_input(1, TXHASH_6f90f3),
request_output(0, TXHASH_6f90f3),
request_output(1, TXHASH_6f90f3),
request_input(0),
request_output(0),
request_output(1),
request_output(0),
@ -231,7 +234,7 @@ class TestMsgSigntx:
address_n=parse_path(
"m/44'/0'/0'/0/5"
), # 1GA9u9TfCG7SWmKCveBumdA1TZpfom6ZdJ
# amount=50000,
amount=50000,
prev_hash=TXHASH_50f6f1,
prev_index=1,
)
@ -254,15 +257,16 @@ class TestMsgSigntx:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_50f6f1),
request_input(0, TXHASH_50f6f1),
request_output(0, TXHASH_50f6f1),
request_output(1, TXHASH_50f6f1),
request_output(0),
request_output(1),
messages.ButtonRequest(code=B.ConfirmOutput),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_50f6f1),
request_input(0, TXHASH_50f6f1),
request_output(0, TXHASH_50f6f1),
request_output(1, TXHASH_50f6f1),
request_input(0),
request_output(0),
request_output(1),
request_output(0),
@ -285,7 +289,7 @@ class TestMsgSigntx:
inp1 = messages.TxInputType(
address_n=parse_path("44'/0'/0'/0/0"),
# amount=390000,
amount=390000,
prev_hash=TXHASH_d5f65e,
prev_index=0,
)
@ -312,10 +316,6 @@ class TestMsgSigntx:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_d5f65e),
request_input(0, TXHASH_d5f65e),
request_input(1, TXHASH_d5f65e),
request_output(0, TXHASH_d5f65e),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
@ -323,6 +323,11 @@ class TestMsgSigntx:
request_output(2),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_d5f65e),
request_input(0, TXHASH_d5f65e),
request_input(1, TXHASH_d5f65e),
request_output(0, TXHASH_d5f65e),
request_input(0),
request_output(0),
request_output(1),
request_output(2),
@ -353,14 +358,14 @@ class TestMsgSigntx:
inp1 = messages.TxInputType(
address_n=parse_path("44h/0h/0h/0/0"),
# amount=100000,
amount=100000,
prev_hash=TXHASH_c6be22,
prev_index=1,
)
inp2 = messages.TxInputType(
address_n=parse_path("44h/0h/0h/0/1"),
# amount=110000,
amount=110000,
prev_hash=TXHASH_58497a,
prev_index=1,
)
@ -380,6 +385,12 @@ class TestMsgSigntx:
with client:
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_c6be22),
request_input(0, TXHASH_c6be22),
@ -390,10 +401,6 @@ class TestMsgSigntx:
request_input(0, TXHASH_58497a),
request_output(0, TXHASH_58497a),
request_output(1, TXHASH_58497a),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_input(1),
request_output(0),
@ -433,6 +440,7 @@ class TestMsgSigntx:
inputs.append(
messages.TxInputType(
address_n=parse_path(f"44h/0h/0h/0/{i}"),
amount=26000,
prev_hash=TXHASH_4a7b7e,
prev_index=i,
)
@ -462,14 +470,14 @@ class TestMsgSigntx:
inp1 = messages.TxInputType(
address_n=parse_path("44h/0h/1h/0/0"),
# amount=100000,
amount=100000,
prev_hash=TXHASH_c63e24,
prev_index=1,
)
inp2 = messages.TxInputType(
address_n=parse_path("44h/0h/1h/0/1"),
# amount=2540000,
amount=2540000,
prev_hash=TXHASH_39a29e,
prev_index=1,
)
@ -504,14 +512,14 @@ class TestMsgSigntx:
inp1 = messages.TxInputType(
address_n=parse_path("44h/0h/1h/0/0"),
# amount=100000,
amount=100000,
prev_hash=TXHASH_c63e24,
prev_index=1,
)
inp2 = messages.TxInputType(
address_n=parse_path("44h/0h/1h/0/1"),
# amount=2540000,
amount=2540000,
prev_hash=TXHASH_39a29e,
prev_index=1,
)
@ -538,6 +546,15 @@ class TestMsgSigntx:
with client:
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
]
+ request_change_outputs
+ [
messages.ButtonRequest(code=B.SignTx),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_c63e24),
request_input(0, TXHASH_c63e24),
@ -549,13 +566,6 @@ class TestMsgSigntx:
request_input(0, TXHASH_39a29e),
request_output(0, TXHASH_39a29e),
request_output(1, TXHASH_39a29e),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
]
+ request_change_outputs
+ [
messages.ButtonRequest(code=B.SignTx),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_input(1),
request_output(0),
@ -583,7 +593,7 @@ class TestMsgSigntx:
inp1 = messages.TxInputType(
address_n=parse_path("44h/0h/0h/0/0"),
# amount=100000000,
amount=100000000,
prev_hash=TXHASH_157041,
prev_index=0,
)
@ -598,15 +608,16 @@ class TestMsgSigntx:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_157041),
request_input(0, TXHASH_157041),
request_output(0, TXHASH_157041),
request_output(1, TXHASH_157041),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
messages.ButtonRequest(code=B.FeeOverThreshold),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_157041),
request_input(0, TXHASH_157041),
request_output(0, TXHASH_157041),
request_output(1, TXHASH_157041),
request_input(0),
request_output(0),
request_output(0),
request_finished(),
@ -628,7 +639,7 @@ class TestMsgSigntx:
inp1 = messages.TxInputType(
address_n=parse_path("44h/0h/0h/0/0"),
# amount=100000000,
amount=100000000,
prev_hash=TXHASH_157041,
prev_index=0,
)
@ -673,7 +684,7 @@ class TestMsgSigntx:
inp1 = messages.TxInputType(
address_n=parse_path("44h/0h/0h/0/0"),
# amount=390000,
amount=390000,
prev_hash=TXHASH_d5f65e,
prev_index=0,
)
@ -688,10 +699,6 @@ class TestMsgSigntx:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_d5f65e),
request_input(0, TXHASH_d5f65e),
request_input(1, TXHASH_d5f65e),
request_output(0, TXHASH_d5f65e),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
messages.Failure(code=messages.FailureType.NotEnoughFunds),
@ -705,7 +712,7 @@ class TestMsgSigntx:
def test_p2sh(self, client):
inp1 = messages.TxInputType(
address_n=parse_path("44h/0h/0h/0/0"),
# amount=400000,
amount=400000,
prev_hash=TXHASH_54aa56,
prev_index=1,
)
@ -719,14 +726,15 @@ class TestMsgSigntx:
with client:
client.set_expected_responses(
[
request_input(0),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_54aa56),
request_input(0, TXHASH_54aa56),
request_output(0, TXHASH_54aa56),
request_output(1, TXHASH_54aa56),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
request_output(0),
@ -771,14 +779,14 @@ class TestMsgSigntx:
def test_attack_change_outputs(self, client):
inp1 = messages.TxInputType(
address_n=parse_path("44h/0h/0h/0/0"),
# amount=100000,
amount=100000,
prev_hash=TXHASH_c6be22,
prev_index=1,
)
inp2 = messages.TxInputType(
address_n=parse_path("44h/0h/0h/0/1"),
# amount=110000,
amount=110000,
prev_hash=TXHASH_58497a,
prev_index=1,
)
@ -841,7 +849,7 @@ class TestMsgSigntx:
# input 0: 0.31 BTC
inp1 = messages.TxInputType(
address_n=parse_path("44'/1'/0'/0/0"),
# amount=31000000,
amount=31000000,
prev_hash=TXHASH_e5040e,
prev_index=0,
)
@ -886,6 +894,7 @@ class TestMsgSigntx:
address_n=parse_path("44'/1'/4'/0/0"),
# moUJnmge8SRXuediK7bW6t4YfrPqbE6hD7
prev_hash=TXHASH_d2dcda,
amount=123400000,
prev_index=1,
script_type=messages.InputScriptType.SPENDADDRESS,
)
@ -912,13 +921,13 @@ class TestMsgSigntx:
== "0100000001243e15b53cc553d93ec4e27e16984adc3d885ef107c613a7577fea47f5dadcd2010000006b483045022100eedaadde3a771967beee39f1daa9e9450f72fccdec63488a96d71eeae4224b4002203a22be3c1677d3451c93a49550b69e8f8fc06328823c7e0f633dde13d67ef96b01210364430c9122948e525e2f1c6d88f00f47679274f0810fd8c63754954f310995c1ffffffff02a0860100000000001976a914b3cc67f3349974d0f1b50e9bb5dfdf226f888fa088ac18555907000000001976a914f80fb232a1e54b1fa732bc120cae72eabd7fcf6888ac00000000"
)
run_attack = False
attack_count = 2
def attack_processor(msg):
nonlocal run_attack
nonlocal attack_count
if msg.tx.inputs and msg.tx.inputs[0] == inp1:
if not run_attack:
run_attack = True
if attack_count > 0:
attack_count -= 1
else:
msg.tx.inputs[0].address_n[2] = H_(12)
@ -930,15 +939,16 @@ class TestMsgSigntx:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_d2dcda),
request_input(0, TXHASH_d2dcda),
request_output(0, TXHASH_d2dcda),
request_output(1, TXHASH_d2dcda),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_d2dcda),
request_input(0, TXHASH_d2dcda),
request_output(0, TXHASH_d2dcda),
request_output(1, TXHASH_d2dcda),
request_input(0),
messages.Failure(code=messages.FailureType.ProcessError),
]
)
@ -959,7 +969,7 @@ class TestMsgSigntx:
def test_spend_coinbase(self, client):
inp1 = messages.TxInputType(
address_n=parse_path("44h/1h/0h/0/0"),
# amount=390000,
amount=2500278230,
prev_hash=TXHASH_d6da21,
prev_index=0,
)
@ -974,13 +984,14 @@ class TestMsgSigntx:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_d6da21),
request_input(0, TXHASH_d6da21),
request_output(0, TXHASH_d6da21),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_d6da21),
request_input(0, TXHASH_d6da21),
request_output(0, TXHASH_d6da21),
request_input(0),
request_output(0),
request_output(0),
request_finished(),
@ -1003,7 +1014,7 @@ class TestMsgSigntx:
# input 0: 0.31 BTC
inp1 = messages.TxInputType(
address_n=parse_path("44'/1'/0'/0/0"),
# amount=31000000,
amount=31000000,
prev_hash=TXHASH_e5040e,
prev_index=0,
)
@ -1030,16 +1041,17 @@ class TestMsgSigntx:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_e5040e),
request_input(0, TXHASH_e5040e),
request_output(0, TXHASH_e5040e),
request_output(1, TXHASH_e5040e),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
request_output(2),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_e5040e),
request_input(0, TXHASH_e5040e),
request_output(0, TXHASH_e5040e),
request_output(1, TXHASH_e5040e),
request_input(0),
request_output(0),
request_output(1),
request_output(2),
@ -1065,7 +1077,7 @@ class TestMsgSigntx:
# input 0: 0.31 BTC
inp1 = messages.TxInputType(
address_n=parse_path("44'/1'/0'/0/0"),
# amount=31000000,
amount=31000000,
prev_hash=TXHASH_e5040e,
prev_index=0,
)
@ -1087,15 +1099,16 @@ class TestMsgSigntx:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_e5040e),
request_input(0, TXHASH_e5040e),
request_output(0, TXHASH_e5040e),
request_output(1, TXHASH_e5040e),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_e5040e),
request_input(0, TXHASH_e5040e),
request_output(0, TXHASH_e5040e),
request_output(1, TXHASH_e5040e),
request_input(0),
request_output(0),
request_output(1),
request_output(0),
@ -1121,20 +1134,29 @@ class TestMsgSigntx:
# vout[0] and vout[1] exist
inp0 = messages.TxInputType(
address_n=parse_path("44h/0h/0h/0/0"), prev_hash=TXHASH_157041, prev_index=0
address_n=parse_path("44h/0h/0h/0/0"),
prev_hash=TXHASH_157041,
amount=100000000,
prev_index=0,
)
inp1 = messages.TxInputType(
address_n=parse_path("44h/0h/0h/0/1"), prev_hash=TXHASH_157041, prev_index=1
address_n=parse_path("44h/0h/0h/0/1"),
prev_hash=TXHASH_157041,
amount=120160000,
prev_index=1,
)
# vout[2] does not exist
inp2 = messages.TxInputType(
address_n=parse_path("44h/0h/0h/1/0"), prev_hash=TXHASH_157041, prev_index=2
address_n=parse_path("44h/0h/0h/1/0"),
prev_hash=TXHASH_157041,
amount=100000000,
prev_index=2,
)
# try to spend the sum of existing vouts
out1 = messages.TxOutputType(
address="1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1",
amount=220160000,
amount=100000000 + 120160000 + 100000000 - 10000,
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
@ -1162,11 +1184,14 @@ class TestMsgSigntx:
@pytest.mark.skip_ui
def test_prevtx_forbidden_fields(self, client, field, value):
inp0 = messages.TxInputType(
address_n=parse_path("44h/0h/0h/0/0"), prev_hash=TXHASH_157041, prev_index=0
address_n=parse_path("44h/0h/0h/0/0"),
prev_hash=TXHASH_157041,
amount=100000000,
prev_index=0,
)
out1 = messages.TxOutputType(
address="1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1",
amount=1000,
amount=100000000 - 1000,
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
@ -1187,7 +1212,10 @@ class TestMsgSigntx:
@pytest.mark.skip_ui
def test_signtx_forbidden_fields(self, client, field, value):
inp0 = messages.TxInputType(
address_n=parse_path("44h/0h/0h/0/0"), prev_hash=TXHASH_157041, prev_index=0
address_n=parse_path("44h/0h/0h/0/0"),
prev_hash=TXHASH_157041,
amount=100000000,
prev_index=0,
)
out1 = messages.TxOutputType(
address="1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1",
@ -1232,6 +1260,7 @@ class TestMsgSigntx:
)
inp1 = messages.TxInputType(
address_n=address_n,
amount=142920000,
prev_index=1,
sequence=0xFFFFFFFF,
script_type=script_type, # incorrect script type
@ -1287,6 +1316,7 @@ class TestMsgSigntx:
)
inp1 = messages.TxInputType(
address_n=address_n,
amount=142920000,
prev_index=1,
sequence=0xFFFFFFFF,
script_type=messages.InputScriptType.SPENDADDRESS,
@ -1321,7 +1351,7 @@ class TestMsgSigntx:
inp1 = messages.TxInputType(
address_n=parse_path("44h/0h/0h/0/0"),
# amount=390000,
amount=390000,
prev_hash=TXHASH_d5f65e,
prev_index=0,
sequence=sequence,
@ -1337,15 +1367,16 @@ class TestMsgSigntx:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_d5f65e),
request_input(0, TXHASH_d5f65e),
request_input(1, TXHASH_d5f65e),
request_output(0, TXHASH_d5f65e),
request_output(0),
messages.ButtonRequest(code=B.ConfirmOutput),
messages.ButtonRequest(code=B.SignTx),
messages.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_d5f65e),
request_input(0, TXHASH_d5f65e),
request_input(1, TXHASH_d5f65e),
request_output(0, TXHASH_d5f65e),
request_input(0),
request_output(0),
request_output(0),
request_finished(),

View File

@ -65,14 +65,15 @@ class TestMsgSigntxBch:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_bc37c2),
request_input(0, TXHASH_bc37c2),
request_output(0, TXHASH_bc37c2),
request_output(0),
request_output(1),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_bc37c2),
request_input(0, TXHASH_bc37c2),
request_output(0, TXHASH_bc37c2),
request_input(0),
request_output(0),
request_output(1),
request_finished(),
@ -112,6 +113,11 @@ class TestMsgSigntxBch:
with client:
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_502e85),
request_input(0, TXHASH_502e85),
@ -122,9 +128,6 @@ class TestMsgSigntxBch:
request_input(0, TXHASH_502e85),
request_output(0, TXHASH_502e85),
request_output(1, TXHASH_502e85),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_input(1),
request_output(0),
@ -165,6 +168,11 @@ class TestMsgSigntxBch:
with client:
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_502e85),
request_input(0, TXHASH_502e85),
@ -175,9 +183,6 @@ class TestMsgSigntxBch:
request_input(0, TXHASH_502e85),
request_output(0, TXHASH_502e85),
request_output(1, TXHASH_502e85),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_input(1),
request_output(0),
@ -212,14 +217,14 @@ class TestMsgSigntxBch:
script_type=proto.OutputScriptType.PAYTOADDRESS,
)
run_attack = False
attack_count = 2
def attack_processor(msg):
nonlocal run_attack
nonlocal attack_count
if msg.tx.inputs and msg.tx.inputs[0] == inp1:
if not run_attack:
run_attack = True
if attack_count > 0:
attack_count -= 1
else:
msg.tx.inputs[0].address_n[2] = H_(1)
@ -231,14 +236,15 @@ class TestMsgSigntxBch:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_bc37c2),
request_input(0, TXHASH_bc37c2),
request_output(0, TXHASH_bc37c2),
request_output(0),
request_output(1),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_bc37c2),
request_input(0, TXHASH_bc37c2),
request_output(0, TXHASH_bc37c2),
request_input(0),
proto.Failure(code=proto.FailureType.ProcessError),
]
)
@ -299,14 +305,15 @@ class TestMsgSigntxBch:
with client:
client.set_expected_responses(
[
request_input(0),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_f68caf),
request_input(0, TXHASH_f68caf),
request_output(0, TXHASH_f68caf),
request_output(1, TXHASH_f68caf),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
request_finished(),
@ -361,14 +368,15 @@ class TestMsgSigntxBch:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_8b6db9),
request_input(0, TXHASH_8b6db9),
request_output(0, TXHASH_8b6db9),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_8b6db9),
request_input(0, TXHASH_8b6db9),
request_output(0, TXHASH_8b6db9),
request_input(0),
request_output(0),
request_output(1),
request_finished(),
@ -398,14 +406,15 @@ class TestMsgSigntxBch:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_8b6db9),
request_input(0, TXHASH_8b6db9),
request_output(0, TXHASH_8b6db9),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_8b6db9),
request_input(0, TXHASH_8b6db9),
request_output(0, TXHASH_8b6db9),
request_input(0),
request_output(0),
request_output(1),
request_finished(),
@ -455,10 +464,6 @@ class TestMsgSigntxBch:
[
request_input(0),
request_input(1),
request_meta(TXHASH_502e85),
request_input(0, TXHASH_502e85),
request_output(0, TXHASH_502e85),
request_output(1, TXHASH_502e85),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
@ -467,6 +472,11 @@ class TestMsgSigntxBch:
request_input(0, TXHASH_502e85),
request_output(0, TXHASH_502e85),
request_output(1, TXHASH_502e85),
request_input(1),
request_meta(TXHASH_502e85),
request_input(0, TXHASH_502e85),
request_output(0, TXHASH_502e85),
request_output(1, TXHASH_502e85),
request_input(0),
request_input(1),
request_output(0),

View File

@ -62,15 +62,16 @@ class TestMsgSigntxBitcoinGold:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_25526b),
request_input(0, TXHASH_25526b),
request_output(0, TXHASH_25526b),
request_output(1, TXHASH_25526b),
request_output(0),
request_output(1),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_25526b),
request_input(0, TXHASH_25526b),
request_output(0, TXHASH_25526b),
request_output(1, TXHASH_25526b),
request_input(0),
request_output(0),
request_output(1),
request_finished(),
@ -109,6 +110,11 @@ class TestMsgSigntxBitcoinGold:
with client:
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_25526b),
request_input(0, TXHASH_25526b),
@ -119,9 +125,6 @@ class TestMsgSigntxBitcoinGold:
request_input(0, TXHASH_db77c2),
request_input(1, TXHASH_db77c2),
request_output(0, TXHASH_db77c2),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_input(1),
request_output(0),
@ -156,16 +159,16 @@ class TestMsgSigntxBitcoinGold:
script_type=proto.OutputScriptType.PAYTOADDRESS,
)
run_attack = False
attack_count = 2
def attack_processor(msg):
nonlocal run_attack
nonlocal attack_count
if msg.tx.inputs and msg.tx.inputs[0] == inp1:
if run_attack:
msg.tx.inputs[0].address_n[2] = H_(1)
if attack_count > 0:
attack_count -= 1
else:
run_attack = True
msg.tx.inputs[0].address_n[2] = H_(1)
return msg
@ -174,15 +177,16 @@ class TestMsgSigntxBitcoinGold:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_25526b),
request_input(0, TXHASH_25526b),
request_output(0, TXHASH_25526b),
request_output(1, TXHASH_25526b),
request_output(0),
request_output(1),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_25526b),
request_input(0, TXHASH_25526b),
request_output(0, TXHASH_25526b),
request_output(1, TXHASH_25526b),
request_input(0),
proto.Failure(code=proto.FailureType.ProcessError),
]
)
@ -227,15 +231,16 @@ class TestMsgSigntxBitcoinGold:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_25526b),
request_input(0, TXHASH_25526b),
request_output(0, TXHASH_25526b),
request_output(1, TXHASH_25526b),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_25526b),
request_input(0, TXHASH_25526b),
request_output(0, TXHASH_25526b),
request_output(1, TXHASH_25526b),
request_input(0),
request_output(0),
request_output(1),
request_finished(),
@ -264,15 +269,16 @@ class TestMsgSigntxBitcoinGold:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_25526b),
request_input(0, TXHASH_25526b),
request_output(0, TXHASH_25526b),
request_output(1, TXHASH_25526b),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_25526b),
request_input(0, TXHASH_25526b),
request_output(0, TXHASH_25526b),
request_output(1, TXHASH_25526b),
request_input(0),
request_output(0),
request_output(1),
request_finished(),
@ -313,16 +319,17 @@ class TestMsgSigntxBitcoinGold:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_25526b),
request_input(0, TXHASH_25526b),
request_output(0, TXHASH_25526b),
request_output(1, TXHASH_25526b),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_25526b),
request_input(0, TXHASH_25526b),
request_output(0, TXHASH_25526b),
request_output(1, TXHASH_25526b),
request_input(0),
request_output(0),
request_output(1),
request_input(0),
@ -360,15 +367,16 @@ class TestMsgSigntxBitcoinGold:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_25526b),
request_input(0, TXHASH_25526b),
request_output(0, TXHASH_25526b),
request_output(1, TXHASH_25526b),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_25526b),
request_input(0, TXHASH_25526b),
request_output(0, TXHASH_25526b),
request_output(1, TXHASH_25526b),
request_input(0),
request_output(0),
request_output(1),
request_input(0),
@ -414,14 +422,15 @@ class TestMsgSigntxBitcoinGold:
with client:
client.set_expected_responses(
[
request_input(0),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_25526b),
request_input(0, TXHASH_25526b),
request_output(0, TXHASH_25526b),
request_output(1, TXHASH_25526b),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
request_input(0),
@ -437,14 +446,15 @@ class TestMsgSigntxBitcoinGold:
inp1.address_n[2] = H_(3)
client.set_expected_responses(
[
request_input(0),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_25526b),
request_input(0, TXHASH_25526b),
request_output(0, TXHASH_25526b),
request_output(1, TXHASH_25526b),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
request_input(0),
@ -523,14 +533,15 @@ class TestMsgSigntxBitcoinGold:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_25526b),
request_input(0, TXHASH_25526b),
request_output(0, TXHASH_25526b),
request_output(1, TXHASH_25526b),
request_input(1),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_25526b),
request_input(0, TXHASH_25526b),
request_output(0, TXHASH_25526b),
request_output(1, TXHASH_25526b),
request_input(1),
request_meta(TXHASH_f55c5b),
request_input(0, TXHASH_f55c5b),

View File

@ -58,15 +58,16 @@ class TestMsgSigntxDash:
with client:
client.set_expected_responses(
[
request_input(0),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(inp1.prev_hash),
request_input(0, inp1.prev_hash),
request_input(1, inp1.prev_hash),
request_output(0, inp1.prev_hash),
request_output(1, inp1.prev_hash),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
request_output(0),
@ -104,16 +105,17 @@ class TestMsgSigntxDash:
with client:
client.set_expected_responses(
[
request_input(0),
request_output(0),
request_output(1),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(inp1.prev_hash),
request_input(0, inp1.prev_hash),
request_output(0, inp1.prev_hash),
request_output(1, inp1.prev_hash),
request_extra_data(0, 39, inp1.prev_hash),
request_output(0),
request_output(1),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
request_output(1),

View File

@ -55,6 +55,7 @@ class TestMsgSigntxDecred:
address_n=parse_path("m/44'/1'/0'/0/0"),
prev_hash=TXHASH_e16248,
prev_index=1,
amount=200000000,
script_type=proto.InputScriptType.SPENDADDRESS,
decred_tree=0,
)
@ -69,15 +70,16 @@ class TestMsgSigntxDecred:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_e16248),
request_input(0, TXHASH_e16248),
request_output(0, TXHASH_e16248),
request_output(1, TXHASH_e16248),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.FeeOverThreshold),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_e16248),
request_input(0, TXHASH_e16248),
request_output(0, TXHASH_e16248),
request_output(1, TXHASH_e16248),
request_input(0),
request_finished(),
]
)
@ -87,13 +89,14 @@ class TestMsgSigntxDecred:
assert (
serialized_tx.hex()
== "0100000001edd579e9462ee0e80127a817e0500d4f942a4cf8f2d6530e0c0a9ab3f04862e10100000000ffffffff01802b530b0000000000001976a914819d291a2f7fbf770e784bfd78b5ce92c58e95ea88ac000000000000000001000000000000000000000000ffffffff6a473044022009e394c7dec76ab6988270b467839b1462ad781556bce37383b76e026418ce6302204f7f6ef535d2986b095d7c96232a0990a0b9ce3004894b39c167bb18e5833ac30121030e669acac1f280d1ddf441cd2ba5e97417bf2689e4bbec86df4f831bf9f7ffd0"
== "0100000001edd579e9462ee0e80127a817e0500d4f942a4cf8f2d6530e0c0a9ab3f04862e10100000000ffffffff01802b530b0000000000001976a914819d291a2f7fbf770e784bfd78b5ce92c58e95ea88ac00000000000000000100c2eb0b0000000000000000ffffffff6a473044022009e394c7dec76ab6988270b467839b1462ad781556bce37383b76e026418ce6302204f7f6ef535d2986b095d7c96232a0990a0b9ce3004894b39c167bb18e5833ac30121030e669acac1f280d1ddf441cd2ba5e97417bf2689e4bbec86df4f831bf9f7ffd0"
)
def test_send_decred_change(self, client):
inp1 = proto.TxInputType(
# TscqTv1he8MZrV321SfRghw7LFBCJDKB3oz
address_n=parse_path("m/44'/1'/0'/0/0"),
amount=190000000,
prev_hash=TXHASH_5e6e35,
prev_index=0,
script_type=proto.InputScriptType.SPENDADDRESS,
@ -103,6 +106,7 @@ class TestMsgSigntxDecred:
inp2 = proto.TxInputType(
# TscqTv1he8MZrV321SfRghw7LFBCJDKB3oz
address_n=parse_path("m/44'/1'/0'/0/0"),
amount=200000000,
prev_hash=TXHASH_ccf95b,
prev_index=1,
script_type=proto.InputScriptType.SPENDADDRESS,
@ -112,6 +116,7 @@ class TestMsgSigntxDecred:
inp3 = proto.TxInputType(
# Tskt39YEvzoJ5KBDH4f1auNzG3jViVjZ2RV
address_n=parse_path("m/44'/1'/0'/0/1"),
amount=200000000,
prev_hash=TXHASH_f395ef,
prev_index=0,
script_type=proto.InputScriptType.SPENDADDRESS,
@ -134,6 +139,13 @@ class TestMsgSigntxDecred:
with client:
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_input(2),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_5e6e35),
request_input(0, TXHASH_5e6e35),
@ -148,10 +160,6 @@ class TestMsgSigntxDecred:
request_input(0, TXHASH_f395ef),
request_output(0, TXHASH_f395ef),
request_output(1, TXHASH_f395ef),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_input(1),
request_input(2),
@ -168,7 +176,7 @@ class TestMsgSigntxDecred:
assert (
serialized_tx.hex()
== "010000000370b95980a47b9bcb4ec2c2b450888a53179b1a5fdb23f5023cc533a300356e5e0000000000ffffffff74bc93bcfce18aff2e522d6822817522e2815a00175b2eae59ef20d20f5bf9cc0100000000ffffffff13317ab453832deabd684d2302eed42580c28ba3e715db66a731a8723eef95f30000000000ffffffff02d86c341d0000000000001976a9143eb656115197956125365348c542e37b6d3d259988ac00e1f5050000000000001976a9143ee6f9d662e7be18373d80e5eb44627014c2bf6688ac000000000000000003000000000000000000000000ffffffff6a47304402200e50a6d43c462045917792e7d03b4354900c3baccb7abef66f556a32b12f2ca6022031ae94fdf2a41dd6ed2e081faf0f8f1c64411a1b46eb26f7f35d94402b2bde110121030e669acac1f280d1ddf441cd2ba5e97417bf2689e4bbec86df4f831bf9f7ffd0000000000000000000000000ffffffff6a47304402204894c2f8e76c4645d2df600cdd01443aeb48807b72150c4bc10eebd126529532022054cd37462a3f0ddb85c75b4e874ab0c2aad7eebcff3e6c1ac20e1c16babe36720121030e669acac1f280d1ddf441cd2ba5e97417bf2689e4bbec86df4f831bf9f7ffd0000000000000000000000000ffffffff6b4830450221009f1ba584023da8aafd57374e83be68f1a097b906967ec9e50736f31bfc7989f102204a190fc2885e394572b5c2ced046657b1dd07abdb19144e21e78987968c7f17601210294e3e5e77e22eea0e4c0d30d89beb4db7f69b4bf1ae709e411d6a06618b8f852"
== "010000000370b95980a47b9bcb4ec2c2b450888a53179b1a5fdb23f5023cc533a300356e5e0000000000ffffffff74bc93bcfce18aff2e522d6822817522e2815a00175b2eae59ef20d20f5bf9cc0100000000ffffffff13317ab453832deabd684d2302eed42580c28ba3e715db66a731a8723eef95f30000000000ffffffff02d86c341d0000000000001976a9143eb656115197956125365348c542e37b6d3d259988ac00e1f5050000000000001976a9143ee6f9d662e7be18373d80e5eb44627014c2bf6688ac000000000000000003802b530b0000000000000000ffffffff6a47304402200e50a6d43c462045917792e7d03b4354900c3baccb7abef66f556a32b12f2ca6022031ae94fdf2a41dd6ed2e081faf0f8f1c64411a1b46eb26f7f35d94402b2bde110121030e669acac1f280d1ddf441cd2ba5e97417bf2689e4bbec86df4f831bf9f7ffd000c2eb0b0000000000000000ffffffff6a47304402204894c2f8e76c4645d2df600cdd01443aeb48807b72150c4bc10eebd126529532022054cd37462a3f0ddb85c75b4e874ab0c2aad7eebcff3e6c1ac20e1c16babe36720121030e669acac1f280d1ddf441cd2ba5e97417bf2689e4bbec86df4f831bf9f7ffd000c2eb0b0000000000000000ffffffff6b4830450221009f1ba584023da8aafd57374e83be68f1a097b906967ec9e50736f31bfc7989f102204a190fc2885e394572b5c2ced046657b1dd07abdb19144e21e78987968c7f17601210294e3e5e77e22eea0e4c0d30d89beb4db7f69b4bf1ae709e411d6a06618b8f852"
)
@pytest.mark.multisig
@ -195,6 +203,7 @@ class TestMsgSigntxDecred:
address_n=address_n,
# TchpthUkRys1VQWgnQyLJNaA4MLBjVmRL2c
multisig=multisig,
amount=200000000,
prev_hash=TXHASH_3f7c39,
prev_index=1,
script_type=proto.InputScriptType.SPENDMULTISIG,
@ -206,6 +215,7 @@ class TestMsgSigntxDecred:
address_n=address_n,
# TcnfDEfMhkM3oLWqiq9v9GmYgLK7qfjitKG
multisig=multisig,
amount=200000000,
prev_hash=TXHASH_16da18,
prev_index=0,
script_type=proto.InputScriptType.SPENDMULTISIG,
@ -230,6 +240,12 @@ class TestMsgSigntxDecred:
with client:
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
request_output(1),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_3f7c39),
request_input(0, TXHASH_3f7c39),
@ -240,10 +256,6 @@ class TestMsgSigntxDecred:
request_input(0, TXHASH_16da18),
request_output(0, TXHASH_16da18),
request_output(1, TXHASH_16da18),
request_output(0),
request_output(1),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_input(1),
request_finished(),
@ -266,5 +278,5 @@ class TestMsgSigntxDecred:
assert (
serialized_tx.hex()
== "01000000023f4c9e61b1cf469cad3785a03566ef23876217fe657561e78783d32155397c3f0100000000ffffffffa806ca135db5160eb91202506ce2645b215805149ce730a6850d74525018da160000000000ffffffff02605af40500000000000017a9142eea8efc154375a0e95fa7849a84cbce38fc9e138700a3e1110000000000001976a9143eb656115197956125365348c542e37b6d3d259988ac000000000000000002000000000000000000000000fffffffffb47304402205aa748d00fbf632fb85bdb31f52713413d455c560aca2243d3ad6605ee6c590c02200c15581cd87a3454a2f1cccf9660d3a3af94763133721202992e8e44ac9051cd01473044022030ee91f21a813dc36af48da4c57c0043c08c6669b831f4b45e1fb62bf627992c02205643c5150e47528d696cc912d7f542788c31affdf903e38f70f97f4056805b3f014c69522102af12ddd0d55e4fa2fcd084148eaf5b0b641320d0431d63d1e9a90f3cbd0d54072102b952c919f91b8252fc1ccd3aed5c16364e19f11063a9c0da35c7142cc5d5dea4210386037d07c629b9a6cd9e966894527f6bfaf6a13e5c18396f536d360ecae35b7c53ae000000000000000000000000fffffffffc4730440220643f64dcdfe8ed70120f6bb7b32b57acf2136e82f74a88baa8d5603448dd46f9022000f324eba92d79d688afff68704600949bd2f8f47f6fa932e333810b19efe8d701483045022100fe8e52118e769af69028b47acb62d21c3f9f417afa5d217d8351b26c942c9bf5022020ae88a2fa109be7e3ba3936db1435a3e04123e91811949d166d9c808f45f681014c69522102faf963264abfdc1907f0fbfea80e2d7b79c6e017b57ad9f18e89222382137440210240f15dc02925879548f66c8cfde23309dfda287a50b277bd6a4c736725a699592102f1897184f21c582fcf1dabcc15c87668de7ca98b32579b9d092ce4b4db0e16c053ae"
== "01000000023f4c9e61b1cf469cad3785a03566ef23876217fe657561e78783d32155397c3f0100000000ffffffffa806ca135db5160eb91202506ce2645b215805149ce730a6850d74525018da160000000000ffffffff02605af40500000000000017a9142eea8efc154375a0e95fa7849a84cbce38fc9e138700a3e1110000000000001976a9143eb656115197956125365348c542e37b6d3d259988ac00000000000000000200c2eb0b0000000000000000fffffffffb47304402205aa748d00fbf632fb85bdb31f52713413d455c560aca2243d3ad6605ee6c590c02200c15581cd87a3454a2f1cccf9660d3a3af94763133721202992e8e44ac9051cd01473044022030ee91f21a813dc36af48da4c57c0043c08c6669b831f4b45e1fb62bf627992c02205643c5150e47528d696cc912d7f542788c31affdf903e38f70f97f4056805b3f014c69522102af12ddd0d55e4fa2fcd084148eaf5b0b641320d0431d63d1e9a90f3cbd0d54072102b952c919f91b8252fc1ccd3aed5c16364e19f11063a9c0da35c7142cc5d5dea4210386037d07c629b9a6cd9e966894527f6bfaf6a13e5c18396f536d360ecae35b7c53ae00c2eb0b0000000000000000fffffffffc4730440220643f64dcdfe8ed70120f6bb7b32b57acf2136e82f74a88baa8d5603448dd46f9022000f324eba92d79d688afff68704600949bd2f8f47f6fa932e333810b19efe8d701483045022100fe8e52118e769af69028b47acb62d21c3f9f417afa5d217d8351b26c942c9bf5022020ae88a2fa109be7e3ba3936db1435a3e04123e91811949d166d9c808f45f681014c69522102faf963264abfdc1907f0fbfea80e2d7b79c6e017b57ad9f18e89222382137440210240f15dc02925879548f66c8cfde23309dfda287a50b277bd6a4c736725a699592102f1897184f21c582fcf1dabcc15c87668de7ca98b32579b9d092ce4b4db0e16c053ae"
)

View File

@ -61,7 +61,7 @@ def test_p2pkh_presigned(client):
address_n=parse_path("m/44h/1h/0h/0/0"),
prev_hash=TXHASH_e5040e,
prev_index=0,
# amount=31000000,
amount=31000000,
)
inp1ext = proto.TxInputType(
@ -81,7 +81,7 @@ def test_p2pkh_presigned(client):
address_n=parse_path("m/44h/1h/0h/0/1"),
prev_hash=TXHASH_d830b8,
prev_index=1,
# amount=600000000,
amount=600000000,
)
inp2ext = proto.TxInputType(
@ -187,10 +187,6 @@ def test_p2wpkh_in_p2sh_presigned(client):
[
request_input(0),
request_input(1),
request_meta(TXHASH_65b811),
request_input(0, TXHASH_65b811),
request_output(0, TXHASH_65b811),
request_output(1, TXHASH_65b811),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
@ -203,6 +199,11 @@ def test_p2wpkh_in_p2sh_presigned(client):
request_input(0, TXHASH_091446),
request_output(0, TXHASH_091446),
request_output(1, TXHASH_091446),
request_input(1),
request_meta(TXHASH_65b811),
request_input(0, TXHASH_65b811),
request_output(0, TXHASH_65b811),
request_output(1, TXHASH_65b811),
request_input(0),
request_input(1),
request_output(0),
@ -233,10 +234,6 @@ def test_p2wpkh_in_p2sh_presigned(client):
[
request_input(0),
request_input(1),
request_meta(TXHASH_65b811),
request_input(0, TXHASH_65b811),
request_output(0, TXHASH_65b811),
request_output(1, TXHASH_65b811),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
@ -352,14 +349,15 @@ def test_p2wsh_external_presigned(client):
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_091446),
request_input(0, TXHASH_091446),
request_output(0, TXHASH_091446),
request_output(1, TXHASH_091446),
request_input(1),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_091446),
request_input(0, TXHASH_091446),
request_output(0, TXHASH_091446),
request_output(1, TXHASH_091446),
request_input(1),
request_meta(TXHASH_a345b8),
request_input(0, TXHASH_a345b8),
@ -388,14 +386,15 @@ def test_p2wsh_external_presigned(client):
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_091446),
request_input(0, TXHASH_091446),
request_output(0, TXHASH_091446),
request_output(1, TXHASH_091446),
request_input(1),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_091446),
request_input(0, TXHASH_091446),
request_output(0, TXHASH_091446),
request_output(1, TXHASH_091446),
request_input(1),
request_meta(TXHASH_a345b8),
request_input(0, TXHASH_a345b8),
@ -459,10 +458,6 @@ def test_p2wpkh_with_proof(client):
[
request_input(0),
request_input(1),
request_meta(TXHASH_65b811),
request_input(0, TXHASH_65b811),
request_output(0, TXHASH_65b811),
request_output(1, TXHASH_65b811),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
@ -473,6 +468,11 @@ def test_p2wpkh_with_proof(client):
request_input(0, TXHASH_e5b7e2),
request_output(0, TXHASH_e5b7e2),
request_output(1, TXHASH_e5b7e2),
request_input(1),
request_meta(TXHASH_65b811),
request_input(0, TXHASH_65b811),
request_output(0, TXHASH_65b811),
request_output(1, TXHASH_65b811),
request_input(0),
request_input(1),
request_output(0),
@ -531,14 +531,15 @@ def test_p2wpkh_with_false_proof(client):
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_70f987),
request_input(0, TXHASH_70f987),
request_output(0, TXHASH_70f987),
request_output(1, TXHASH_70f987),
request_input(1),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_70f987),
request_input(0, TXHASH_70f987),
request_output(0, TXHASH_70f987),
request_output(1, TXHASH_70f987),
request_input(1),
request_meta(TXHASH_65b768),
request_input(0, TXHASH_65b768),

View File

@ -42,6 +42,7 @@ class TestMsgSigntxGRS:
inp1 = proto.TxInputType(
# FXHDsC5ZqWQHkDmShzgRVZ1MatpWhwxTAA
address_n=parse_path("44'/17'/0'/0/2"),
amount=210016,
prev_hash=TXHASH_cb74c8,
prev_index=0,
)
@ -62,6 +63,7 @@ class TestMsgSigntxGRS:
inp1 = proto.TxInputType(
# FXHDsC5ZqWQHkDmShzgRVZ1MatpWhwxTAA
address_n=parse_path("44'/17'/0'/0/2"),
amount=210016,
prev_hash=TXHASH_cb74c8,
prev_index=0,
)

View File

@ -46,7 +46,7 @@ class TestMsgSigntxInvalidPath:
inp1 = proto.TxInputType(
address_n=parse_path("44h/0h/0h/0/0"),
# amount=390000,
amount=390000,
prev_hash=TXHASH_d5f65e,
prev_index=0,
)

View File

@ -64,15 +64,16 @@ class TestMsgSigntxKomodo:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_2807c),
request_input(0, TXHASH_2807c),
request_output(0, TXHASH_2807c),
request_extra_data(0, 11, TXHASH_2807c),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_2807c),
request_input(0, TXHASH_2807c),
request_output(0, TXHASH_2807c),
request_extra_data(0, 11, TXHASH_2807c),
request_input(0),
request_output(0),
request_finished(),
]
@ -123,10 +124,6 @@ class TestMsgSigntxKomodo:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_7b28bd),
request_input(0, TXHASH_7b28bd),
request_output(0, TXHASH_7b28bd),
request_extra_data(0, 11, TXHASH_7b28bd),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
@ -134,6 +131,11 @@ class TestMsgSigntxKomodo:
proto.ButtonRequest(code=B.SignTx),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_7b28bd),
request_input(0, TXHASH_7b28bd),
request_output(0, TXHASH_7b28bd),
request_extra_data(0, 11, TXHASH_7b28bd),
request_input(0),
request_output(0),
request_output(1),
request_finished(),

View File

@ -43,7 +43,7 @@ def test_non_segwit_segwit_inputs(client):
inp1 = messages.TxInputType(
address_n=parse_path("44'/1'/0'/0/0"),
# amount=31000000,
amount=31000000,
prev_hash=TXHASH_e5040e,
prev_index=0,
)
@ -93,7 +93,7 @@ def test_segwit_non_segwit_inputs(client):
)
inp2 = messages.TxInputType(
address_n=parse_path("44'/1'/0'/0/0"),
# amount=31000000,
amount=31000000,
prev_hash=TXHASH_e5040e,
prev_index=0,
)
@ -136,7 +136,7 @@ def test_segwit_non_segwit_segwit_inputs(client):
)
inp2 = messages.TxInputType(
address_n=parse_path("44'/1'/0'/0/0"),
# amount=31000000,
amount=31000000,
prev_hash=TXHASH_e5040e,
prev_index=0,
)
@ -183,7 +183,7 @@ def test_non_segwit_segwit_non_segwit_inputs(client):
inp1 = messages.TxInputType(
address_n=parse_path("44'/1'/0'/0/0"),
# amount=31000000,
amount=31000000,
prev_hash=TXHASH_e5040e,
prev_index=0,
)
@ -195,7 +195,10 @@ def test_non_segwit_segwit_non_segwit_inputs(client):
script_type=messages.InputScriptType.SPENDWITNESS,
)
inp3 = messages.TxInputType(
address_n=parse_path("44'/1'/1'/0/0"), prev_hash=TXHASH_2bac7a, prev_index=0,
address_n=parse_path("44'/1'/1'/0/0"),
amount=9226912,
prev_hash=TXHASH_2bac7a,
prev_index=0,
)
out1 = messages.TxOutputType(
address="tb1q54un3q39sf7e7tlfq99d6ezys7qgc62a6rxllc",

View File

@ -36,7 +36,10 @@ def test_timestamp_included(client):
# input 0: 0.1 PPC
inp1 = messages.TxInputType(
address_n=parse_path("m/44'/6'/0'/0/0"), prev_hash=TXHASH_41b29a, prev_index=0
address_n=parse_path("m/44'/6'/0'/0/0"),
amount=100000,
prev_hash=TXHASH_41b29a,
prev_index=0,
)
out1 = messages.TxOutputType(
@ -60,7 +63,10 @@ def test_timestamp_included(client):
@pytest.mark.skip_ui
def test_timestamp_missing(client):
inp1 = messages.TxInputType(
address_n=parse_path("m/44'/6'/0'/0/0"), prev_hash=TXHASH_41b29a, prev_index=0
address_n=parse_path("m/44'/6'/0'/0/0"),
amount=100000,
prev_hash=TXHASH_41b29a,
prev_index=0,
)
out1 = messages.TxOutputType(
address="PXtfyTjzgXSgTwK5AbszdHQSSxyQN3BLM5",
@ -86,7 +92,10 @@ def test_timestamp_missing(client):
@pytest.mark.skip_ui
def test_timestamp_missing_prevtx(client):
inp1 = messages.TxInputType(
address_n=parse_path("m/44'/6'/0'/0/0"), prev_hash=TXHASH_41b29a, prev_index=0
address_n=parse_path("m/44'/6'/0'/0/0"),
amount=100000,
prev_hash=TXHASH_41b29a,
prev_index=0,
)
out1 = messages.TxOutputType(
address="PXtfyTjzgXSgTwK5AbszdHQSSxyQN3BLM5",

View File

@ -107,7 +107,7 @@ def test_invalid_prev_hash_attack(client, prev_hash):
)
out1 = messages.TxOutputType(
address="1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1",
amount=12300000,
amount=100000000 - 10000,
script_type=messages.OutputScriptType.PAYTOADDRESS,
)
@ -148,7 +148,10 @@ def test_invalid_prev_hash_in_prevtx(client, prev_hash):
tx_hash = hash_tx(serialize_tx(prev_tx))
inp0 = messages.TxInputType(
address_n=tools.parse_path("m/44h/0h/0h/0/0"), prev_hash=tx_hash, prev_index=0
address_n=tools.parse_path("m/44h/0h/0h/0/0"),
amount=100000000,
prev_hash=tx_hash,
prev_index=0,
)
out1 = messages.TxOutputType(
address="1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1",

View File

@ -64,16 +64,17 @@ class TestMsgSigntxSegwit:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_20912f),
request_input(0, TXHASH_20912f),
request_output(0, TXHASH_20912f),
request_output(1, TXHASH_20912f),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_20912f),
request_input(0, TXHASH_20912f),
request_output(0, TXHASH_20912f),
request_output(1, TXHASH_20912f),
request_input(0),
request_output(0),
request_output(1),
request_input(0),
@ -112,15 +113,16 @@ class TestMsgSigntxSegwit:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_20912f),
request_input(0, TXHASH_20912f),
request_output(0, TXHASH_20912f),
request_output(1, TXHASH_20912f),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_20912f),
request_input(0, TXHASH_20912f),
request_output(0, TXHASH_20912f),
request_output(1, TXHASH_20912f),
request_input(0),
request_output(0),
request_output(1),
request_input(0),
@ -155,12 +157,13 @@ class TestMsgSigntxSegwit:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_dee13c),
request_output(0, TXHASH_dee13c),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_dee13c),
request_output(0, TXHASH_dee13c),
request_input(0),
request_output(0),
request_input(0),
request_finished(),
@ -205,14 +208,15 @@ class TestMsgSigntxSegwit:
with client:
client.set_expected_responses(
[
request_input(0),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_9c3192),
request_input(0, TXHASH_9c3192),
request_output(0, TXHASH_9c3192),
request_output(1, TXHASH_9c3192),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
request_input(0),
@ -228,14 +232,15 @@ class TestMsgSigntxSegwit:
inp1.address_n[2] = H_(3)
client.set_expected_responses(
[
request_input(0),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_9c3192),
request_input(0, TXHASH_9c3192),
request_output(0, TXHASH_9c3192),
request_output(1, TXHASH_9c3192),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
request_input(0),
@ -276,16 +281,17 @@ class TestMsgSigntxSegwit:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_20912f),
request_input(0, TXHASH_20912f),
request_output(0, TXHASH_20912f),
request_output(1, TXHASH_20912f),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_20912f),
request_input(0, TXHASH_20912f),
request_output(0, TXHASH_20912f),
request_output(1, TXHASH_20912f),
request_input(0),
request_output(0),
request_output(1),
request_input(0),
@ -301,13 +307,13 @@ class TestMsgSigntxSegwit:
== "0100000000010137c361fb8f2d9056ba8c98c5611930fcb48cacfdd0fe2e0449d83eea982f91200000000017160014d16b8c0680c61fc6ed2e407455715055e41052f5ffffffff02e0aebb00000000001976a91414fdede0ddc3be652a0ce1afbc1b509a55b6b94888ac3df39f060000000017a9142f98413cb83ff8b3eaf1926192e68973cbd68a3a8702473044022013cbce7c575337ca05dbe03b5920a0805b510cd8dfd3180bd7c5d01cec6439cd0220050001be4bcefb585caf973caae0ffec682347f2127cc22f26efd93ee54fd852012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7900000000"
)
run_attack = True
attack_count = 2
def attack_processor(msg):
nonlocal run_attack
nonlocal attack_count
if run_attack and msg.tx.inputs and msg.tx.inputs[0] == inp1:
run_attack = False
if attack_count > 0 and msg.tx.inputs and msg.tx.inputs[0] == inp1:
attack_count -= 1
msg.tx.inputs[0].address_n[2] = H_(12)
return msg
@ -318,15 +324,16 @@ class TestMsgSigntxSegwit:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_20912f),
request_input(0, TXHASH_20912f),
request_output(0, TXHASH_20912f),
request_output(1, TXHASH_20912f),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_20912f),
request_input(0, TXHASH_20912f),
request_output(0, TXHASH_20912f),
request_output(1, TXHASH_20912f),
request_input(0),
proto.Failure(code=proto.FailureType.ProcessError),
]
)
@ -342,7 +349,7 @@ class TestMsgSigntxSegwit:
def test_attack_mixed_inputs(self, client):
TRUE_AMOUNT = 123456789
FAKE_AMOUNT = 123
FAKE_AMOUNT = 120000000
inp1 = proto.TxInputType(
address_n=parse_path("44'/1'/0'/0/0"),
@ -367,6 +374,12 @@ class TestMsgSigntxSegwit:
)
expected_responses = [
request_input(0),
request_input(1),
request_output(0),
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
proto.ButtonRequest(code=proto.ButtonRequestType.FeeOverThreshold),
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
request_input(0),
request_meta(TXHASH_e5040e),
request_input(0, TXHASH_e5040e),
@ -377,10 +390,6 @@ class TestMsgSigntxSegwit:
request_input(0, TXHASH_20912f),
request_output(0, TXHASH_20912f),
request_output(1, TXHASH_20912f),
request_output(0),
proto.ButtonRequest(code=proto.ButtonRequestType.ConfirmOutput),
proto.ButtonRequest(code=proto.ButtonRequestType.FeeOverThreshold),
proto.ButtonRequest(code=proto.ButtonRequestType.SignTx),
request_input(0),
request_input(1),
request_output(0),
@ -407,9 +416,13 @@ class TestMsgSigntxSegwit:
if client.features.model == "1":
# T1 fails as soon as it encounters the fake amount.
expected_responses = expected_responses[:9] + [proto.Failure()]
expected_responses = (
expected_responses[:4] + expected_responses[5:15] + [proto.Failure()]
)
else:
expected_responses = expected_responses[:10] + [proto.Failure()]
expected_responses = (
expected_responses[:4] + expected_responses[5:16] + [proto.Failure()]
)
with pytest.raises(TrezorFailure) as e, client:
client.set_expected_responses(expected_responses)

View File

@ -79,16 +79,17 @@ class TestMsgSigntxSegwitNative:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_20912f),
request_input(0, TXHASH_20912f),
request_output(0, TXHASH_20912f),
request_output(1, TXHASH_20912f),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_20912f),
request_input(0, TXHASH_20912f),
request_output(0, TXHASH_20912f),
request_output(1, TXHASH_20912f),
request_input(0),
request_output(0),
request_output(1),
request_input(0),
@ -127,15 +128,16 @@ class TestMsgSigntxSegwitNative:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_20912f),
request_input(0, TXHASH_20912f),
request_output(0, TXHASH_20912f),
request_output(1, TXHASH_20912f),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_20912f),
request_input(0, TXHASH_20912f),
request_output(0, TXHASH_20912f),
request_output(1, TXHASH_20912f),
request_input(0),
request_output(0),
request_output(1),
request_input(0),
@ -173,16 +175,17 @@ class TestMsgSigntxSegwitNative:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_091446),
request_input(0, TXHASH_091446),
request_output(0, TXHASH_091446),
request_output(1, TXHASH_091446),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_091446),
request_input(0, TXHASH_091446),
request_output(0, TXHASH_091446),
request_output(1, TXHASH_091446),
request_input(0),
request_output(0),
request_output(1),
request_input(0),
@ -220,15 +223,16 @@ class TestMsgSigntxSegwitNative:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_091446),
request_input(0, TXHASH_091446),
request_output(0, TXHASH_091446),
request_output(1, TXHASH_091446),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_091446),
request_input(0, TXHASH_091446),
request_output(0, TXHASH_091446),
request_output(1, TXHASH_091446),
request_input(0),
request_output(0),
request_output(1),
request_input(0),
@ -281,6 +285,15 @@ class TestMsgSigntxSegwitNative:
with client:
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(2),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_091446),
request_input(0, TXHASH_091446),
@ -291,13 +304,6 @@ class TestMsgSigntxSegwitNative:
request_input(0, TXHASH_65b811),
request_output(0, TXHASH_65b811),
request_output(1, TXHASH_65b811),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(2),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_input(1),
request_output(0),
@ -350,14 +356,15 @@ class TestMsgSigntxSegwitNative:
with client:
client.set_expected_responses(
[
request_input(0),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_9c3192),
request_input(0, TXHASH_9c3192),
request_output(0, TXHASH_9c3192),
request_output(1, TXHASH_9c3192),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
request_input(0),
@ -373,14 +380,15 @@ class TestMsgSigntxSegwitNative:
inp1.address_n[2] = H_(3)
client.set_expected_responses(
[
request_input(0),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_9c3192),
request_input(0, TXHASH_9c3192),
request_output(0, TXHASH_9c3192),
request_output(1, TXHASH_9c3192),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
request_input(0),
@ -430,13 +438,14 @@ class TestMsgSigntxSegwitNative:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_f41cbe),
request_input(0, TXHASH_f41cbe),
request_output(0, TXHASH_f41cbe),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_f41cbe),
request_input(0, TXHASH_f41cbe),
request_output(0, TXHASH_f41cbe),
request_input(0),
request_output(0),
request_input(0),
request_finished(),
@ -452,13 +461,14 @@ class TestMsgSigntxSegwitNative:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_f41cbe),
request_input(0, TXHASH_f41cbe),
request_output(0, TXHASH_f41cbe),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_f41cbe),
request_input(0, TXHASH_f41cbe),
request_output(0, TXHASH_f41cbe),
request_input(0),
request_output(0),
request_input(0),
request_finished(),
@ -513,12 +523,13 @@ class TestMsgSigntxSegwitNative:
with client:
client.set_expected_responses(
[
request_input(0),
request_output(0),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_c93480),
request_input(0, TXHASH_c93480),
request_output(0, TXHASH_c93480),
request_output(0),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
request_input(0),
@ -535,12 +546,13 @@ class TestMsgSigntxSegwitNative:
out1.address_n[2] = H_(3)
client.set_expected_responses(
[
request_input(0),
request_output(0),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_c93480),
request_input(0, TXHASH_c93480),
request_output(0, TXHASH_c93480),
request_output(0),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
request_input(0),
@ -596,12 +608,13 @@ class TestMsgSigntxSegwitNative:
with client:
client.set_expected_responses(
[
request_input(0),
request_output(0),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_31bc1c),
request_input(0, TXHASH_31bc1c),
request_output(0, TXHASH_31bc1c),
request_output(0),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
request_input(0),
@ -618,12 +631,13 @@ class TestMsgSigntxSegwitNative:
out1.address_n[2] = H_(3)
client.set_expected_responses(
[
request_input(0),
request_output(0),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_31bc1c),
request_input(0, TXHASH_31bc1c),
request_output(0, TXHASH_31bc1c),
request_output(0),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
request_input(0),
@ -694,6 +708,14 @@ class TestMsgSigntxSegwitNative:
with client:
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
# Ensure that the multisig output is not identified as a change output.
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_091446),
request_input(0, TXHASH_091446),
@ -703,12 +725,6 @@ class TestMsgSigntxSegwitNative:
request_meta(TXHASH_a345b8),
request_input(0, TXHASH_a345b8),
request_output(0, TXHASH_a345b8),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
# Ensure that the multisig output is not identified as a change output.
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_input(1),
request_output(0),

View File

@ -110,6 +110,10 @@ class TestMsgSigntxZcash:
with client:
client.set_expected_responses(
[
request_input(0),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_e38206),
request_input(0, TXHASH_e38206),
@ -117,9 +121,6 @@ class TestMsgSigntxZcash:
request_output(0, TXHASH_e38206),
request_output(1, TXHASH_e38206),
request_extra_data(0, 1, TXHASH_e38206),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
request_finished(),
@ -259,6 +260,11 @@ class TestMsgSigntxZcash:
with client:
client.set_expected_responses(
[
request_input(0),
request_input(1),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_e38206),
request_input(0, TXHASH_e38206),
@ -267,10 +273,6 @@ class TestMsgSigntxZcash:
request_output(1, TXHASH_e38206),
request_extra_data(0, 1, TXHASH_e38206),
request_input(1),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(1),
request_meta(TXHASH_aaf51e),
request_input(0, TXHASH_aaf51e),
request_output(0, TXHASH_aaf51e),

View File

@ -52,6 +52,7 @@ class TestMultisig:
# Let's go to sign with key 1
inp1 = proto.TxInputType(
address_n=parse_path("48'/0'/1'/0/0"),
amount=100000,
prev_hash=TXHASH_c6091a,
prev_index=1,
script_type=proto.InputScriptType.SPENDMULTISIG,
@ -67,14 +68,15 @@ class TestMultisig:
with client:
client.set_expected_responses(
[
request_input(0),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_c6091a),
request_input(0, TXHASH_c6091a),
request_output(0, TXHASH_c6091a),
request_output(1, TXHASH_c6091a),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
request_output(0),
@ -109,6 +111,7 @@ class TestMultisig:
# Let's do a second signature with key 3
inp3 = proto.TxInputType(
address_n=parse_path("48'/0'/3'/0/0"),
amount=100000,
prev_hash=TXHASH_c6091a,
prev_index=1,
script_type=proto.InputScriptType.SPENDMULTISIG,
@ -118,14 +121,15 @@ class TestMultisig:
with client:
client.set_expected_responses(
[
request_input(0),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_c6091a),
request_input(0, TXHASH_c6091a),
request_output(0, TXHASH_c6091a),
request_output(1, TXHASH_c6091a),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
request_output(0),
@ -169,6 +173,7 @@ class TestMultisig:
inp1 = proto.TxInputType(
address_n=parse_path(f"48h/0h/1h/0/{x}"),
amount=20000,
prev_hash=TXHASH_6189e3,
prev_index=1,
script_type=proto.InputScriptType.SPENDMULTISIG,
@ -206,6 +211,7 @@ class TestMultisig:
# Let's go to sign with key 10, which is NOT in pubkeys
inp1 = proto.TxInputType(
address_n=parse_path("48h/0h/1h/0/10"),
amount=100000,
prev_hash=TXHASH_c6091a,
prev_index=1,
script_type=proto.InputScriptType.SPENDMULTISIG,
@ -278,7 +284,7 @@ class TestMultisig:
multisig=multisig_fake,
)
attack_count = 2
attack_count = 3
def attack_processor(msg):
nonlocal attack_count
@ -293,15 +299,16 @@ class TestMultisig:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_fbbff7),
request_input(0, TXHASH_fbbff7),
request_output(0, TXHASH_fbbff7),
request_output(1, TXHASH_fbbff7),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_fbbff7),
request_input(0, TXHASH_fbbff7),
request_output(0, TXHASH_fbbff7),
request_output(1, TXHASH_fbbff7),
request_input(0),
request_output(0),
request_output(1),
request_input(0),

View File

@ -105,6 +105,7 @@ class TestMultisigChange:
# 2N9W4z9AhAPaHghtqVQPbaTAGHdbrhKeBQw
inp1 = proto.TxInputType(
address_n=[H_(45), 0, 0, 0],
amount=50000000,
prev_hash=TXHASH_16c6c8,
prev_index=1,
script_type=proto.InputScriptType.SPENDMULTISIG,
@ -114,6 +115,7 @@ class TestMultisigChange:
# 2NDBG6QXQLtnQ3jRGkrqo53BiCeXfQXLdj4
inp2 = proto.TxInputType(
address_n=[H_(45), 0, 0, 1],
amount=34500000,
prev_hash=TXHASH_d80c34,
prev_index=0,
script_type=proto.InputScriptType.SPENDMULTISIG,
@ -123,6 +125,7 @@ class TestMultisigChange:
# 2MvwPWfp2XPU3S1cMwgEMKBPUw38VP5SBE4
inp3 = proto.TxInputType(
address_n=[H_(45), 0, 0, 1],
amount=55500000,
prev_hash=TXHASH_b0946d,
prev_index=0,
script_type=proto.InputScriptType.SPENDMULTISIG,
@ -131,6 +134,17 @@ class TestMultisigChange:
def _responses(self, inp1, inp2, change=0):
resp = [
request_input(0),
request_input(1),
request_output(0),
]
if change != 1:
resp.append(proto.ButtonRequest(code=B.ConfirmOutput))
resp.append(request_output(1))
if change != 2:
resp.append(proto.ButtonRequest(code=B.ConfirmOutput))
resp += [
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(inp1.prev_hash),
request_input(0, inp1.prev_hash),
@ -141,15 +155,6 @@ class TestMultisigChange:
request_input(0, inp2.prev_hash),
request_output(0, inp2.prev_hash),
request_output(1, inp2.prev_hash),
request_output(0),
]
if change != 1:
resp.append(proto.ButtonRequest(code=B.ConfirmOutput))
resp.append(request_output(1))
if change != 2:
resp.append(proto.ButtonRequest(code=B.ConfirmOutput))
resp += [
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_input(1),
request_output(0),

View File

@ -34,7 +34,10 @@ TXHASH_d5f65e = bytes.fromhex(
class TestOpReturn:
def test_opreturn(self, client):
inp1 = proto.TxInputType(
address_n=parse_path("44'/0'/0'/0/2"), prev_hash=TXHASH_d5f65e, prev_index=0
address_n=parse_path("44'/0'/0'/0/2"),
amount=390000,
prev_hash=TXHASH_d5f65e,
prev_index=0,
)
out1 = proto.TxOutputType(
@ -53,16 +56,17 @@ class TestOpReturn:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_d5f65e),
request_input(0, TXHASH_d5f65e),
request_input(1, TXHASH_d5f65e),
request_output(0, TXHASH_d5f65e),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
request_output(1),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_d5f65e),
request_input(0, TXHASH_d5f65e),
request_input(1, TXHASH_d5f65e),
request_output(0, TXHASH_d5f65e),
request_input(0),
request_output(0),
request_output(1),
request_output(0),
@ -83,6 +87,7 @@ class TestOpReturn:
def test_nonzero_opreturn(self, client):
inp1 = proto.TxInputType(
address_n=parse_path("44'/0'/10'/0/5"),
amount=390000,
prev_hash=TXHASH_d5f65e,
prev_index=0,
)
@ -95,15 +100,7 @@ class TestOpReturn:
with client:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_d5f65e),
request_input(0, TXHASH_d5f65e),
request_input(1, TXHASH_d5f65e),
request_output(0, TXHASH_d5f65e),
request_output(0),
proto.Failure(),
]
[request_input(0), request_output(0), proto.Failure()]
)
with pytest.raises(
@ -114,7 +111,10 @@ class TestOpReturn:
@pytest.mark.skip_ui
def test_opreturn_address(self, client):
inp1 = proto.TxInputType(
address_n=parse_path("44'/0'/0'/0/2"), prev_hash=TXHASH_d5f65e, prev_index=0
address_n=parse_path("44'/0'/0'/0/2"),
amount=390000,
prev_hash=TXHASH_d5f65e,
prev_index=0,
)
out1 = proto.TxOutputType(
@ -126,15 +126,7 @@ class TestOpReturn:
with client:
client.set_expected_responses(
[
request_input(0),
request_meta(TXHASH_d5f65e),
request_input(0, TXHASH_d5f65e),
request_input(1, TXHASH_d5f65e),
request_output(0, TXHASH_d5f65e),
request_output(0),
proto.Failure(),
]
[request_input(0), request_output(0), proto.Failure()]
)
with pytest.raises(
TrezorFailure, match="Output's address_n provided but not expected."

View File

@ -195,6 +195,7 @@ class TestProtectionLevels:
address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
prev_hash=TXHASH_d5f65e,
prev_index=0,
amount=390000,
)
out1 = proto.TxOutputType(
@ -211,13 +212,14 @@ class TestProtectionLevels:
proto.PinMatrixRequest(),
proto.PassphraseRequest(),
request_input(0),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_meta(TXHASH_d5f65e),
request_input(0, TXHASH_d5f65e),
request_input(1, TXHASH_d5f65e),
request_output(0, TXHASH_d5f65e),
request_output(0),
proto.ButtonRequest(code=B.ConfirmOutput),
proto.ButtonRequest(code=B.SignTx),
request_input(0),
request_output(0),
request_output(0),

View File

@ -55,14 +55,14 @@
"test_msg_applysettings.py-test_apply_settings_passphrase": "5c1ed9a0be3d14475102d447da0b5d51bbb6dfaaeceff5ea9179064609db7870",
"test_msg_applysettings.py-test_apply_settings_passphrase_on_device": "3e6527e227bdde54f51bc9c417b176d0d87fdb6c40c4761368f50eb201b4beed",
"test_msg_applysettings.py-test_safety_checks": "19bd500c3b791d51bbd1140085f306a838194593697529263f362acb0b1ab445",
"test_msg_backup_device.py::test_backup_bip39": "42325cccfc0bd54db180a01a076437ec981022338307339bb5e0f6463d842e23",
"test_msg_backup_device.py::test_backup_slip39_advanced": "9a01aa5ecdafa52571ed2149575f86ffea6c2984a2541ea8e5f9a7c37cf4c9fe",
"test_msg_backup_device.py::test_backup_slip39_basic": "57d841257b10c4f67cf76487c8f0bc95947a93a8e0b8c03d7a11894da3c233da",
"test_msg_authorize_coinjoin.py::test_cancel_authorization": "d8a608beb6165f5667cc44dcff6bdc17ebb4638ddd3bd09e7f0e1e75d1e21135",
"test_msg_authorize_coinjoin.py::test_no_anonymity": "fd09da284b650e893990b95047b63a35b6b695fc5301d595f17a6d2cf9d90bcb",
"test_msg_authorize_coinjoin.py::test_sign_tx": "2838d4062333c241b6bbef7e680ec8a5764fe7bcaa41419e4141e146d3586a5d",
"test_msg_authorize_coinjoin.py::test_unfair_fee": "62314e936de46a6caaf02c8eb20f6f471be6e79ca0c5450cad6f67f9cb823f2b",
"test_msg_authorize_coinjoin.py::test_wrong_coordinator": "d8a608beb6165f5667cc44dcff6bdc17ebb4638ddd3bd09e7f0e1e75d1e21135",
"test_msg_backup_device.py::test_backup_bip39": "42325cccfc0bd54db180a01a076437ec981022338307339bb5e0f6463d842e23",
"test_msg_backup_device.py::test_backup_slip39_advanced": "9a01aa5ecdafa52571ed2149575f86ffea6c2984a2541ea8e5f9a7c37cf4c9fe",
"test_msg_backup_device.py::test_backup_slip39_basic": "57d841257b10c4f67cf76487c8f0bc95947a93a8e0b8c03d7a11894da3c233da",
"test_msg_backup_device.py::test_interrupt_backup_fails": "8dc5c385fec6dd871a141e2efd83f767a5f3da85b2857c8ac27e054f9fa4b384",
"test_msg_backup_device.py::test_no_backup_fails": "93039a9472cfc9058563bd56e4a3dbe2e41af64744a61f6ee3255a04bd3a9366",
"test_msg_backup_device.py::test_no_backup_show_entropy_fails": "14fcdd2ded299ca099a35966cc9f21204b31de8d6bab9ec91cb64537bd70440c",
@ -314,17 +314,17 @@
"test_msg_signtx_external.py::test_p2wsh_external_presigned": "8374d50b803db0160de39ce7e5a4170112f4c99d703490920a2de735bd261bda",
"test_msg_signtx_grs.py-test_legacy": "3a80ea724a93ed225d64f8def739d63b11f8c096455f971feabec8be6f7597fb",
"test_msg_signtx_grs.py-test_legacy_change": "8dfc140534bdaa08f6916831dc0d510f57b07617f30df748e4e0456d4dd93ece",
"test_msg_signtx_invalid_path.py-test_invalid_path_fail": "b0f22cba2dbab2cd21c15c002b66ed89b6c728b10daa8d0c0e78abd4164a3912",
"test_msg_signtx_invalid_path.py-test_invalid_path_pass_forkid": "667dcb09b569e5b4e091e6b1ac7e8e057c0c730c931b22f8c0ee64050f3f467b",
"test_msg_signtx_grs.py-test_send_segwit_native": "82dfa15178d33e757da58943aff36dcc0eebb984e34832b71f6ca09b2a525cbc",
"test_msg_signtx_grs.py-test_send_segwit_native_change": "d8ae74de3aada1d136c4119f2306a63bd109901ce15d00ae916ba5b4457e798e",
"test_msg_signtx_grs.py-test_send_segwit_p2sh": "9ab885dd3b390813f8a47e1d1587abe07ab713e9f8696dc667b3a2925f23c103",
"test_msg_signtx_grs.py-test_send_segwit_p2sh_change": "6c352ab975a75a150f7c3415a967fb8635395ff8db0de89ecb9c2011cb519509",
"test_msg_signtx_invalid_path.py-test_invalid_path_fail": "b0f22cba2dbab2cd21c15c002b66ed89b6c728b10daa8d0c0e78abd4164a3912",
"test_msg_signtx_invalid_path.py-test_invalid_path_pass_forkid": "667dcb09b569e5b4e091e6b1ac7e8e057c0c730c931b22f8c0ee64050f3f467b",
"test_msg_signtx_komodo.py-test_one_one_fee_sapling": "14bad8852ee51f6fec12677cced9ffafa0cbae91b4ba94e988a800544072ed21",
"test_msg_signtx_komodo.py-test_one_one_rewards_claim": "751e83d63bf01c6c57047b5e004629d613df75342371cd43a7b4b80a07f4b88d",
"test_msg_signtx_peercoin.py::test_timestamp_included": "825b9bdf5238c5c6415a254a6bae4b2bd9df8fc5cb31f66f0c20145cb4e60bbb",
"test_msg_signtx_segwit.py-test_attack_change_input_address": "5ae71202c062ef7942626a80a4ceeb8d8c4ea5065a97f0de6a97505e9cb82c2c",
"test_msg_signtx_segwit.py-test_attack_mixed_inputs": "ed4cf8ff26ca1abb0adf20e1020dad7861b5e63ead2a1a9c0c5e9080d37f6f1c",
"test_msg_signtx_segwit.py-test_attack_mixed_inputs": "f127a4766b23d9b6dfe0c41f9cf1ed13c0a883ea4e92e55961bcaf44bd152c02",
"test_msg_signtx_segwit.py-test_send_multisig_1": "958a0741070e057dcb889b2000e5487d391bc513e4a5d86193a355261c5f361b",
"test_msg_signtx_segwit.py-test_send_p2sh": "ca593e31e919b9e920289b13e4c70b9607f34b93d06ace69835e3d08ecf046c8",
"test_msg_signtx_segwit.py-test_send_p2sh_change": "562c7ee5a2e264c9f93387dd165403dab32bb305a4c3a6143a902c4a4c9e5950",