halt("debug mode inactive") if __debug__: from trezor import loop from trezor.messages import MessageType from trezor.messages.DebugLinkState import DebugLinkState from trezor.ui import confirm, swipe from trezor.wire import register, protobuf_workflow from apps.common import storage reset_internal_entropy = None reset_current_words = None reset_word_index = None confirm_signal = loop.signal() swipe_signal = loop.signal() input_signal = loop.signal() async def dispatch_DebugLinkDecision(ctx, msg): if msg.yes_no is not None: confirm_signal.send(confirm.CONFIRMED if msg.yes_no else confirm.CANCELLED) if msg.up_down is not None: swipe_signal.send(swipe.SWIPE_DOWN if msg.up_down else swipe.SWIPE_UP) if msg.input is not None: input_signal.send(msg.input) async def dispatch_DebugLinkGetState(ctx, msg): m = DebugLinkState() m.mnemonic = storage.get_mnemonic() m.passphrase_protection = storage.has_passphrase()
from trezor import wire, ui, loop from trezor.utils import unimport # used to confirm/cancel the dialogs from outside of this module (i.e. # through debug link) if __debug__: signal = loop.signal() @ui.layout @unimport async def confirm(ctx, content, code=None, *args, **kwargs): from trezor.ui.confirm import ConfirmDialog, CONFIRMED from trezor.messages.ButtonRequest import ButtonRequest from trezor.messages.ButtonRequestType import Other from trezor.messages.wire_types import ButtonAck ui.display.clear() dialog = ConfirmDialog(content, *args, **kwargs) dialog.render() if code is None: code = Other await ctx.call(ButtonRequest(code=code), ButtonAck) if __debug__: waiter = loop.wait(signal, dialog) else: waiter = dialog return await waiter == CONFIRMED
from trezor import loop workflows = [] layouts = [] default = None default_layout = None # HACK: workaround way to stop the WebAuthn layout from the outside webauthn_stop_signal = loop.signal() def onstart(w): workflows.append(w) def onclose(w): workflows.remove(w) if not layouts and default_layout: startdefault(default_layout) def closedefault(): global default if default: loop.close(default) default = None def startdefault(layout): global default
from trezor import loop workflows = [] layouts = [] layout_signal = loop.signal() default = None default_layout = None def onstart(w): workflows.append(w) def onclose(w): workflows.remove(w) if not layouts and default_layout: startdefault(default_layout) if __debug__: import micropython from trezor import utils if utils.LOG_MEMORY: micropython.mem_info() def closedefault(): global default if default: loop.close(default)
from trezor import loop, ui, wire from trezor.messages import ButtonRequestType, FailureType, wire_types from trezor.messages.ButtonRequest import ButtonRequest from trezor.ui.confirm import CONFIRMED, ConfirmDialog, HoldToConfirmDialog from apps.common import cache # used to confirm/cancel the dialogs from outside of this module (i.e. # through debug link) if __debug__: signal = cache.memory.setdefault('confirm_signal', loop.signal()) @ui.layout async def confirm(ctx, content, code=None, *args, **kwargs): if code is None: code = ButtonRequestType.Other await ctx.call(ButtonRequest(code=code), wire_types.ButtonAck) dialog = ConfirmDialog(content, *args, **kwargs) if __debug__: waiter = ctx.wait(signal, dialog) else: waiter = ctx.wait(dialog) return await waiter == CONFIRMED @ui.layout async def hold_to_confirm(ctx, content, code=None, *args, **kwargs): if code is None: code = ButtonRequestType.Other