diff --git a/src/apps/wallet/sign_message.py b/src/apps/wallet/sign_message.py index 23141ec938..246307476b 100644 --- a/src/apps/wallet/sign_message.py +++ b/src/apps/wallet/sign_message.py @@ -26,6 +26,7 @@ async def sign_message(ctx, msg): path=msg.address_n, coin=coin, script_type=msg.script_type, + validate_script_type=False, ) node = await seed.derive_node(ctx, address_n, curve_name=coin.curve_name) diff --git a/src/apps/wallet/sign_tx/addresses.py b/src/apps/wallet/sign_tx/addresses.py index 3a14090bd2..6a7db4b8e2 100644 --- a/src/apps/wallet/sign_tx/addresses.py +++ b/src/apps/wallet/sign_tx/addresses.py @@ -193,7 +193,7 @@ def address_short(coin: CoinInfo, address: str) -> str: def validate_full_path( - path: list, coin: CoinInfo, script_type: InputScriptType + path: list, coin: CoinInfo, script_type: InputScriptType, validate_script_type=True ) -> bool: """ Validates derivation path to fit Bitcoin-like coins. We mostly use @@ -209,7 +209,9 @@ def validate_full_path( if not validate_purpose(path[0], coin): return False - if not validate_purpose_against_script_type(path[0], script_type): + if validate_script_type and not validate_purpose_against_script_type( + path[0], script_type + ): return False if path[1] != coin.slip44 | HARDENED: diff --git a/tests/test_apps.wallet.address.py b/tests/test_apps.wallet.address.py index 7ffdef6b8b..d39067ddbb 100644 --- a/tests/test_apps.wallet.address.py +++ b/tests/test_apps.wallet.address.py @@ -152,6 +152,10 @@ class TestAddress(unittest.TestCase): for path, input_type in correct_derivation_paths: self.assertTrue(validate_full_path(path, coin, input_type)) + self.assertTrue(validate_full_path([44 | HARDENED, 0 | HARDENED, 0 | HARDENED, 0, 0], coin, InputScriptType.SPENDADDRESS)) + self.assertFalse(validate_full_path([44 | HARDENED, 0 | HARDENED, 0 | HARDENED, 0, 0], coin, InputScriptType.SPENDWITNESS)) + self.assertTrue(validate_full_path([44 | HARDENED, 0 | HARDENED, 0 | HARDENED, 0, 0], coin, InputScriptType.SPENDWITNESS, validate_script_type=False)) + def test_paths_bch(self): incorrect_derivation_paths = [ ([44 | HARDENED], InputScriptType.SPENDADDRESS), # invalid length