mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 07:28:10 +00:00
feat(core/bitcoin): do not show path warning when GetAddress is called silently (fixes #1206)
This commit is contained in:
parent
f3b6de399a
commit
f10084117b
@ -43,12 +43,14 @@ async def show_xpubs(
|
||||
async def get_address(
|
||||
ctx: wire.Context, msg: GetAddress, keychain: Keychain, coin: CoinInfo
|
||||
) -> Address:
|
||||
await validate_path(
|
||||
ctx,
|
||||
keychain,
|
||||
msg.address_n,
|
||||
validate_path_against_script_type(coin, msg),
|
||||
)
|
||||
if msg.show_display:
|
||||
# skip soft-validation for silent calls
|
||||
await validate_path(
|
||||
ctx,
|
||||
keychain,
|
||||
msg.address_n,
|
||||
validate_path_against_script_type(coin, msg),
|
||||
)
|
||||
|
||||
node = keychain.derive(msg.address_n)
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import btc, messages, device
|
||||
from trezorlib import btc, device, messages
|
||||
from trezorlib.exceptions import TrezorFailure
|
||||
from trezorlib.messages import SafetyCheckLevel
|
||||
from trezorlib.tools import parse_path
|
||||
@ -227,10 +227,11 @@ def test_invalid_path(client):
|
||||
|
||||
|
||||
@pytest.mark.skip_t1
|
||||
def test_unknown_path(client):
|
||||
def test_unknown_path_tt(client):
|
||||
UNKNOWN_PATH = parse_path("m/44'/9'/0'/0/0")
|
||||
with pytest.raises(TrezorFailure, match="Forbidden key path"):
|
||||
# account number is too high
|
||||
btc.get_address(client, "Bitcoin", parse_path("m/44'/0'/101'/0/0"))
|
||||
btc.get_address(client, "Bitcoin", UNKNOWN_PATH)
|
||||
|
||||
# disable safety checks
|
||||
device.apply_settings(client, safety_checks=SafetyCheckLevel.PromptTemporarily)
|
||||
@ -241,11 +242,37 @@ def test_unknown_path(client):
|
||||
messages.ButtonRequest(
|
||||
code=messages.ButtonRequestType.UnknownDerivationPath
|
||||
),
|
||||
messages.ButtonRequest(code=messages.ButtonRequestType.Address),
|
||||
messages.Address,
|
||||
]
|
||||
)
|
||||
# try again with a warning
|
||||
btc.get_address(client, "Bitcoin", parse_path("m/44'/0'/101'/0/0"))
|
||||
btc.get_address(client, "Bitcoin", UNKNOWN_PATH, show_display=True)
|
||||
|
||||
with client:
|
||||
# no warning is displayed when the call is silent
|
||||
client.set_expected_responses([messages.Address])
|
||||
btc.get_address(client, "Bitcoin", UNKNOWN_PATH, show_display=False)
|
||||
|
||||
|
||||
@pytest.mark.skip_t2
|
||||
def test_unknown_path_t1(client):
|
||||
UNKNOWN_PATH = parse_path("m/44'/9'/0'/0/0")
|
||||
with client:
|
||||
client.set_expected_responses(
|
||||
[
|
||||
messages.ButtonRequest(code=messages.ButtonRequestType.Other),
|
||||
messages.ButtonRequest(code=messages.ButtonRequestType.Address),
|
||||
messages.Address,
|
||||
]
|
||||
)
|
||||
# warning is shown when showing address
|
||||
btc.get_address(client, "Bitcoin", UNKNOWN_PATH, show_display=True)
|
||||
|
||||
with client:
|
||||
# no warning is displayed when the call is silent
|
||||
client.set_expected_responses([messages.Address])
|
||||
btc.get_address(client, "Bitcoin", UNKNOWN_PATH, show_display=False)
|
||||
|
||||
|
||||
@pytest.mark.altcoin
|
||||
|
Loading…
Reference in New Issue
Block a user