|
|
|
@ -23,36 +23,12 @@ async def get_passphrase(msg: ThpCreateNewSession) -> str:
|
|
|
|
|
passphrase = await _get_on_device()
|
|
|
|
|
else:
|
|
|
|
|
passphrase = msg.passphrase or ""
|
|
|
|
|
if passphrase:
|
|
|
|
|
await _handle_displaying_passphrase_from_host(passphrase)
|
|
|
|
|
|
|
|
|
|
if len(passphrase.encode()) > _MAX_PASSPHRASE_LEN:
|
|
|
|
|
raise DataError(f"Maximum passphrase length is {_MAX_PASSPHRASE_LEN} bytes")
|
|
|
|
|
|
|
|
|
|
# non-empty passphrase
|
|
|
|
|
if passphrase:
|
|
|
|
|
from trezor import TR
|
|
|
|
|
from trezor.ui.layouts import confirm_action, confirm_blob
|
|
|
|
|
|
|
|
|
|
# We want to hide the passphrase, or show it, according to settings.
|
|
|
|
|
if storage_device.get_hide_passphrase_from_host():
|
|
|
|
|
await confirm_action(
|
|
|
|
|
"passphrase_host1_hidden",
|
|
|
|
|
TR.passphrase__hidden_wallet,
|
|
|
|
|
description=f"{TR.passphrase__access_hidden_wallet}\n{TR.passphrase__from_host_not_shown}",
|
|
|
|
|
)
|
|
|
|
|
else:
|
|
|
|
|
await confirm_action(
|
|
|
|
|
"passphrase_host1",
|
|
|
|
|
TR.passphrase__hidden_wallet,
|
|
|
|
|
description=TR.passphrase__next_screen_will_show_passphrase,
|
|
|
|
|
verb=TR.buttons__continue,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
await confirm_blob(
|
|
|
|
|
"passphrase_host2",
|
|
|
|
|
TR.passphrase__title_confirm,
|
|
|
|
|
passphrase,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
return passphrase
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -88,7 +64,6 @@ async def get() -> str:
|
|
|
|
|
|
|
|
|
|
@check_thp_is_not_used
|
|
|
|
|
async def _request_on_host() -> str:
|
|
|
|
|
from trezor import TR
|
|
|
|
|
from trezor.messages import PassphraseAck, PassphraseRequest
|
|
|
|
|
from trezor.ui.layouts import request_passphrase_on_host
|
|
|
|
|
from trezor.wire.context import call
|
|
|
|
@ -113,27 +88,32 @@ async def _request_on_host() -> str:
|
|
|
|
|
|
|
|
|
|
# non-empty passphrase
|
|
|
|
|
if passphrase:
|
|
|
|
|
from trezor.ui.layouts import confirm_action, confirm_blob
|
|
|
|
|
|
|
|
|
|
# We want to hide the passphrase, or show it, according to settings.
|
|
|
|
|
if storage_device.get_hide_passphrase_from_host():
|
|
|
|
|
await confirm_action(
|
|
|
|
|
"passphrase_host1_hidden",
|
|
|
|
|
TR.passphrase__hidden_wallet,
|
|
|
|
|
description=f"{TR.passphrase__access_hidden_wallet}\n{TR.passphrase__from_host_not_shown}",
|
|
|
|
|
)
|
|
|
|
|
else:
|
|
|
|
|
await confirm_action(
|
|
|
|
|
"passphrase_host1",
|
|
|
|
|
TR.passphrase__hidden_wallet,
|
|
|
|
|
description=TR.passphrase__next_screen_will_show_passphrase,
|
|
|
|
|
verb=TR.buttons__continue,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
await confirm_blob(
|
|
|
|
|
"passphrase_host2",
|
|
|
|
|
TR.passphrase__title_confirm,
|
|
|
|
|
passphrase,
|
|
|
|
|
)
|
|
|
|
|
await _handle_displaying_passphrase_from_host(passphrase)
|
|
|
|
|
|
|
|
|
|
return passphrase
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def _handle_displaying_passphrase_from_host(passphrase: str) -> None:
|
|
|
|
|
from trezor import TR
|
|
|
|
|
from trezor.ui.layouts import confirm_action, confirm_blob
|
|
|
|
|
|
|
|
|
|
# We want to hide the passphrase, or show it, according to settings.
|
|
|
|
|
if storage_device.get_hide_passphrase_from_host():
|
|
|
|
|
await confirm_action(
|
|
|
|
|
"passphrase_host1_hidden",
|
|
|
|
|
TR.passphrase__hidden_wallet,
|
|
|
|
|
description=f"{TR.passphrase__access_hidden_wallet}\n{TR.passphrase__from_host_not_shown}",
|
|
|
|
|
)
|
|
|
|
|
else:
|
|
|
|
|
await confirm_action(
|
|
|
|
|
"passphrase_host1",
|
|
|
|
|
TR.passphrase__hidden_wallet,
|
|
|
|
|
description=TR.passphrase__next_screen_will_show_passphrase,
|
|
|
|
|
verb=TR.buttons__continue,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
await confirm_blob(
|
|
|
|
|
"passphrase_host2",
|
|
|
|
|
TR.passphrase__title_confirm,
|
|
|
|
|
passphrase,
|
|
|
|
|
)
|
|
|
|
|