def _start_progress() -> None: from trezor.ui.layouts import draw_simple_text # Because we are drawing to the screen manually, without a layout, we # should make sure that no other layout is running. workflow.close_others() draw_simple_text("Please wait")
async def get_firmware(ctx: Context, _msg: GetFirmware) -> Success: await confirm_action( ctx, "dump_firmware", title="Extract firmware", action="Do you want to extract device firmware?", description="Your seed will not be revealed.", ) sector_buffer = bytearray(CHUNK_SIZE) packet = FirmwareChunk(chunk=sector_buffer) workflow.close_others() draw_simple_text("Please wait") progress = 0 _render_progress(progress, PROGRESS_TOTAL) for i in range(utils.FIRMWARE_SECTORS_COUNT): size = utils.firmware_sector_size(i) try: for ofs in range(0, size, CHUNK_SIZE): utils.get_firmware_chunk(i, ofs, sector_buffer) await ctx.call(packet, FirmwareChunkAck) progress += CHUNK_SIZE _render_progress(progress, PROGRESS_TOTAL) # reset progress to known point, in case some sectors are not 128 kB progress = (i + 1) * 128 * 1024 _render_progress(progress, PROGRESS_TOTAL) except ValueError: raise wire.DataError("Failed to dump firmware.") return Success(message="Firmware dumped.")
async def button_request( ctx: wire.GenericContext, br_type: str, code: ButtonRequestType = ButtonRequestType.Other, ) -> None: if __debug__: log.debug(__name__, "ButtonRequest.type=%s", br_type) workflow.close_others() await ctx.call(ButtonRequest(code=code), ButtonAck)
async def interact( ctx: wire.GenericContext, layout: LayoutType, brtype: str, brcode: EnumTypeButtonRequestType = ButtonRequestType.Other, ) -> Any: log.debug(__name__, "ButtonRequest.type={}".format(brtype)) workflow.close_others() await ctx.call(ButtonRequest(code=brcode), ButtonAck) return await ctx.wait(layout)
async def get_firmware_hash(ctx: Context, msg: GetFirmwareHash) -> FirmwareHash: workflow.close_others() draw_simple_text("Please wait") try: hash = firmware_hash(msg.challenge, _render_progress) except ValueError as e: raise wire.DataError(str(e)) return FirmwareHash(hash=hash)
async def _request_from_user(ctx: wire.Context) -> str: workflow.close_others() # request exclusive UI access if storage.device.get_passphrase_always_on_device(): passphrase = await _request_on_device(ctx) else: passphrase = await _request_on_host(ctx) if len(passphrase.encode()) > _MAX_PASSPHRASE_LEN: raise wire.DataError("Maximum passphrase length is %d bytes" % _MAX_PASSPHRASE_LEN) return passphrase
async def interact( self, ctx: wire.GenericContext, code: ButtonRequestType = ButtonRequestType.Other, ) -> Any: workflow.close_others() await ctx.call(ButtonRequest(code=code, pages=len(self.pages)), ButtonAck) result = WAS_PAGED while result is WAS_PAGED: result = await ctx.wait(self) return result
async def button_request( ctx: wire.GenericContext, br_type: str, code: ButtonRequestType = ButtonRequestType.Other, pages: int | None = None, ) -> None: if __debug__: log.debug(__name__, "ButtonRequest.type=%s", br_type) workflow.close_others() if pages is not None: await ctx.call(ButtonRequest(code=code, pages=pages), ButtonAck) else: await ctx.call(ButtonRequest(code=code), ButtonAck)
def lock_device() -> None: if config.has_pin(): config.lock() wire.find_handler = get_pinlocked_handler set_homescreen() workflow.close_others()
def _start_progress() -> None: # Because we are drawing to the screen manually, without a layout, we # should make sure that no other layout is running. workflow.close_others() t = Text("Please wait", ui.ICON_CONFIG) ui.draw_simple(t)
def report_init() -> None: workflow.close_others() ui.display.clear() ui.header("Signing transaction")
async def button_request( ctx: wire.GenericContext, code: EnumTypeButtonRequestType = ButtonRequestType.Other) -> None: workflow.close_others() await ctx.call(ButtonRequest(code=code), ButtonAck)