2018-06-11 13:54:57 +00:00
|
|
|
from micropython import const
|
2018-07-03 14:20:26 +00:00
|
|
|
|
2018-06-11 13:54:57 +00:00
|
|
|
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
|
|
|
|
|
2018-07-03 14:20:26 +00:00
|
|
|
from apps.common.confirm import confirm
|
|
|
|
|
2018-06-11 13:54:57 +00:00
|
|
|
|
|
|
|
async def show_address(ctx, address: str):
|
|
|
|
lines = split_address(address)
|
2018-07-03 14:20:58 +00:00
|
|
|
text = Text("Confirm address", ui.ICON_RECEIVE, icon_color=ui.GREEN)
|
2018-07-02 13:19:04 +00:00
|
|
|
text.mono(*lines)
|
2018-06-11 13:54:57 +00:00
|
|
|
return await confirm(
|
2018-07-03 14:20:58 +00:00
|
|
|
ctx, text, code=ButtonRequestType.Address, cancel="QR", cancel_style=ui.BTN_KEY
|
|
|
|
)
|
2018-06-11 13:54:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
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)
|
2018-07-03 14:20:58 +00:00
|
|
|
text = Text("Confirm address", ui.ICON_RECEIVE, icon_color=ui.GREEN)
|
2018-07-02 13:19:04 +00:00
|
|
|
content = Container(qr, text)
|
2018-06-11 13:54:57 +00:00
|
|
|
return await confirm(
|
|
|
|
ctx,
|
|
|
|
content,
|
|
|
|
code=ButtonRequestType.Address,
|
2018-07-03 14:20:58 +00:00
|
|
|
cancel="Address",
|
|
|
|
cancel_style=ui.BTN_KEY,
|
|
|
|
)
|
2018-06-11 13:54:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
def split_address(address: str):
|
|
|
|
return chunks(address, 17)
|