2018-06-21 14:28:34 +00:00
|
|
|
# This file is part of the Trezor project.
|
2017-01-03 18:40:05 +00:00
|
|
|
#
|
2019-05-29 16:44:09 +00:00
|
|
|
# Copyright (C) 2012-2019 SatoshiLabs and contributors
|
2017-01-03 18:40:05 +00:00
|
|
|
#
|
|
|
|
# This library is free software: you can redistribute it and/or modify
|
2018-06-21 14:28:34 +00:00
|
|
|
# it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
# as published by the Free Software Foundation.
|
2017-01-03 18:40:05 +00:00
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Lesser General Public License for more details.
|
|
|
|
#
|
2018-06-21 14:28:34 +00:00
|
|
|
# You should have received a copy of the License along with this library.
|
|
|
|
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
2017-01-03 18:40:05 +00:00
|
|
|
|
2018-05-22 17:13:59 +00:00
|
|
|
import pytest
|
2016-05-20 20:27:20 +00:00
|
|
|
|
2024-03-11 15:20:08 +00:00
|
|
|
from trezorlib import btc, messages, models
|
2022-01-31 12:25:30 +00:00
|
|
|
from trezorlib.debuglink import TrezorClientDebugLink as Client
|
2020-03-24 13:18:08 +00:00
|
|
|
from trezorlib.exceptions import TrezorFailure
|
2022-01-24 20:23:58 +00:00
|
|
|
from trezorlib.tools import parse_path
|
2014-12-04 00:30:41 +00:00
|
|
|
|
2024-03-09 21:05:05 +00:00
|
|
|
from ...common import MNEMONIC12, is_core
|
2024-05-21 21:49:08 +00:00
|
|
|
from ...input_flows import InputFlowConfirmAllWarnings
|
2021-11-29 11:00:01 +00:00
|
|
|
from ...tx_cache import TxCache
|
2022-01-24 20:23:58 +00:00
|
|
|
from .signtx import (
|
|
|
|
assert_tx_matches,
|
|
|
|
request_finished,
|
|
|
|
request_input,
|
|
|
|
request_meta,
|
|
|
|
request_output,
|
|
|
|
)
|
2018-08-13 16:21:24 +00:00
|
|
|
|
2021-11-10 21:28:11 +00:00
|
|
|
B = messages.ButtonRequestType
|
2020-03-03 16:29:02 +00:00
|
|
|
TX_API = TxCache("Bitcoin")
|
2022-01-24 20:23:58 +00:00
|
|
|
TX_API_TESTNET = TxCache("Testnet")
|
2018-11-02 15:25:51 +00:00
|
|
|
|
2018-09-12 18:34:26 +00:00
|
|
|
TXHASH_c6091a = bytes.fromhex(
|
2018-08-13 16:21:24 +00:00
|
|
|
"c6091adf4c0c23982a35899a6e58ae11e703eacd7954f588ed4b9cdefc4dba52"
|
|
|
|
)
|
2022-01-24 20:23:58 +00:00
|
|
|
TXHASH_509e08 = bytes.fromhex(
|
|
|
|
"509e08424b047403b34dc83e9899e09185ea36791716e42c00a74e1f12bcb6ef"
|
|
|
|
)
|
|
|
|
TXHASH_6b07c1 = bytes.fromhex(
|
|
|
|
"6b07c1321b52d9c85743f9695e13eb431b41708cdf4e1585258d51208e5b93fc"
|
2020-03-26 14:58:44 +00:00
|
|
|
)
|
2022-01-24 20:23:58 +00:00
|
|
|
TXHASH_0d5b56 = bytes.fromhex(
|
|
|
|
"0d5b5648d47b5650edea1af3d47bbe5624213abb577cf1b1c96f98321f75cdbc"
|
2020-03-26 14:58:44 +00:00
|
|
|
)
|
2017-07-28 13:24:18 +00:00
|
|
|
|
2021-11-10 21:19:53 +00:00
|
|
|
pytestmark = pytest.mark.multisig
|
|
|
|
|
|
|
|
|
2022-01-24 20:23:58 +00:00
|
|
|
@pytest.mark.multisig
|
2023-09-14 10:22:18 +00:00
|
|
|
@pytest.mark.parametrize("chunkify", (True, False))
|
|
|
|
def test_2_of_3(client: Client, chunkify: bool):
|
2022-01-24 20:23:58 +00:00
|
|
|
# input tx: 6b07c1321b52d9c85743f9695e13eb431b41708cdf4e1585258d51208e5b93fc
|
|
|
|
|
2021-11-10 21:19:53 +00:00
|
|
|
nodes = [
|
2022-01-24 20:23:58 +00:00
|
|
|
btc.get_public_node(
|
|
|
|
client, parse_path(f"m/48h/1h/{index}h/0h"), coin_name="Testnet"
|
|
|
|
).node
|
2021-11-10 21:19:53 +00:00
|
|
|
for index in range(1, 4)
|
|
|
|
]
|
|
|
|
|
2021-11-10 21:28:11 +00:00
|
|
|
multisig = messages.MultisigRedeemScriptType(
|
2021-11-10 21:19:53 +00:00
|
|
|
nodes=nodes, address_n=[0, 0], signatures=[b"", b"", b""], m=2
|
|
|
|
)
|
|
|
|
# Let's go to sign with key 1
|
2021-11-10 21:28:11 +00:00
|
|
|
inp1 = messages.TxInputType(
|
2022-01-24 20:23:58 +00:00
|
|
|
address_n=parse_path("m/48h/1h/1h/0h/0/0"),
|
|
|
|
amount=1_496_278,
|
|
|
|
prev_hash=TXHASH_6b07c1,
|
|
|
|
prev_index=0,
|
2021-11-10 21:28:11 +00:00
|
|
|
script_type=messages.InputScriptType.SPENDMULTISIG,
|
2021-11-10 21:19:53 +00:00
|
|
|
multisig=multisig,
|
|
|
|
)
|
|
|
|
|
2021-11-10 21:28:11 +00:00
|
|
|
out1 = messages.TxOutputType(
|
2022-01-24 20:23:58 +00:00
|
|
|
address="mnY26FLTzfC94mDoUcyDJh1GVE3LuAUMbs", # "44h/1h/0h/0/6"
|
|
|
|
amount=1_496_278 - 10_000,
|
2021-11-10 21:28:11 +00:00
|
|
|
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
2021-11-10 21:19:53 +00:00
|
|
|
)
|
|
|
|
|
2022-01-24 20:23:58 +00:00
|
|
|
# Expected responses are the same for both two signings
|
|
|
|
expected_responses = [
|
|
|
|
request_input(0),
|
|
|
|
request_output(0),
|
|
|
|
messages.ButtonRequest(code=B.ConfirmOutput),
|
2024-03-09 21:05:05 +00:00
|
|
|
(is_core(client), messages.ButtonRequest(code=B.ConfirmOutput)),
|
2022-01-24 20:23:58 +00:00
|
|
|
messages.ButtonRequest(code=B.SignTx),
|
|
|
|
request_input(0),
|
|
|
|
request_meta(TXHASH_6b07c1),
|
|
|
|
request_input(0, TXHASH_6b07c1),
|
|
|
|
request_output(0, TXHASH_6b07c1),
|
|
|
|
request_input(0),
|
|
|
|
request_output(0),
|
|
|
|
request_output(0),
|
|
|
|
request_finished(),
|
|
|
|
]
|
|
|
|
|
2021-11-10 21:19:53 +00:00
|
|
|
with client:
|
2022-01-24 20:23:58 +00:00
|
|
|
client.set_expected_responses(expected_responses)
|
2014-12-04 00:30:41 +00:00
|
|
|
|
2021-11-10 21:19:53 +00:00
|
|
|
# Now we have first signature
|
|
|
|
signatures1, _ = btc.sign_tx(
|
2023-09-14 10:22:18 +00:00
|
|
|
client,
|
|
|
|
"Testnet",
|
|
|
|
[inp1],
|
|
|
|
[out1],
|
|
|
|
prev_txes=TX_API_TESTNET,
|
|
|
|
chunkify=chunkify,
|
2018-08-13 16:21:24 +00:00
|
|
|
)
|
2014-12-07 14:10:16 +00:00
|
|
|
|
2021-11-10 21:19:53 +00:00
|
|
|
assert (
|
|
|
|
signatures1[0].hex()
|
2022-01-24 20:23:58 +00:00
|
|
|
== "304402206c99b48a12f340599076b93efdc2578b0cdeaedf9092aed628788f4ffc579a50022031b16212dd1f0f62f01bb5862b6d128276c7a5430746aa27a04ae0c8acbcb3b1"
|
2021-11-10 21:19:53 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# ---------------------------------------
|
|
|
|
# Let's do second signature using 3rd key
|
|
|
|
|
2021-11-10 21:28:11 +00:00
|
|
|
multisig = messages.MultisigRedeemScriptType(
|
2021-11-10 21:19:53 +00:00
|
|
|
nodes=nodes,
|
|
|
|
address_n=[0, 0],
|
|
|
|
signatures=[
|
|
|
|
signatures1[0],
|
|
|
|
b"",
|
|
|
|
b"",
|
|
|
|
], # Fill signature from previous signing process
|
|
|
|
m=2,
|
|
|
|
)
|
|
|
|
|
|
|
|
# Let's do a second signature with key 3
|
2021-11-10 21:28:11 +00:00
|
|
|
inp3 = messages.TxInputType(
|
2022-01-24 20:23:58 +00:00
|
|
|
address_n=parse_path("m/48h/1h/3h/0h/0/0"),
|
|
|
|
amount=1_496_278,
|
|
|
|
prev_hash=TXHASH_6b07c1,
|
|
|
|
prev_index=0,
|
2021-11-10 21:28:11 +00:00
|
|
|
script_type=messages.InputScriptType.SPENDMULTISIG,
|
2021-11-10 21:19:53 +00:00
|
|
|
multisig=multisig,
|
|
|
|
)
|
|
|
|
|
|
|
|
with client:
|
2022-01-24 20:23:58 +00:00
|
|
|
client.set_expected_responses(expected_responses)
|
2021-11-10 21:19:53 +00:00
|
|
|
signatures2, serialized_tx = btc.sign_tx(
|
2022-01-24 20:23:58 +00:00
|
|
|
client, "Testnet", [inp3], [out1], prev_txes=TX_API_TESTNET
|
2017-06-23 19:31:42 +00:00
|
|
|
)
|
2014-12-04 00:30:41 +00:00
|
|
|
|
2021-11-10 21:19:53 +00:00
|
|
|
assert (
|
|
|
|
signatures2[0].hex()
|
2022-01-24 20:23:58 +00:00
|
|
|
== "304502210089153ad97c0d69656cd9bd9eb2056552acaec91365dd7ab31250f3f707123baa02200f884de63041d73bd20fbe8804c6036968d8149b7f46963a82b561cd8211ab08"
|
2021-11-10 21:19:53 +00:00
|
|
|
)
|
2018-08-13 16:21:24 +00:00
|
|
|
|
2022-01-24 20:23:58 +00:00
|
|
|
assert_tx_matches(
|
|
|
|
serialized_tx,
|
|
|
|
hash_link="https://tbtc1.trezor.io/api/tx/4123415574c16899b4bb5b691f9b65643dbe566a9b68e4e2e7a8b29c79c83f2b",
|
|
|
|
tx_hex="0100000001fc935b8e20518d2585154edf8c70411b43eb135e69f94357c8d9521b32c1076b00000000fdfd000047304402206c99b48a12f340599076b93efdc2578b0cdeaedf9092aed628788f4ffc579a50022031b16212dd1f0f62f01bb5862b6d128276c7a5430746aa27a04ae0c8acbcb3b10148304502210089153ad97c0d69656cd9bd9eb2056552acaec91365dd7ab31250f3f707123baa02200f884de63041d73bd20fbe8804c6036968d8149b7f46963a82b561cd8211ab08014c69522103725d6c5253f2040a9a73af24bcc196bf302d6cc94374dd7197b138e10912670121038924e94fff15302a3fb45ad4fc0ed17178800f0f1c2bdacb1017f4db951aa9f12102aae8affd0eb8e1181d665daef4de1828f23053c548ec9bafc3a787f558aa014153aeffffffff01c6ad1600000000001976a9144cfc772f24b600762f905a1ee799ce0e9c26831f88ac00000000",
|
2021-11-10 21:19:53 +00:00
|
|
|
)
|
2014-12-07 14:10:16 +00:00
|
|
|
|
2014-12-04 00:30:41 +00:00
|
|
|
|
2022-01-24 20:23:58 +00:00
|
|
|
@pytest.mark.multisig
|
2022-01-31 12:25:30 +00:00
|
|
|
def test_15_of_15(client: Client):
|
2022-01-24 20:23:58 +00:00
|
|
|
# input tx: 0d5b5648d47b5650edea1af3d47bbe5624213abb577cf1b1c96f98321f75cdbc
|
|
|
|
|
2021-11-10 21:19:53 +00:00
|
|
|
node = btc.get_public_node(
|
2022-01-24 20:23:58 +00:00
|
|
|
client, parse_path("m/48h/1h/1h/0h"), coin_name="Testnet"
|
2021-11-10 21:19:53 +00:00
|
|
|
).node
|
2021-11-10 21:28:11 +00:00
|
|
|
pubs = [messages.HDNodePathType(node=node, address_n=[0, x]) for x in range(15)]
|
2014-12-10 16:51:55 +00:00
|
|
|
|
2021-11-10 21:19:53 +00:00
|
|
|
signatures = [b""] * 15
|
2014-12-10 16:51:55 +00:00
|
|
|
|
2021-11-10 21:28:11 +00:00
|
|
|
out1 = messages.TxOutputType(
|
2022-01-24 20:23:58 +00:00
|
|
|
address="mnY26FLTzfC94mDoUcyDJh1GVE3LuAUMbs", # "44h/1h/0h/0/6"
|
|
|
|
amount=1_476_278 - 10_000,
|
2021-11-10 21:28:11 +00:00
|
|
|
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
2021-11-10 21:19:53 +00:00
|
|
|
)
|
2014-12-12 21:19:30 +00:00
|
|
|
|
2021-11-10 21:19:53 +00:00
|
|
|
for x in range(15):
|
2021-11-10 21:28:11 +00:00
|
|
|
multisig = messages.MultisigRedeemScriptType(
|
2021-11-10 21:19:53 +00:00
|
|
|
pubkeys=pubs, signatures=signatures, m=15
|
2017-06-23 19:31:42 +00:00
|
|
|
)
|
2014-12-10 16:51:55 +00:00
|
|
|
|
2021-11-10 21:28:11 +00:00
|
|
|
inp1 = messages.TxInputType(
|
2022-01-24 20:23:58 +00:00
|
|
|
address_n=parse_path(f"m/48h/1h/1h/0h/0/{x}"),
|
|
|
|
amount=1_476_278,
|
|
|
|
prev_hash=TXHASH_0d5b56,
|
|
|
|
prev_index=0,
|
2021-11-10 21:28:11 +00:00
|
|
|
script_type=messages.InputScriptType.SPENDMULTISIG,
|
2017-06-23 19:31:42 +00:00
|
|
|
multisig=multisig,
|
|
|
|
)
|
|
|
|
|
2021-11-10 21:19:53 +00:00
|
|
|
with client:
|
|
|
|
sig, serialized_tx = btc.sign_tx(
|
2022-01-24 20:23:58 +00:00
|
|
|
client, "Testnet", [inp1], [out1], prev_txes=TX_API_TESTNET
|
2021-11-10 21:19:53 +00:00
|
|
|
)
|
|
|
|
signatures[x] = sig[0]
|
|
|
|
|
2022-01-24 20:23:58 +00:00
|
|
|
assert_tx_matches(
|
|
|
|
serialized_tx,
|
|
|
|
hash_link="https://tbtc1.trezor.io/api/tx/b41284067577e1266ad3632f7caffead5d58277cc35f42642455bfd2a3fa0325",
|
2021-11-10 21:19:53 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-01-24 20:23:58 +00:00
|
|
|
@pytest.mark.multisig
|
2021-11-10 21:19:53 +00:00
|
|
|
@pytest.mark.setup_client(mnemonic=MNEMONIC12)
|
2022-01-31 12:25:30 +00:00
|
|
|
def test_missing_pubkey(client: Client):
|
2021-11-10 21:19:53 +00:00
|
|
|
node = btc.get_public_node(
|
2022-01-31 12:25:30 +00:00
|
|
|
client, parse_path("m/48h/0h/1h/0h/0"), coin_name="Bitcoin"
|
2021-11-10 21:19:53 +00:00
|
|
|
).node
|
|
|
|
|
2021-11-10 21:28:11 +00:00
|
|
|
multisig = messages.MultisigRedeemScriptType(
|
2021-11-10 21:19:53 +00:00
|
|
|
pubkeys=[
|
2021-11-10 21:28:11 +00:00
|
|
|
messages.HDNodePathType(node=node, address_n=[1]),
|
|
|
|
messages.HDNodePathType(node=node, address_n=[2]),
|
|
|
|
messages.HDNodePathType(node=node, address_n=[3]),
|
2021-11-10 21:19:53 +00:00
|
|
|
],
|
|
|
|
signatures=[b"", b"", b""],
|
|
|
|
m=2,
|
|
|
|
)
|
|
|
|
|
|
|
|
# Let's go to sign with key 10, which is NOT in pubkeys
|
2021-11-10 21:28:11 +00:00
|
|
|
inp1 = messages.TxInputType(
|
2022-01-31 12:25:30 +00:00
|
|
|
address_n=parse_path("m/48h/0h/1h/0h/0/10"),
|
|
|
|
amount=100_000,
|
2021-11-10 21:19:53 +00:00
|
|
|
prev_hash=TXHASH_c6091a,
|
|
|
|
prev_index=1,
|
2021-11-10 21:28:11 +00:00
|
|
|
script_type=messages.InputScriptType.SPENDMULTISIG,
|
2021-11-10 21:19:53 +00:00
|
|
|
multisig=multisig,
|
|
|
|
)
|
|
|
|
|
2021-11-10 21:28:11 +00:00
|
|
|
out1 = messages.TxOutputType(
|
2021-11-10 21:19:53 +00:00
|
|
|
address="12iyMbUb4R2K3gre4dHSrbu5azG5KaqVss",
|
2022-01-31 12:25:30 +00:00
|
|
|
amount=100_000,
|
2021-11-10 21:28:11 +00:00
|
|
|
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
2021-11-10 21:19:53 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
with pytest.raises(TrezorFailure) as exc:
|
|
|
|
btc.sign_tx(client, "Bitcoin", [inp1], [out1], prev_txes=TX_API)
|
|
|
|
|
2024-03-11 15:20:08 +00:00
|
|
|
if client.model is models.T1B1:
|
2021-11-10 21:19:53 +00:00
|
|
|
assert exc.value.message.endswith("Failed to derive scriptPubKey")
|
|
|
|
else:
|
|
|
|
assert exc.value.message.endswith("Pubkey not found in multisig script")
|
|
|
|
|
|
|
|
|
2022-01-24 20:23:58 +00:00
|
|
|
@pytest.mark.multisig
|
2022-01-31 12:25:30 +00:00
|
|
|
def test_attack_change_input(client: Client):
|
2021-11-10 21:19:53 +00:00
|
|
|
"""
|
|
|
|
In Phases 1 and 2 the attacker replaces a non-multisig input
|
|
|
|
`input_real` with a multisig input `input_fake`, which allows the
|
|
|
|
attacker to provide a 1-of-2 multisig change address. When `input_real`
|
|
|
|
is provided in the signing phase, an error must occur.
|
|
|
|
"""
|
2022-01-24 20:23:58 +00:00
|
|
|
address_n = parse_path("m/48h/1h/0h/1h/0/0") # 2NErUdruXmM8o8bQySrzB3WdBRcmc5br4E8
|
2021-11-10 21:19:53 +00:00
|
|
|
attacker_multisig_public_key = bytes.fromhex(
|
|
|
|
"03653a148b68584acb97947344a7d4fd6a6f8b8485cad12987ff8edac874268088"
|
|
|
|
)
|
|
|
|
|
2021-11-10 21:28:11 +00:00
|
|
|
input_real = messages.TxInputType(
|
2021-11-10 21:19:53 +00:00
|
|
|
address_n=address_n,
|
2022-01-24 20:23:58 +00:00
|
|
|
prev_hash=TXHASH_509e08,
|
|
|
|
prev_index=0,
|
2021-11-10 21:28:11 +00:00
|
|
|
script_type=messages.InputScriptType.SPENDP2SHWITNESS,
|
2022-01-24 20:23:58 +00:00
|
|
|
amount=61_093,
|
2021-11-10 21:19:53 +00:00
|
|
|
)
|
|
|
|
|
2021-11-10 21:28:11 +00:00
|
|
|
multisig_fake = messages.MultisigRedeemScriptType(
|
2021-11-10 21:19:53 +00:00
|
|
|
m=1,
|
|
|
|
nodes=[
|
|
|
|
btc.get_public_node(client, address_n, coin_name="Testnet").node,
|
2021-11-10 21:28:11 +00:00
|
|
|
messages.HDNodeType(
|
2021-11-10 21:19:53 +00:00
|
|
|
depth=0,
|
|
|
|
fingerprint=0,
|
|
|
|
child_num=0,
|
|
|
|
chain_code=bytes(32),
|
|
|
|
public_key=attacker_multisig_public_key,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
address_n=[],
|
|
|
|
)
|
|
|
|
|
2021-11-10 21:28:11 +00:00
|
|
|
input_fake = messages.TxInputType(
|
2021-11-10 21:19:53 +00:00
|
|
|
address_n=address_n,
|
|
|
|
prev_hash=input_real.prev_hash,
|
|
|
|
prev_index=input_real.prev_index,
|
|
|
|
script_type=input_real.script_type,
|
|
|
|
multisig=multisig_fake,
|
|
|
|
amount=input_real.amount,
|
|
|
|
)
|
|
|
|
|
2021-11-10 21:28:11 +00:00
|
|
|
output_payee = messages.TxOutputType(
|
2021-11-10 21:19:53 +00:00
|
|
|
address="n2eMqTT929pb1RDNuqEnxdaLau1rxy3efi",
|
2022-01-24 20:23:58 +00:00
|
|
|
amount=10_000,
|
2021-11-10 21:28:11 +00:00
|
|
|
script_type=messages.OutputScriptType.PAYTOADDRESS,
|
2021-11-10 21:19:53 +00:00
|
|
|
)
|
|
|
|
|
2021-11-10 21:28:11 +00:00
|
|
|
output_change = messages.TxOutputType(
|
2021-11-10 21:19:53 +00:00
|
|
|
address_n=address_n,
|
2022-01-31 12:25:30 +00:00
|
|
|
amount=input_real.amount - output_payee.amount - 1_000,
|
2021-11-10 21:28:11 +00:00
|
|
|
script_type=messages.OutputScriptType.PAYTOP2SHWITNESS,
|
2021-11-10 21:19:53 +00:00
|
|
|
multisig=multisig_fake,
|
|
|
|
)
|
|
|
|
|
2022-01-24 20:23:58 +00:00
|
|
|
# Transaction can be signed without the attack processor
|
|
|
|
with client:
|
2024-05-21 21:49:08 +00:00
|
|
|
if is_core(client):
|
|
|
|
IF = InputFlowConfirmAllWarnings(client)
|
|
|
|
client.set_input_flow(IF.get())
|
2022-01-24 20:23:58 +00:00
|
|
|
btc.sign_tx(
|
|
|
|
client,
|
|
|
|
"Testnet",
|
|
|
|
[input_real],
|
|
|
|
[output_payee, output_change],
|
|
|
|
prev_txes=TX_API_TESTNET,
|
|
|
|
)
|
|
|
|
|
2021-11-10 21:19:53 +00:00
|
|
|
attack_count = 3
|
|
|
|
|
|
|
|
def attack_processor(msg):
|
|
|
|
nonlocal attack_count
|
|
|
|
# replace the first input_real with input_fake
|
|
|
|
if attack_count > 0 and msg.tx.inputs and msg.tx.inputs[0] == input_real:
|
|
|
|
msg.tx.inputs[0] = input_fake
|
|
|
|
attack_count -= 1
|
|
|
|
return msg
|
|
|
|
|
|
|
|
with client:
|
2021-11-10 21:28:11 +00:00
|
|
|
client.set_filter(messages.TxAck, attack_processor)
|
2022-03-07 19:19:03 +00:00
|
|
|
with pytest.raises(TrezorFailure):
|
2021-11-10 21:19:53 +00:00
|
|
|
btc.sign_tx(
|
|
|
|
client,
|
|
|
|
"Testnet",
|
|
|
|
[input_real],
|
|
|
|
[output_payee, output_change],
|
2022-01-24 20:23:58 +00:00
|
|
|
prev_txes=TX_API_TESTNET,
|
2020-03-06 15:31:22 +00:00
|
|
|
)
|