1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-05 13:01:12 +00:00
trezor-firmware/src/apps/common/display_address.py

41 lines
1.0 KiB
Python
Raw Normal View History

from micropython import const
from apps.common.confirm import confirm
from trezor import ui
from trezor.messages import ButtonRequestType
from trezor.ui.container import Container
from trezor.ui.qr import Qr
from trezor.ui.text import Text
from trezor.utils import chunks
async def show_address(ctx, address: str):
lines = split_address(address)
2018-07-02 13:19:04 +00:00
text = Text('Confirm address', ui.ICON_RECEIVE, icon_color=ui.GREEN)
text.mono(*lines)
return await confirm(
ctx,
2018-07-02 13:19:04 +00:00
text,
code=ButtonRequestType.Address,
cancel='QR',
cancel_style=ui.BTN_KEY)
async def show_qr(ctx, address: str):
qr_x = const(120)
qr_y = const(115)
qr_coef = const(4)
2018-07-02 13:19:04 +00:00
qr = Qr(address, (qr_x, qr_y), qr_coef)
text = Text('Confirm address', ui.ICON_RECEIVE, icon_color=ui.GREEN)
content = Container(qr, text)
return await confirm(
ctx,
content,
code=ButtonRequestType.Address,
cancel='Address',
cancel_style=ui.BTN_KEY)
def split_address(address: str):
return chunks(address, 17)