mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-27 01:48:17 +00:00
src/apps/common/request_pin: cancel is optional
This commit is contained in:
parent
168cbabbf5
commit
76590c44ad
@ -7,7 +7,7 @@ class PinCancelled(Exception):
|
|||||||
|
|
||||||
|
|
||||||
@ui.layout
|
@ui.layout
|
||||||
async def request_pin(code: int = None) -> str:
|
async def request_pin(code: int = None, cancellable: bool = True) -> str:
|
||||||
from trezor.ui.confirm import ConfirmDialog, CONFIRMED
|
from trezor.ui.confirm import ConfirmDialog, CONFIRMED
|
||||||
from trezor.ui.pin import PinMatrix
|
from trezor.ui.pin import PinMatrix
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ async def request_pin(code: int = None) -> str:
|
|||||||
c.render()
|
c.render()
|
||||||
else:
|
else:
|
||||||
lock = res.load(ui.ICON_LOCK)
|
lock = res.load(ui.ICON_LOCK)
|
||||||
if c.content is not lock:
|
if c.content is not lock and cancellable:
|
||||||
c.normal_style = ui.BTN_CANCEL['normal']
|
c.normal_style = ui.BTN_CANCEL['normal']
|
||||||
c.content = lock
|
c.content = lock
|
||||||
c.taint()
|
c.taint()
|
||||||
@ -37,6 +37,9 @@ async def request_pin(code: int = None) -> str:
|
|||||||
dialog.cancel.area = ui.grid(12)
|
dialog.cancel.area = ui.grid(12)
|
||||||
dialog.confirm.area = ui.grid(14)
|
dialog.confirm.area = ui.grid(14)
|
||||||
matrix.onchange()
|
matrix.onchange()
|
||||||
|
if not cancellable:
|
||||||
|
dialog.cancel.content = ''
|
||||||
|
dialog.cancel.disable()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
result = await dialog
|
result = await dialog
|
||||||
|
@ -3,22 +3,24 @@ from trezor import config
|
|||||||
from trezor.pin import pin_to_int, show_pin_timeout
|
from trezor.pin import pin_to_int, show_pin_timeout
|
||||||
|
|
||||||
|
|
||||||
async def request_pin(ctx, code: int = None):
|
async def request_pin(ctx, *args, **kwargs):
|
||||||
from trezor.messages.ButtonRequest import ButtonRequest
|
from trezor.messages.ButtonRequest import ButtonRequest
|
||||||
from trezor.messages.wire_types import ButtonAck
|
from trezor.messages.wire_types import ButtonAck
|
||||||
from apps.common.request_pin import request_pin
|
from apps.common.request_pin import request_pin
|
||||||
|
|
||||||
await ctx.call(ButtonRequest(), ButtonAck)
|
await ctx.call(ButtonRequest(), ButtonAck)
|
||||||
|
|
||||||
return await request_pin(code)
|
return await request_pin(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
async def request_pin_confirm(ctx):
|
async def request_pin_confirm(ctx, *args, **kwargs):
|
||||||
from trezor.messages import PinMatrixRequestType
|
from trezor.messages import PinMatrixRequestType
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
pin1 = await request_pin(ctx, PinMatrixRequestType.NewFirst)
|
pin1 = await request_pin(
|
||||||
pin2 = await request_pin(ctx, PinMatrixRequestType.NewSecond)
|
ctx, code=PinMatrixRequestType.NewFirst, *args, **kwargs)
|
||||||
|
pin2 = await request_pin(
|
||||||
|
ctx, code=PinMatrixRequestType.NewSecond, *args, **kwargs)
|
||||||
if pin1 == pin2:
|
if pin1 == pin2:
|
||||||
return pin1
|
return pin1
|
||||||
# TODO: display a message and wait
|
# TODO: display a message and wait
|
||||||
|
Loading…
Reference in New Issue
Block a user