From edae40e22cb19a51dc1a02ba6806fc89f6c350fe Mon Sep 17 00:00:00 2001 From: Andrew Kozlik Date: Sat, 23 Feb 2019 12:19:08 +0100 Subject: [PATCH] pin: do not allow the user to enter an empty PIN An empty PIN is used to signify PIN removal and T1 does not allow entering an empty PIN neither via web-wallet nor via trezorctl. --- src/apps/common/request_pin.py | 13 +++++++++++++ src/trezor/ui/button.py | 3 +++ 2 files changed, 16 insertions(+) diff --git a/src/apps/common/request_pin.py b/src/apps/common/request_pin.py index 82eb3eb77b..c0d9f091c2 100644 --- a/src/apps/common/request_pin.py +++ b/src/apps/common/request_pin.py @@ -36,6 +36,17 @@ async def request_pin( c.taint() c.render() + c = dialog.confirm + if matrix.pin: + if not c.is_enabled(): + c.enable() + c.taint() + else: + if c.is_enabled(): + c.disable() + c.taint() + c.render() + if label is None: label = "Enter your PIN" sublabel = None @@ -59,6 +70,8 @@ async def request_pin( else: result = await dialog if result == CONFIRMED: + if not matrix.pin: + continue return matrix.pin elif matrix.pin: # reset matrix.change("") diff --git a/src/trezor/ui/button.py b/src/trezor/ui/button.py index 5d39410a77..75f5e427d2 100644 --- a/src/trezor/ui/button.py +++ b/src/trezor/ui/button.py @@ -36,6 +36,9 @@ class Button(Widget): self.state = BTN_DISABLED self.tainted = True + def is_enabled(self): + return self.state != BTN_DISABLED + def render(self): if not self.tainted: return