async def request_passphrase_ack(ctx: wire.Context, on_device: bool) -> str: if not on_device: text = Text("Passphrase entry", ui.ICON_CONFIG) text.normal("Please, type passphrase", "on connected host.") await Popup(text) req = PassphraseRequest(on_device=on_device) ack = await ctx.call(req, PassphraseAck) if on_device: if ack.passphrase is not None: raise wire.ProcessError( "Passphrase provided when it should not be") keyboard = PassphraseKeyboard("Enter passphrase", _MAX_PASSPHRASE_LEN) if __debug__: passphrase = await ctx.wait(keyboard, input_signal()) else: passphrase = await ctx.wait(keyboard) if passphrase is CANCELLED: raise wire.ActionCancelled("Passphrase cancelled") else: if ack.passphrase is None: raise wire.ProcessError("Passphrase not provided") passphrase = ack.passphrase state = cache.get_state(prev_state=ack.state, passphrase=passphrase) req = PassphraseStateRequest(state=state) ack = await ctx.call(req, PassphraseStateAck) return passphrase
async def request_passphrase_ack(ctx, on_device): if not on_device: text = Text('Passphrase entry', ui.ICON_CONFIG, 'Please, type passphrase', 'on connected host.') text.render() req = PassphraseRequest(on_device=on_device) ack = await ctx.call(req, wire_types.PassphraseAck, wire_types.Cancel) if ack.MESSAGE_WIRE_TYPE == wire_types.Cancel: raise wire.ActionCancelled('Passphrase cancelled') if on_device: if ack.passphrase is not None: raise wire.ProcessError( 'Passphrase provided when it should not be') keyboard = PassphraseKeyboard('Enter passphrase') passphrase = await ctx.wait(keyboard) if passphrase == CANCELLED: raise wire.ActionCancelled('Passphrase cancelled') else: if ack.passphrase is None: raise wire.ProcessError('Passphrase not provided') passphrase = ack.passphrase req = PassphraseStateRequest( state=get_state(prev_state=ack.state, passphrase=passphrase)) ack = await ctx.call(req, wire_types.PassphraseStateAck, wire_types.Cancel) return passphrase
async def request_passphrase_ack(ctx, on_device): if not on_device: text = Text("Passphrase entry", ui.ICON_CONFIG) text.normal("Please, type passphrase", "on connected host.") text.render() req = PassphraseRequest(on_device=on_device) ack = await ctx.call(req, MessageType.PassphraseAck, MessageType.Cancel) if ack.MESSAGE_WIRE_TYPE == MessageType.Cancel: raise wire.ActionCancelled("Passphrase cancelled") if on_device: if ack.passphrase is not None: raise wire.ProcessError( "Passphrase provided when it should not be") keyboard = PassphraseKeyboard("Enter passphrase") passphrase = await ctx.wait(keyboard) if passphrase == CANCELLED: raise wire.ActionCancelled("Passphrase cancelled") else: if ack.passphrase is None: raise wire.ProcessError("Passphrase not provided") passphrase = ack.passphrase req = PassphraseStateRequest( state=get_state(prev_state=ack.state, passphrase=passphrase)) ack = await ctx.call(req, MessageType.PassphraseStateAck, MessageType.Cancel) return passphrase
async def _request_on_device(ctx: wire.Context) -> str: await button_request(ctx, code=ButtonRequestType.PassphraseEntry) keyboard = PassphraseKeyboard("Enter passphrase", _MAX_PASSPHRASE_LEN) passphrase = await ctx.wait(keyboard) if passphrase is CANCELLED: raise wire.ActionCancelled("Passphrase entry cancelled") assert isinstance(passphrase, str) return passphrase
async def _request_on_device(ctx: wire.Context) -> str: await ctx.call(ButtonRequest(code=ButtonRequestType.PassphraseEntry), ButtonAck) keyboard = PassphraseKeyboard("Enter passphrase", _MAX_PASSPHRASE_LEN) if __debug__: passphrase = await ctx.wait(keyboard, input_signal()) else: passphrase = await ctx.wait(keyboard) if passphrase is CANCELLED: raise wire.ActionCancelled("Passphrase entry cancelled") assert isinstance(passphrase, str) return passphrase