1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 04:18:10 +00:00

feat(python/trezorctl): notify user about PIN/passphrase entry in terminal (fixes #3203)

This commit is contained in:
matejcik 2023-10-19 13:27:50 +02:00
parent c9e9c34e06
commit 3c0344304f
2 changed files with 15 additions and 5 deletions

View File

@ -0,0 +1 @@
ClickUI: notify user in terminal that they should enter PIN or passphrase on Trezor.

View File

@ -90,15 +90,24 @@ class ClickUI:
self, always_prompt: bool = False, passphrase_on_host: bool = False self, always_prompt: bool = False, passphrase_on_host: bool = False
) -> None: ) -> None:
self.pinmatrix_shown = False self.pinmatrix_shown = False
self.prompt_shown = False self.last_prompt_shown = ""
self.always_prompt = always_prompt self.always_prompt = always_prompt
self.passphrase_on_host = passphrase_on_host self.passphrase_on_host = passphrase_on_host
def button_request(self, _br: messages.ButtonRequest) -> None: def _prompt_for_button(self, br: messages.ButtonRequest) -> str:
if not self.prompt_shown: if br.code == messages.ButtonRequestType.PassphraseEntry:
echo("Please confirm action on your Trezor device.") return "Please enter passphrase on your Trezor device."
if br.code == messages.ButtonRequestType.PinEntry:
return "Please enter PIN on your Trezor device."
return "Please confirm action on your Trezor device."
def button_request(self, br: messages.ButtonRequest) -> None:
prompt = self._prompt_for_button(br)
if prompt != self.last_prompt_shown:
echo(prompt)
if not self.always_prompt: if not self.always_prompt:
self.prompt_shown = True self.last_prompt_shown = prompt
def get_pin(self, code: Optional[PinMatrixRequestType] = None) -> str: def get_pin(self, code: Optional[PinMatrixRequestType] = None) -> str:
if code == PIN_CURRENT: if code == PIN_CURRENT: