diff --git a/python/CHANGELOG.md b/python/CHANGELOG.md index 09507b3e0e..486576a119 100644 --- a/python/CHANGELOG.md +++ b/python/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - protobuf is aware of `required` fields and default values - `btc.sign_tx()` accepts keyword arguments for transaction metadata [#1266] +- Support long PIN of up to 50 digits. [#1167] ### Deprecated @@ -509,6 +510,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#948]: https://github.com/trezor/trezor-firmware/issues/948 [#1052]: https://github.com/trezor/trezor-firmware/issues/1052 [#1126]: https://github.com/trezor/trezor-firmware/issues/1126 +[#1167]: https://github.com/trezor/trezor-firmware/issues/1167 [#1179]: https://github.com/trezor/trezor-firmware/issues/1179 [#1196]: https://github.com/trezor/trezor-firmware/issues/1196 [#1210]: https://github.com/trezor/trezor-firmware/issues/1210 diff --git a/python/src/trezorlib/client.py b/python/src/trezorlib/client.py index a75be139a2..cd10380e01 100644 --- a/python/src/trezorlib/client.py +++ b/python/src/trezorlib/client.py @@ -29,6 +29,7 @@ LOG = logging.getLogger(__name__) VENDORS = ("bitcointrezor.com", "trezor.io") MAX_PASSPHRASE_LENGTH = 50 +MAX_PIN_LENGTH = 50 PASSPHRASE_ON_DEVICE = object() PASSPHRASE_TEST_PATH = tools.parse_path("44h/1h/0h/0/0") @@ -152,7 +153,9 @@ class TrezorClient: self.call_raw(messages.Cancel()) raise - if any(d not in "123456789" for d in pin) or not (1 <= len(pin) <= 9): + if any(d not in "123456789" for d in pin) or not ( + 1 <= len(pin) <= MAX_PIN_LENGTH + ): self.call_raw(messages.Cancel()) raise ValueError("Invalid PIN provided") diff --git a/python/src/trezorlib/ui.py b/python/src/trezorlib/ui.py index 479d76f91b..bbdf09fa59 100644 --- a/python/src/trezorlib/ui.py +++ b/python/src/trezorlib/ui.py @@ -20,7 +20,7 @@ import click from mnemonic import Mnemonic from . import device -from .client import PASSPHRASE_ON_DEVICE +from .client import MAX_PIN_LENGTH, PASSPHRASE_ON_DEVICE from .exceptions import Cancelled from .messages import PinMatrixRequestType, WordRequestType @@ -107,8 +107,12 @@ class ClickUI: echo( "The value may only consist of digits 1 to 9 or letters cvbdfgert." ) - elif len(pin) > 9: - echo("The value must be at most 9 digits in length.") + elif len(pin) > MAX_PIN_LENGTH: + echo( + "The value must be at most {} digits in length.".format( + MAX_PIN_LENGTH + ) + ) else: return pin