|
|
|
@ -53,15 +53,15 @@ def format_coin_amount(amount: int) -> str:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def confirm_sending(ctx: wire.Context, amount: int, to: str):
|
|
|
|
|
t1 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
t1.normal("Confirm sending:")
|
|
|
|
|
t1.bold(format_coin_amount(amount))
|
|
|
|
|
t1.normal("to")
|
|
|
|
|
page1 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
page1.normal("Confirm sending:")
|
|
|
|
|
page1.bold(format_coin_amount(amount))
|
|
|
|
|
page1.normal("to")
|
|
|
|
|
|
|
|
|
|
to_lines = list(chunks(to, 17))
|
|
|
|
|
t1.bold(to_lines[0])
|
|
|
|
|
page1.bold(to_lines[0])
|
|
|
|
|
|
|
|
|
|
pages = [t1] + _paginate_lines(to_lines, 1, "Confirm transaction", ui.ICON_SEND)
|
|
|
|
|
pages = [page1] + _paginate_lines(to_lines, 1, "Confirm transaction", ui.ICON_SEND)
|
|
|
|
|
|
|
|
|
|
await require_confirm(ctx, Paginated(pages))
|
|
|
|
|
|
|
|
|
@ -69,89 +69,89 @@ async def confirm_sending(ctx: wire.Context, amount: int, to: str):
|
|
|
|
|
async def show_warning_tx_no_staking_info(
|
|
|
|
|
ctx: wire.Context, address_type: EnumTypeCardanoAddressType, amount: int
|
|
|
|
|
):
|
|
|
|
|
t1 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
t1.normal("Change " + ADDRESS_TYPE_NAMES[address_type].lower())
|
|
|
|
|
t1.normal("address has no stake")
|
|
|
|
|
t1.normal("rights.")
|
|
|
|
|
t1.normal("Change amount:")
|
|
|
|
|
t1.bold(format_coin_amount(amount))
|
|
|
|
|
page1 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
page1.normal("Change " + ADDRESS_TYPE_NAMES[address_type].lower())
|
|
|
|
|
page1.normal("address has no stake")
|
|
|
|
|
page1.normal("rights.")
|
|
|
|
|
page1.normal("Change amount:")
|
|
|
|
|
page1.bold(format_coin_amount(amount))
|
|
|
|
|
|
|
|
|
|
await require_confirm(ctx, t1)
|
|
|
|
|
await require_confirm(ctx, page1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def show_warning_tx_pointer_address(
|
|
|
|
|
ctx: wire.Context, pointer: CardanoBlockchainPointerType, amount: int,
|
|
|
|
|
):
|
|
|
|
|
t1 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
t1.normal("Change address has a")
|
|
|
|
|
t1.normal("pointer with staking")
|
|
|
|
|
t1.normal("rights.")
|
|
|
|
|
|
|
|
|
|
t2 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
t2.normal("Pointer:")
|
|
|
|
|
t2.bold(
|
|
|
|
|
page1 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
page1.normal("Change address has a")
|
|
|
|
|
page1.normal("pointer with staking")
|
|
|
|
|
page1.normal("rights.")
|
|
|
|
|
|
|
|
|
|
page2 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
page2.normal("Pointer:")
|
|
|
|
|
page2.bold(
|
|
|
|
|
"%s, %s, %s"
|
|
|
|
|
% (pointer.block_index, pointer.tx_index, pointer.certificate_index)
|
|
|
|
|
)
|
|
|
|
|
t2.normal("Change amount:")
|
|
|
|
|
t2.bold(format_coin_amount(amount))
|
|
|
|
|
page2.normal("Change amount:")
|
|
|
|
|
page2.bold(format_coin_amount(amount))
|
|
|
|
|
|
|
|
|
|
await require_confirm(ctx, Paginated([t1, t2]))
|
|
|
|
|
await require_confirm(ctx, Paginated([page1, page2]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def show_warning_tx_different_staking_account(
|
|
|
|
|
ctx: wire.Context, staking_account_path: List[int], amount: int,
|
|
|
|
|
):
|
|
|
|
|
t1 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
t1.normal("Change address staking")
|
|
|
|
|
t1.normal("rights do not match")
|
|
|
|
|
t1.normal("the current account.")
|
|
|
|
|
page1 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
page1.normal("Change address staking")
|
|
|
|
|
page1.normal("rights do not match")
|
|
|
|
|
page1.normal("the current account.")
|
|
|
|
|
|
|
|
|
|
t2 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
t2.normal("Staking account:")
|
|
|
|
|
t2.bold(address_n_to_str(staking_account_path))
|
|
|
|
|
t2.normal("Change amount:")
|
|
|
|
|
t2.bold(format_coin_amount(amount))
|
|
|
|
|
page2 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
page2.normal("Staking account:")
|
|
|
|
|
page2.bold(address_n_to_str(staking_account_path))
|
|
|
|
|
page2.normal("Change amount:")
|
|
|
|
|
page2.bold(format_coin_amount(amount))
|
|
|
|
|
|
|
|
|
|
await require_confirm(ctx, Paginated([t1, t2]))
|
|
|
|
|
await require_confirm(ctx, Paginated([page1, page2]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def show_warning_tx_staking_key_hash(
|
|
|
|
|
ctx: wire.Context, staking_key_hash: bytes, amount: int,
|
|
|
|
|
):
|
|
|
|
|
t1 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
t1.normal("Change address staking")
|
|
|
|
|
t1.normal("rights do not match")
|
|
|
|
|
t1.normal("the current account.")
|
|
|
|
|
page1 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
page1.normal("Change address staking")
|
|
|
|
|
page1.normal("rights do not match")
|
|
|
|
|
page1.normal("the current account.")
|
|
|
|
|
|
|
|
|
|
t2 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
t2.normal("Staking key hash:")
|
|
|
|
|
t2.mono(*chunks(hexlify(staking_key_hash), 17))
|
|
|
|
|
page2 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
page2.normal("Staking key hash:")
|
|
|
|
|
page2.mono(*chunks(hexlify(staking_key_hash), 17))
|
|
|
|
|
|
|
|
|
|
t3 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
t3.normal("Change amount:")
|
|
|
|
|
t3.bold(format_coin_amount(amount))
|
|
|
|
|
page3 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
page3.normal("Change amount:")
|
|
|
|
|
page3.bold(format_coin_amount(amount))
|
|
|
|
|
|
|
|
|
|
await require_confirm(ctx, Paginated([t1, t2, t3]))
|
|
|
|
|
await require_confirm(ctx, Paginated([page1, page2, page3]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def confirm_transaction(
|
|
|
|
|
ctx, amount: int, fee: int, protocol_magic: int, has_metadata: bool
|
|
|
|
|
) -> None:
|
|
|
|
|
t1 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
t1.normal("Transaction amount:")
|
|
|
|
|
t1.bold(format_coin_amount(amount))
|
|
|
|
|
t1.normal("Transaction fee:")
|
|
|
|
|
t1.bold(format_coin_amount(fee))
|
|
|
|
|
|
|
|
|
|
t2 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
t2.normal("Network:")
|
|
|
|
|
t2.bold(protocol_magics.to_ui_string(protocol_magic))
|
|
|
|
|
page1 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
page1.normal("Transaction amount:")
|
|
|
|
|
page1.bold(format_coin_amount(amount))
|
|
|
|
|
page1.normal("Transaction fee:")
|
|
|
|
|
page1.bold(format_coin_amount(fee))
|
|
|
|
|
|
|
|
|
|
page2 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
page2.normal("Network:")
|
|
|
|
|
page2.bold(protocol_magics.to_ui_string(protocol_magic))
|
|
|
|
|
if has_metadata:
|
|
|
|
|
t2.normal("Transaction contains")
|
|
|
|
|
t2.normal("metadata")
|
|
|
|
|
page2.normal("Transaction contains")
|
|
|
|
|
page2.normal("metadata")
|
|
|
|
|
|
|
|
|
|
await require_hold_to_confirm(ctx, Paginated([t1, t2]))
|
|
|
|
|
await require_hold_to_confirm(ctx, Paginated([page1, page2]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def confirm_certificate(
|
|
|
|
@ -159,18 +159,18 @@ async def confirm_certificate(
|
|
|
|
|
) -> bool:
|
|
|
|
|
pages = []
|
|
|
|
|
|
|
|
|
|
t1 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
t1.normal("Confirm:")
|
|
|
|
|
t1.bold(CERTIFICATE_TYPE_NAMES[certificate.type])
|
|
|
|
|
t1.normal("for account:")
|
|
|
|
|
t1.bold(address_n_to_str(to_account_path(certificate.path)))
|
|
|
|
|
pages.append(t1)
|
|
|
|
|
page1 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
page1.normal("Confirm:")
|
|
|
|
|
page1.bold(CERTIFICATE_TYPE_NAMES[certificate.type])
|
|
|
|
|
page1.normal("for account:")
|
|
|
|
|
page1.bold(address_n_to_str(to_account_path(certificate.path)))
|
|
|
|
|
pages.append(page1)
|
|
|
|
|
|
|
|
|
|
if certificate.type == CardanoCertificateType.STAKE_DELEGATION:
|
|
|
|
|
t2 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
t2.normal("to pool:")
|
|
|
|
|
t2.bold(hexlify(certificate.pool).decode())
|
|
|
|
|
pages.append(t2)
|
|
|
|
|
page2 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
page2.normal("to pool:")
|
|
|
|
|
page2.bold(hexlify(certificate.pool).decode())
|
|
|
|
|
pages.append(page2)
|
|
|
|
|
|
|
|
|
|
await require_confirm(ctx, Paginated(pages))
|
|
|
|
|
|
|
|
|
@ -178,14 +178,14 @@ async def confirm_certificate(
|
|
|
|
|
async def confirm_withdrawal(
|
|
|
|
|
ctx: wire.Context, withdrawal: CardanoTxWithdrawalType
|
|
|
|
|
) -> bool:
|
|
|
|
|
t1 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
t1.normal("Confirm withdrawal")
|
|
|
|
|
t1.normal("for account:")
|
|
|
|
|
t1.bold(address_n_to_str(to_account_path(withdrawal.path)))
|
|
|
|
|
t1.normal("Amount:")
|
|
|
|
|
t1.bold(format_coin_amount(withdrawal.amount))
|
|
|
|
|
page1 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
|
|
|
|
|
page1.normal("Confirm withdrawal")
|
|
|
|
|
page1.normal("for account:")
|
|
|
|
|
page1.bold(address_n_to_str(to_account_path(withdrawal.path)))
|
|
|
|
|
page1.normal("Amount:")
|
|
|
|
|
page1.bold(format_coin_amount(withdrawal.amount))
|
|
|
|
|
|
|
|
|
|
await require_confirm(ctx, t1)
|
|
|
|
|
await require_confirm(ctx, page1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def show_address(
|
|
|
|
@ -201,18 +201,18 @@ async def show_address(
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
address_type_label = "%s address" % ADDRESS_TYPE_NAMES[address_type]
|
|
|
|
|
t1 = Text(address_type_label, ui.ICON_RECEIVE, ui.GREEN)
|
|
|
|
|
page1 = Text(address_type_label, ui.ICON_RECEIVE, ui.GREEN)
|
|
|
|
|
|
|
|
|
|
lines_per_page = 5
|
|
|
|
|
lines_used_on_first_page = 0
|
|
|
|
|
|
|
|
|
|
# assemble first page to be displayed (path + network + whatever part of the address fits)
|
|
|
|
|
if network is not None:
|
|
|
|
|
t1.normal("%s network" % network)
|
|
|
|
|
page1.normal("%s network" % network)
|
|
|
|
|
lines_used_on_first_page += 1
|
|
|
|
|
|
|
|
|
|
path_str = address_n_to_str(path)
|
|
|
|
|
t1.mono(path_str)
|
|
|
|
|
page1.mono(path_str)
|
|
|
|
|
lines_used_on_first_page = min(
|
|
|
|
|
lines_used_on_first_page + math.ceil(len(path_str) / _MAX_MONO_LINE),
|
|
|
|
|
lines_per_page,
|
|
|
|
@ -220,10 +220,10 @@ async def show_address(
|
|
|
|
|
|
|
|
|
|
address_lines = list(chunks(address, 17))
|
|
|
|
|
for address_line in address_lines[: lines_per_page - lines_used_on_first_page]:
|
|
|
|
|
t1.bold(address_line)
|
|
|
|
|
page1.bold(address_line)
|
|
|
|
|
|
|
|
|
|
# append remaining pages containing the rest of the address
|
|
|
|
|
pages = [t1] + _paginate_lines(
|
|
|
|
|
pages = [page1] + _paginate_lines(
|
|
|
|
|
address_lines,
|
|
|
|
|
lines_per_page - lines_used_on_first_page,
|
|
|
|
|
address_type_label,
|
|
|
|
|