diff --git a/src/apps/debug/__init__.py b/src/apps/debug/__init__.py index efa585411..a880a7984 100644 --- a/src/apps/debug/__init__.py +++ b/src/apps/debug/__init__.py @@ -1,42 +1,41 @@ -from trezor import loop, utils -from trezor.messages import wire_types -from trezor.messages.DebugLinkState import DebugLinkState -from trezor.ui import confirm, swipe -from trezor.wire import register, protobuf_workflow -from apps.common import storage - if not __debug__: - utils.halt("debug mode inactive") + from trezor.utils import halt + halt("debug mode inactive") -reset_internal_entropy = None -reset_current_words = None -reset_word_index = None +if __debug__: + from trezor import loop + from trezor.messages import wire_types + from trezor.messages.DebugLinkState import DebugLinkState + from trezor.ui import confirm, swipe + from trezor.wire import register, protobuf_workflow + from apps.common import storage -confirm_signal = loop.signal() -swipe_signal = loop.signal() -input_signal = loop.signal() + 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_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() + m.reset_word_pos = reset_word_index + m.reset_entropy = reset_internal_entropy + if reset_current_words: + m.reset_word = ' '.join(reset_current_words) + return m -async def dispatch_DebugLinkGetState(ctx, msg): - m = DebugLinkState() - m.mnemonic = storage.get_mnemonic() - m.passphrase_protection = storage.has_passphrase() - m.reset_word_pos = reset_word_index - m.reset_entropy = reset_internal_entropy - if reset_current_words: - m.reset_word = ' '.join(reset_current_words) - return m - - -def boot(): - register(wire_types.DebugLinkDecision, protobuf_workflow, dispatch_DebugLinkDecision) - register(wire_types.DebugLinkGetState, protobuf_workflow, dispatch_DebugLinkGetState) + def boot(): + register(wire_types.DebugLinkDecision, protobuf_workflow, dispatch_DebugLinkDecision) + register(wire_types.DebugLinkGetState, protobuf_workflow, dispatch_DebugLinkGetState)