2020-07-23 13:54:49 +00:00
|
|
|
from trezor import ui
|
2021-03-23 12:35:27 +00:00
|
|
|
from trezor.enums import ButtonRequestType, CardanoAddressType, CardanoCertificateType
|
2020-07-23 13:54:49 +00:00
|
|
|
from trezor.strings import format_amount
|
2021-03-10 09:52:26 +00:00
|
|
|
from trezor.ui.layouts import (
|
|
|
|
confirm_metadata,
|
|
|
|
confirm_output,
|
|
|
|
confirm_path_warning,
|
|
|
|
confirm_properties,
|
|
|
|
)
|
2020-07-23 13:54:49 +00:00
|
|
|
|
2020-12-17 21:25:28 +00:00
|
|
|
from apps.common.layout import address_n_to_str
|
2020-07-23 13:54:49 +00:00
|
|
|
|
2020-09-29 18:23:25 +00:00
|
|
|
from . import seed
|
|
|
|
from .address import (
|
|
|
|
encode_human_readable_address,
|
|
|
|
get_public_key_hash,
|
|
|
|
pack_reward_address_bytes,
|
|
|
|
)
|
2020-07-23 13:54:49 +00:00
|
|
|
from .helpers import protocol_magics
|
2021-02-08 21:00:00 +00:00
|
|
|
from .helpers.utils import (
|
|
|
|
format_account_number,
|
2021-03-02 18:08:14 +00:00
|
|
|
format_asset_fingerprint,
|
2021-02-08 21:00:00 +00:00
|
|
|
format_optional_int,
|
|
|
|
format_stake_pool_id,
|
|
|
|
to_account_path,
|
|
|
|
)
|
2020-07-23 13:54:49 +00:00
|
|
|
|
|
|
|
if False:
|
|
|
|
from trezor import wire
|
2021-03-23 12:35:27 +00:00
|
|
|
from trezor.messages import (
|
2020-07-27 10:48:31 +00:00
|
|
|
CardanoBlockchainPointerType,
|
2021-03-23 12:35:27 +00:00
|
|
|
CardanoTxCertificateType,
|
|
|
|
CardanoTxWithdrawalType,
|
|
|
|
CardanoPoolParametersType,
|
|
|
|
CardanoPoolOwnerType,
|
|
|
|
CardanoPoolMetadataType,
|
|
|
|
CardanoAssetGroupType,
|
2020-07-27 10:48:31 +00:00
|
|
|
)
|
2020-07-23 13:54:49 +00:00
|
|
|
|
2021-06-23 08:02:09 +00:00
|
|
|
from trezor.ui.layouts import PropertyType
|
|
|
|
|
2020-07-23 13:54:49 +00:00
|
|
|
|
|
|
|
ADDRESS_TYPE_NAMES = {
|
|
|
|
CardanoAddressType.BYRON: "Legacy",
|
|
|
|
CardanoAddressType.BASE: "Base",
|
|
|
|
CardanoAddressType.POINTER: "Pointer",
|
|
|
|
CardanoAddressType.ENTERPRISE: "Enterprise",
|
|
|
|
CardanoAddressType.REWARD: "Reward",
|
|
|
|
}
|
|
|
|
|
2020-07-27 10:48:31 +00:00
|
|
|
CERTIFICATE_TYPE_NAMES = {
|
|
|
|
CardanoCertificateType.STAKE_REGISTRATION: "Stake key registration",
|
|
|
|
CardanoCertificateType.STAKE_DEREGISTRATION: "Stake key deregistration",
|
|
|
|
CardanoCertificateType.STAKE_DELEGATION: "Stake delegation",
|
2020-09-29 18:23:25 +00:00
|
|
|
CardanoCertificateType.STAKE_POOL_REGISTRATION: "Stakepool registration",
|
2020-07-27 10:48:31 +00:00
|
|
|
}
|
|
|
|
|
2020-07-23 13:54:49 +00:00
|
|
|
|
|
|
|
def format_coin_amount(amount: int) -> str:
|
|
|
|
return "%s %s" % (format_amount(amount, 6), "ADA")
|
|
|
|
|
|
|
|
|
2021-01-25 16:12:32 +00:00
|
|
|
def is_printable_ascii_bytestring(bytestr: bytes) -> bool:
|
|
|
|
return all((32 < b < 127) for b in bytestr)
|
|
|
|
|
|
|
|
|
|
|
|
async def confirm_sending(
|
|
|
|
ctx: wire.Context,
|
|
|
|
ada_amount: int,
|
2021-03-18 09:48:50 +00:00
|
|
|
token_bundle: list[CardanoAssetGroupType],
|
2021-01-25 16:12:32 +00:00
|
|
|
to: str,
|
|
|
|
) -> None:
|
2021-03-02 18:08:14 +00:00
|
|
|
await confirm_sending_token_bundle(ctx, token_bundle)
|
2021-01-25 16:12:32 +00:00
|
|
|
|
2021-03-10 09:52:26 +00:00
|
|
|
await confirm_output(
|
|
|
|
ctx,
|
2021-04-01 13:17:58 +00:00
|
|
|
to,
|
2021-03-10 09:52:26 +00:00
|
|
|
format_coin_amount(ada_amount),
|
|
|
|
title="Confirm transaction",
|
|
|
|
subtitle="Confirm sending:",
|
|
|
|
font_amount=ui.BOLD,
|
|
|
|
width_paginated=17,
|
|
|
|
to_str="\nto\n",
|
|
|
|
to_paginated=True,
|
|
|
|
br_code=ButtonRequestType.Other,
|
2021-04-01 13:17:58 +00:00
|
|
|
)
|
2020-07-23 13:54:49 +00:00
|
|
|
|
|
|
|
|
2021-03-02 18:08:14 +00:00
|
|
|
async def confirm_sending_token_bundle(
|
2021-03-18 09:48:50 +00:00
|
|
|
ctx: wire.Context, token_bundle: list[CardanoAssetGroupType]
|
2021-01-25 16:12:32 +00:00
|
|
|
) -> None:
|
2021-03-02 18:08:14 +00:00
|
|
|
for token_group in token_bundle:
|
|
|
|
for token in token_group.tokens:
|
2021-03-10 09:52:26 +00:00
|
|
|
await confirm_properties(
|
|
|
|
ctx,
|
|
|
|
"confirm_token",
|
|
|
|
title="Confirm transaction",
|
|
|
|
props=[
|
|
|
|
(
|
|
|
|
"Asset fingerprint:",
|
|
|
|
format_asset_fingerprint(
|
|
|
|
policy_id=token_group.policy_id,
|
|
|
|
asset_name_bytes=token.asset_name_bytes,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
("Amount sent:", format_amount(token.amount, 0)),
|
|
|
|
],
|
|
|
|
br_code=ButtonRequestType.Other,
|
2021-03-02 18:08:14 +00:00
|
|
|
)
|
2021-01-25 16:12:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def show_warning_tx_output_contains_tokens(ctx: wire.Context) -> None:
|
2021-03-10 09:52:26 +00:00
|
|
|
await confirm_metadata(
|
|
|
|
ctx,
|
|
|
|
"confirm_tokens",
|
|
|
|
title="Confirm transaction",
|
|
|
|
content="The following\ntransaction output\ncontains tokens.",
|
|
|
|
larger_vspace=True,
|
|
|
|
br_code=ButtonRequestType.Other,
|
|
|
|
)
|
2021-01-25 16:12:32 +00:00
|
|
|
|
|
|
|
|
2021-03-18 09:48:50 +00:00
|
|
|
async def show_warning_path(ctx: wire.Context, path: list[int], title: str) -> None:
|
2021-03-10 09:52:26 +00:00
|
|
|
await confirm_path_warning(ctx, address_n_to_str(path), path_type=title)
|
2021-01-21 09:32:23 +00:00
|
|
|
|
|
|
|
|
2020-07-23 13:54:49 +00:00
|
|
|
async def show_warning_tx_no_staking_info(
|
2021-03-23 12:35:27 +00:00
|
|
|
ctx: wire.Context, address_type: CardanoAddressType, amount: int
|
2020-09-29 18:23:25 +00:00
|
|
|
) -> None:
|
2021-03-10 09:52:26 +00:00
|
|
|
atype = ADDRESS_TYPE_NAMES[address_type].lower()
|
|
|
|
content = "Change %s address has no stake rights.\nChange amount:\n{}" % atype
|
|
|
|
await confirm_metadata(
|
|
|
|
ctx,
|
|
|
|
"warning_staking",
|
|
|
|
title="Confirm transaction",
|
|
|
|
content=content,
|
|
|
|
param=format_coin_amount(amount),
|
|
|
|
hide_continue=True,
|
|
|
|
br_code=ButtonRequestType.Other,
|
|
|
|
)
|
2020-07-23 13:54:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def show_warning_tx_pointer_address(
|
2020-09-25 11:59:16 +00:00
|
|
|
ctx: wire.Context,
|
|
|
|
pointer: CardanoBlockchainPointerType,
|
|
|
|
amount: int,
|
2020-09-29 18:23:25 +00:00
|
|
|
) -> None:
|
2021-03-10 09:52:26 +00:00
|
|
|
await confirm_properties(
|
|
|
|
ctx,
|
|
|
|
"warning_pointer",
|
|
|
|
title="Confirm transaction",
|
|
|
|
props=[
|
|
|
|
("Change address has a\npointer with staking\nrights.\n\n\n", None),
|
|
|
|
(
|
|
|
|
"Pointer:",
|
|
|
|
"%s, %s, %s"
|
|
|
|
% (
|
|
|
|
pointer.block_index,
|
|
|
|
pointer.tx_index,
|
|
|
|
pointer.certificate_index,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
("Change amount:", format_coin_amount(amount)),
|
|
|
|
],
|
|
|
|
br_code=ButtonRequestType.Other,
|
2020-07-23 13:54:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
async def show_warning_tx_different_staking_account(
|
2020-09-25 11:59:16 +00:00
|
|
|
ctx: wire.Context,
|
2021-03-18 09:48:50 +00:00
|
|
|
staking_account_path: list[int],
|
2020-09-25 11:59:16 +00:00
|
|
|
amount: int,
|
2020-09-29 18:23:25 +00:00
|
|
|
) -> None:
|
2021-03-10 09:52:26 +00:00
|
|
|
await confirm_properties(
|
|
|
|
ctx,
|
|
|
|
"warning_differentstaking",
|
|
|
|
title="Confirm transaction",
|
|
|
|
props=[
|
|
|
|
(
|
|
|
|
"Change address staking rights do not match the current account.\n\n",
|
|
|
|
None,
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"Staking account %s:" % format_account_number(staking_account_path),
|
|
|
|
address_n_to_str(staking_account_path),
|
|
|
|
),
|
|
|
|
("Change amount:", format_coin_amount(amount)),
|
|
|
|
],
|
|
|
|
br_code=ButtonRequestType.Other,
|
|
|
|
)
|
2020-07-23 13:54:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def show_warning_tx_staking_key_hash(
|
2020-09-25 11:59:16 +00:00
|
|
|
ctx: wire.Context,
|
|
|
|
staking_key_hash: bytes,
|
|
|
|
amount: int,
|
2020-09-29 18:23:25 +00:00
|
|
|
) -> None:
|
2021-03-10 09:52:26 +00:00
|
|
|
props = [
|
|
|
|
("Change address staking rights do not match the current account.\n\n", None),
|
2021-06-22 13:14:15 +00:00
|
|
|
("Staking key hash:", staking_key_hash),
|
2021-03-10 09:52:26 +00:00
|
|
|
("Change amount:", format_coin_amount(amount)),
|
|
|
|
]
|
2020-07-23 13:54:49 +00:00
|
|
|
|
2021-03-10 09:52:26 +00:00
|
|
|
await confirm_properties(
|
|
|
|
ctx,
|
|
|
|
"confirm_different_stakingrights",
|
|
|
|
title="Confirm transaction",
|
|
|
|
props=props,
|
|
|
|
br_code=ButtonRequestType.Other,
|
|
|
|
)
|
2020-07-23 13:54:49 +00:00
|
|
|
|
|
|
|
|
2020-07-29 06:22:36 +00:00
|
|
|
async def confirm_transaction(
|
2021-01-08 10:31:03 +00:00
|
|
|
ctx: wire.Context,
|
2020-12-03 21:53:30 +00:00
|
|
|
amount: int,
|
|
|
|
fee: int,
|
|
|
|
protocol_magic: int,
|
2021-03-18 09:48:50 +00:00
|
|
|
ttl: int | None,
|
|
|
|
validity_interval_start: int | None,
|
2020-12-03 21:53:30 +00:00
|
|
|
is_network_id_verifiable: bool,
|
2020-07-29 06:22:36 +00:00
|
|
|
) -> None:
|
2021-06-23 08:02:09 +00:00
|
|
|
props: list[PropertyType] = [
|
2021-03-10 09:52:26 +00:00
|
|
|
("Transaction amount:", format_coin_amount(amount)),
|
|
|
|
("Transaction fee:", format_coin_amount(fee)),
|
|
|
|
]
|
2020-11-02 18:27:34 +00:00
|
|
|
|
2020-12-03 21:53:30 +00:00
|
|
|
if is_network_id_verifiable:
|
2021-03-10 09:52:26 +00:00
|
|
|
props.append(("Network:", protocol_magics.to_ui_string(protocol_magic)))
|
|
|
|
|
|
|
|
props.append(
|
|
|
|
("Valid since: %s" % format_optional_int(validity_interval_start), None)
|
|
|
|
)
|
|
|
|
props.append(("TTL: %s" % format_optional_int(ttl), None))
|
2020-11-02 18:27:34 +00:00
|
|
|
|
2021-03-10 09:52:26 +00:00
|
|
|
await confirm_properties(
|
|
|
|
ctx,
|
|
|
|
"confirm_total",
|
|
|
|
title="Confirm transaction",
|
|
|
|
props=props,
|
|
|
|
hold=True,
|
|
|
|
br_code=ButtonRequestType.Other,
|
|
|
|
)
|
2020-07-23 13:54:49 +00:00
|
|
|
|
|
|
|
|
2020-07-27 10:48:31 +00:00
|
|
|
async def confirm_certificate(
|
|
|
|
ctx: wire.Context, certificate: CardanoTxCertificateType
|
2020-09-29 18:23:25 +00:00
|
|
|
) -> None:
|
|
|
|
# stake pool registration requires custom confirmation logic not covered
|
|
|
|
# in this call
|
|
|
|
assert certificate.type != CardanoCertificateType.STAKE_POOL_REGISTRATION
|
|
|
|
|
2021-03-10 09:52:26 +00:00
|
|
|
props = [
|
|
|
|
("Confirm:", CERTIFICATE_TYPE_NAMES[certificate.type]),
|
|
|
|
(
|
|
|
|
"for account %s:" % format_account_number(certificate.path),
|
|
|
|
address_n_to_str(to_account_path(certificate.path)),
|
|
|
|
),
|
|
|
|
]
|
2020-07-27 10:48:31 +00:00
|
|
|
if certificate.type == CardanoCertificateType.STAKE_DELEGATION:
|
2021-01-08 10:31:03 +00:00
|
|
|
assert certificate.pool is not None # validate_certificate
|
2021-03-10 09:52:26 +00:00
|
|
|
props.append(("to pool:", format_stake_pool_id(certificate.pool)))
|
2020-07-27 10:48:31 +00:00
|
|
|
|
2021-03-10 09:52:26 +00:00
|
|
|
await confirm_properties(
|
|
|
|
ctx,
|
|
|
|
"confirm_certificate",
|
|
|
|
title="Confirm transaction",
|
|
|
|
props=props,
|
|
|
|
br_code=ButtonRequestType.Other,
|
|
|
|
)
|
2020-07-27 10:48:31 +00:00
|
|
|
|
|
|
|
|
2020-09-29 18:23:25 +00:00
|
|
|
async def confirm_stake_pool_parameters(
|
|
|
|
ctx: wire.Context,
|
|
|
|
pool_parameters: CardanoPoolParametersType,
|
|
|
|
network_id: int,
|
|
|
|
protocol_magic: int,
|
|
|
|
) -> None:
|
|
|
|
margin_percentage = (
|
|
|
|
100.0 * pool_parameters.margin_numerator / pool_parameters.margin_denominator
|
|
|
|
)
|
|
|
|
percentage_formatted = ("%f" % margin_percentage).rstrip("0").rstrip(".")
|
2021-03-10 09:52:26 +00:00
|
|
|
await confirm_properties(
|
|
|
|
ctx,
|
|
|
|
"confirm_pool_registration",
|
|
|
|
title="Confirm transaction",
|
|
|
|
props=[
|
|
|
|
(
|
|
|
|
"Stake pool registration\nPool ID:",
|
|
|
|
format_stake_pool_id(pool_parameters.pool_id),
|
|
|
|
),
|
|
|
|
("Pool reward account:", pool_parameters.reward_account),
|
|
|
|
(
|
|
|
|
"Pledge: {}\nCost: {}\nMargin: {}%".format(
|
|
|
|
format_coin_amount(pool_parameters.pledge),
|
|
|
|
format_coin_amount(pool_parameters.cost),
|
|
|
|
percentage_formatted,
|
|
|
|
),
|
|
|
|
None,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
br_code=ButtonRequestType.Other,
|
|
|
|
)
|
2020-09-29 18:23:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def confirm_stake_pool_owners(
|
|
|
|
ctx: wire.Context,
|
2021-01-08 10:31:03 +00:00
|
|
|
keychain: seed.Keychain,
|
2021-03-18 09:48:50 +00:00
|
|
|
owners: list[CardanoPoolOwnerType],
|
2020-09-29 18:23:25 +00:00
|
|
|
network_id: int,
|
|
|
|
) -> None:
|
2021-03-10 09:52:26 +00:00
|
|
|
props: list[tuple[str, str | None]] = []
|
2020-09-29 18:23:25 +00:00
|
|
|
for index, owner in enumerate(owners, 1):
|
|
|
|
if owner.staking_key_path:
|
2021-03-10 09:52:26 +00:00
|
|
|
props.append(
|
|
|
|
("Pool owner #%d:" % index, address_n_to_str(owner.staking_key_path))
|
|
|
|
)
|
|
|
|
props.append(
|
|
|
|
(
|
|
|
|
encode_human_readable_address(
|
|
|
|
pack_reward_address_bytes(
|
|
|
|
get_public_key_hash(keychain, owner.staking_key_path),
|
|
|
|
network_id,
|
|
|
|
)
|
|
|
|
),
|
|
|
|
None,
|
2020-09-29 18:23:25 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
else:
|
2021-01-08 10:31:03 +00:00
|
|
|
assert owner.staking_key_hash is not None # validate_pool_owners
|
2021-03-10 09:52:26 +00:00
|
|
|
props.append(
|
|
|
|
(
|
|
|
|
"Pool owner #%d:" % index,
|
|
|
|
encode_human_readable_address(
|
|
|
|
pack_reward_address_bytes(owner.staking_key_hash, network_id)
|
|
|
|
),
|
2020-09-29 18:23:25 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2021-03-10 09:52:26 +00:00
|
|
|
await confirm_properties(
|
|
|
|
ctx,
|
|
|
|
"confirm_pool_owners",
|
|
|
|
title="Confirm transaction",
|
|
|
|
props=props,
|
|
|
|
br_code=ButtonRequestType.Other,
|
|
|
|
)
|
2020-09-29 18:23:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def confirm_stake_pool_metadata(
|
|
|
|
ctx: wire.Context,
|
2021-03-18 09:48:50 +00:00
|
|
|
metadata: CardanoPoolMetadataType | None,
|
2020-09-29 18:23:25 +00:00
|
|
|
) -> None:
|
|
|
|
if metadata is None:
|
2021-03-10 09:52:26 +00:00
|
|
|
await confirm_properties(
|
|
|
|
ctx,
|
|
|
|
"confirm_pool_metadata",
|
|
|
|
title="Confirm transaction",
|
|
|
|
props=[("Pool has no metadata (anonymous pool)", None)],
|
|
|
|
br_code=ButtonRequestType.Other,
|
|
|
|
)
|
2020-09-29 18:23:25 +00:00
|
|
|
return
|
|
|
|
|
2021-03-10 09:52:26 +00:00
|
|
|
await confirm_properties(
|
|
|
|
ctx,
|
|
|
|
"confirm_pool_metadata",
|
|
|
|
title="Confirm transaction",
|
|
|
|
props=[
|
|
|
|
("Pool metadata url:", metadata.url),
|
2021-06-22 13:14:15 +00:00
|
|
|
("Pool metadata hash:", metadata.hash),
|
2021-03-10 09:52:26 +00:00
|
|
|
],
|
|
|
|
br_code=ButtonRequestType.Other,
|
|
|
|
)
|
2020-09-29 18:23:25 +00:00
|
|
|
|
|
|
|
|
2021-01-25 16:12:32 +00:00
|
|
|
async def confirm_transaction_network_ttl(
|
2021-01-08 10:31:03 +00:00
|
|
|
ctx: wire.Context,
|
|
|
|
protocol_magic: int,
|
2021-03-18 09:48:50 +00:00
|
|
|
ttl: int | None,
|
|
|
|
validity_interval_start: int | None,
|
2021-01-25 16:12:32 +00:00
|
|
|
) -> None:
|
2021-03-10 09:52:26 +00:00
|
|
|
await confirm_properties(
|
|
|
|
ctx,
|
|
|
|
"confirm_pool_network",
|
|
|
|
title="Confirm transaction",
|
|
|
|
props=[
|
|
|
|
("Network:", protocol_magics.to_ui_string(protocol_magic)),
|
|
|
|
(
|
|
|
|
"Valid since: %s" % format_optional_int(validity_interval_start),
|
|
|
|
None,
|
|
|
|
),
|
|
|
|
("TTL: %s" % format_optional_int(ttl), None),
|
|
|
|
],
|
|
|
|
br_code=ButtonRequestType.Other,
|
|
|
|
)
|
2020-11-02 18:27:34 +00:00
|
|
|
|
|
|
|
|
2020-09-29 18:23:25 +00:00
|
|
|
async def confirm_stake_pool_registration_final(
|
|
|
|
ctx: wire.Context,
|
|
|
|
) -> None:
|
2021-03-10 09:52:26 +00:00
|
|
|
await confirm_metadata(
|
|
|
|
ctx,
|
|
|
|
"confirm_pool_final",
|
|
|
|
title="Confirm transaction",
|
|
|
|
content="Confirm signing the stake pool registration as an owner",
|
|
|
|
hide_continue=True,
|
|
|
|
hold=True,
|
|
|
|
br_code=ButtonRequestType.Other,
|
|
|
|
)
|
2020-09-29 18:23:25 +00:00
|
|
|
|
|
|
|
|
2020-07-27 10:48:31 +00:00
|
|
|
async def confirm_withdrawal(
|
|
|
|
ctx: wire.Context, withdrawal: CardanoTxWithdrawalType
|
2020-09-29 18:23:25 +00:00
|
|
|
) -> None:
|
2021-03-10 09:52:26 +00:00
|
|
|
await confirm_properties(
|
|
|
|
ctx,
|
|
|
|
"confirm_withdrawal",
|
|
|
|
title="Confirm transaction",
|
|
|
|
props=[
|
|
|
|
(
|
|
|
|
"Confirm withdrawal\nfor account %s:"
|
|
|
|
% format_account_number(withdrawal.path),
|
|
|
|
address_n_to_str(to_account_path(withdrawal.path)),
|
|
|
|
),
|
|
|
|
("Amount:", format_coin_amount(withdrawal.amount)),
|
|
|
|
],
|
|
|
|
br_code=ButtonRequestType.Other,
|
|
|
|
)
|
2020-07-27 10:48:31 +00:00
|
|
|
|
|
|
|
|
2021-03-26 07:46:14 +00:00
|
|
|
async def confirm_catalyst_registration(
|
|
|
|
ctx: wire.Context,
|
|
|
|
public_key: str,
|
|
|
|
staking_path: list[int],
|
|
|
|
reward_address: str,
|
|
|
|
nonce: int,
|
|
|
|
) -> None:
|
2021-03-10 09:52:26 +00:00
|
|
|
await confirm_properties(
|
|
|
|
ctx,
|
|
|
|
"confirm_catalyst_registration",
|
|
|
|
title="Confirm transaction",
|
|
|
|
props=[
|
|
|
|
("Catalyst voting key registration", None),
|
|
|
|
("Voting public key:", public_key),
|
|
|
|
(
|
|
|
|
"Staking key for account %s:" % format_account_number(staking_path),
|
|
|
|
address_n_to_str(staking_path),
|
|
|
|
),
|
|
|
|
("Rewards go to:", reward_address),
|
|
|
|
("Nonce:", str(nonce)),
|
|
|
|
],
|
|
|
|
br_code=ButtonRequestType.Other,
|
2021-03-26 07:46:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
async def show_auxiliary_data_hash(
|
|
|
|
ctx: wire.Context, auxiliary_data_hash: bytes
|
|
|
|
) -> None:
|
2021-03-10 09:52:26 +00:00
|
|
|
await confirm_properties(
|
2020-07-23 13:54:49 +00:00
|
|
|
ctx,
|
2021-03-10 09:52:26 +00:00
|
|
|
"confirm_auxiliary_data",
|
|
|
|
title="Confirm transaction",
|
2021-06-22 13:14:15 +00:00
|
|
|
props=[("Auxiliary data hash:", auxiliary_data_hash)],
|
2021-03-10 09:52:26 +00:00
|
|
|
br_code=ButtonRequestType.Other,
|
2020-07-23 13:54:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
async def show_warning_address_foreign_staking_key(
|
|
|
|
ctx: wire.Context,
|
2021-03-18 09:48:50 +00:00
|
|
|
account_path: list[int],
|
|
|
|
staking_account_path: list[int],
|
|
|
|
staking_key_hash: bytes | None,
|
2020-07-23 13:54:49 +00:00
|
|
|
) -> None:
|
2021-06-23 08:02:09 +00:00
|
|
|
props: list[PropertyType] = [
|
2021-03-10 09:52:26 +00:00
|
|
|
(
|
|
|
|
"Stake rights associated with this address do not match your account %s:"
|
|
|
|
% format_account_number(account_path),
|
|
|
|
address_n_to_str(account_path),
|
|
|
|
)
|
|
|
|
]
|
|
|
|
|
2020-07-23 13:54:49 +00:00
|
|
|
if staking_account_path:
|
2021-03-10 09:52:26 +00:00
|
|
|
props.append(
|
|
|
|
(
|
|
|
|
"Stake account %s:" % format_account_number(staking_account_path),
|
|
|
|
address_n_to_str(staking_account_path),
|
|
|
|
)
|
|
|
|
)
|
2020-07-23 13:54:49 +00:00
|
|
|
else:
|
2021-01-08 10:31:03 +00:00
|
|
|
assert staking_key_hash is not None # _validate_base_address_staking_info
|
2021-06-22 13:14:15 +00:00
|
|
|
props.append(("Staking key:", staking_key_hash))
|
2021-03-10 09:52:26 +00:00
|
|
|
props.append(("Continue?", None))
|
2020-07-23 13:54:49 +00:00
|
|
|
|
2021-03-10 09:52:26 +00:00
|
|
|
await confirm_properties(
|
|
|
|
ctx,
|
|
|
|
"warning_foreign_stakingkey",
|
|
|
|
title="Warning",
|
|
|
|
props=props,
|
|
|
|
icon=ui.ICON_WRONG,
|
|
|
|
icon_color=ui.RED,
|
|
|
|
br_code=ButtonRequestType.Other,
|
|
|
|
)
|
2020-07-23 13:54:49 +00:00
|
|
|
|
|
|
|
|
2020-12-03 21:53:30 +00:00
|
|
|
async def show_warning_tx_network_unverifiable(ctx: wire.Context) -> None:
|
2021-03-10 09:52:26 +00:00
|
|
|
await confirm_metadata(
|
|
|
|
ctx,
|
|
|
|
"warning_no_outputs",
|
|
|
|
title="Warning",
|
|
|
|
content="Transaction has no outputs, network cannot be verified.",
|
|
|
|
larger_vspace=True,
|
|
|
|
br_code=ButtonRequestType.Other,
|
|
|
|
)
|
2020-12-03 21:53:30 +00:00
|
|
|
|
|
|
|
|
2020-07-23 13:54:49 +00:00
|
|
|
async def show_warning_address_pointer(
|
|
|
|
ctx: wire.Context, pointer: CardanoBlockchainPointerType
|
|
|
|
) -> None:
|
2021-03-10 09:52:26 +00:00
|
|
|
content = "Pointer address:\nBlock: %s\nTransaction: %s\nCertificate: %s" % (
|
|
|
|
pointer.block_index,
|
|
|
|
pointer.tx_index,
|
|
|
|
pointer.certificate_index,
|
|
|
|
)
|
|
|
|
await confirm_metadata(
|
|
|
|
ctx,
|
|
|
|
"warning_pointer",
|
|
|
|
title="Warning",
|
|
|
|
icon=ui.ICON_WRONG,
|
|
|
|
icon_color=ui.RED,
|
|
|
|
content=content,
|
|
|
|
br_code=ButtonRequestType.Other,
|
|
|
|
)
|