예제 #1
0
async def require_confirm_ecdh_session_key(ctx: wire.Context,
                                           identity: IdentityType) -> None:
    lines = chunks(serialize_identity_without_proto(identity), 18)
    proto = identity.proto.upper() if identity.proto else "identity"
    text = Text("Decrypt %s" % proto)
    text.mono(*lines)
    await require_confirm(ctx, text)
예제 #2
0
async def confirm_asset_issuer(ctx, asset: StellarAssetType):
    if asset is None or asset.type == consts.ASSET_TYPE_NATIVE:
        return
    text = Text("Confirm issuer", ui.ICON_CONFIRM, ui.GREEN)
    text.bold("%s issuer:" % asset.code)
    text.mono(*split(asset.issuer))
    await require_confirm(ctx, text, ButtonRequestType.ConfirmOutput)
예제 #3
0
async def require_confirm_init(ctx, address: str, network_passphrase: str,
                               accounts_match: bool):
    text = Text("Confirm Stellar", ui.ICON_SEND, ui.GREEN)
    text.normal("Initialize signing with")
    if accounts_match:
        text.normal("your account")
        text.mono(*split(trim_to_rows(address, 3)))
    else:
        text.mono(*split(address))
    await require_confirm(ctx, text, ButtonRequestType.ConfirmOutput)
    network = get_network_warning(network_passphrase)
    if network:
        text = Text("Confirm network", ui.ICON_CONFIRM, ui.GREEN)
        text.normal("Transaction is on")
        text.bold(network)
        await require_confirm(ctx, text, ButtonRequestType.ConfirmOutput)
예제 #4
0
async def confirm_payment_op(ctx, op: StellarPaymentOp):
    text = Text("Confirm operation", ui.ICON_CONFIRM, ui.GREEN)
    text.bold("Pay %s" % format_amount(op.amount, ticker=False))
    text.bold("%s to:" % format_asset_code(op.asset))
    text.mono(*split(trim_to_rows(op.destination_account, 3)))
    await require_confirm(ctx, text, ButtonRequestType.ConfirmOutput)
    await confirm_asset_issuer(ctx, op.asset)
예제 #5
0
async def pin_mismatch() -> None:
    text = Text("PIN mismatch", ui.ICON_WRONG, ui.RED)
    text.normal("The PINs you entered", "do not match.")
    text.normal("")
    text.normal("Please try again.")
    popup = Popup(text, 3000)  # show for 3 seconds
    await popup
예제 #6
0
def _entry_dialog() -> None:
    from trezor.ui import ICON_CONFIG, draw_simple
    from trezor.ui.components.tt.text import Text

    text = Text("Passphrase entry", ICON_CONFIG)
    text.normal("Please type your", "passphrase on the", "connected host.")
    draw_simple(text)
예제 #7
0
async def require_confirm_experimental_features(ctx, enable: bool) -> None:
    if enable:
        text = Text("Experimental mode", ui.ICON_CONFIG)
        text.normal("Enable experimental", "features?")
        text.br_half()
        text.bold("Only for development", "and beta testing!")
        await require_confirm(ctx, text, ButtonRequestType.ProtectCall)
예제 #8
0
async def error_pin_matches_wipe_code(ctx: wire.Context) -> NoReturn:
    from apps.common.confirm import confirm

    text = Text("Invalid PIN", ui.ICON_WRONG, ui.RED)
    text.normal("The new PIN must be", "different from your", "wipe code.")
    await confirm(ctx, text, confirm=None, cancel="Close")
    raise wire.PinInvalid
예제 #9
0
async def confirm_path_payment_op(ctx, op: StellarPathPaymentOp):
    text = Text("Confirm operation", ui.ICON_CONFIRM, ui.GREEN)
    text.bold("Path Pay %s" % format_amount(op.destination_amount, ticker=False))
    text.bold("%s to:" % format_asset_code(op.destination_asset))
    text.mono(*split(trim_to_rows(op.destination_account, 3)))
    await require_confirm(ctx, text, ButtonRequestType.ConfirmOutput)
    await confirm_asset_issuer(ctx, op.destination_asset)
    # confirm what the sender is using to pay
    text = Text("Confirm operation", ui.ICON_CONFIRM, ui.GREEN)
    text.normal("Pay using")
    text.bold(format_amount(op.send_max, ticker=False))
    text.bold(format_asset_code(op.send_asset))
    text.normal("This amount is debited")
    text.normal("from your account.")
    await require_confirm(ctx, text, ButtonRequestType.ConfirmOutput)
    await confirm_asset_issuer(ctx, op.send_asset)
예제 #10
0
async def show_warning_tx_network_unverifiable(ctx: wire.Context) -> None:
    page1 = Text("Warning", ui.ICON_SEND, ui.GREEN)
    page1.normal("Transaction has no outputs, network cannot be verified.")
    page1.br_half()
    page1.normal("Continue?")

    await require_confirm(ctx, page1)
예제 #11
0
async def require_confirm_change_passphrase(ctx, use):
    text = Text("Enable passphrase" if use else "Disable passphrase",
                ui.ICON_CONFIG)
    text.normal("Do you really want to")
    text.normal("enable passphrase" if use else "disable passphrase")
    text.normal("encryption?")
    await require_confirm(ctx, text, ButtonRequestType.ProtectCall)
예제 #12
0
def _paginate_text(
    first_page: Text,
    page_desc: str,
    page_icon: str,
    text: str,
    lines_per_page: int = 5,
    lines_used_on_first_page: int = 1,
) -> list[ui.Component]:
    lines = list(chunks(text, 17))

    offset = lines_per_page - lines_used_on_first_page

    for text_line in lines[:offset]:
        first_page.bold(text_line)

    pages: list[ui.Component] = [first_page]
    if len(lines) > offset:
        to_pages = list(chunks(lines[offset:], lines_per_page))
        for page in to_pages:
            t = Text(page_desc, page_icon, ui.GREEN)
            for line in page:
                t.bold(line)
            pages.append(t)

    return pages
예제 #13
0
async def show_warning_path(ctx: wire.Context, path: list[int], title: str) -> None:
    page1 = Text("Confirm path", ui.ICON_WRONG, ui.RED)
    page1.normal(title)
    page1.bold(address_n_to_str(path))
    page1.normal("is unknown.")
    page1.normal("Are you sure?")
    await require_confirm(ctx, page1)
예제 #14
0
async def confirm_stake_pool_owners(
    ctx: wire.Context,
    keychain: seed.Keychain,
    owners: list[CardanoPoolOwnerType],
    network_id: int,
) -> None:
    pages: list[ui.Component] = []
    for index, owner in enumerate(owners, 1):
        page = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
        page.normal("Pool owner #%d:" % (index))

        if owner.staking_key_path:
            page.bold(address_n_to_str(owner.staking_key_path))
            page.normal(
                encode_human_readable_address(
                    pack_reward_address_bytes(
                        get_public_key_hash(keychain, owner.staking_key_path),
                        network_id,
                    )
                )
            )
        else:
            assert owner.staking_key_hash is not None  # validate_pool_owners
            page.bold(
                encode_human_readable_address(
                    pack_reward_address_bytes(owner.staking_key_hash, network_id)
                )
            )

        pages.append(page)

    await require_confirm(ctx, Paginated(pages))
예제 #15
0
async def error_pin_invalid(ctx: wire.Context) -> NoReturn:
    from apps.common.confirm import confirm

    text = Text("Wrong PIN", ui.ICON_WRONG, ui.RED)
    text.normal("The PIN you entered is", "invalid.")
    await confirm(ctx, text, confirm=None, cancel="Close")
    raise wire.PinInvalid
예제 #16
0
async def require_confirm_origination_fee(ctx, balance, fee):
    text = Text("Confirm origination", ui.ICON_SEND, ui.ORANGE)
    text.normal("Balance:")
    text.bold(format_tezos_amount(balance))
    text.normal("Fee:")
    text.bold(format_tezos_amount(fee))
    await require_hold_to_confirm(ctx, text, ButtonRequestType.SignTx)
예제 #17
0
async def require_confirm_fee(ctx, value, fee):
    text = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
    text.normal("Amount:")
    text.bold(format_tezos_amount(value))
    text.normal("Fee:")
    text.bold(format_tezos_amount(fee))
    await require_hold_to_confirm(ctx, text, ButtonRequestType.SignTx)
예제 #18
0
async def require_confirm_final(ctx, fee: int):
    text = Text("Final confirm", ui.ICON_SEND, ui.GREEN)
    text.normal("Sign this transaction")
    text.bold("and pay %s XEM" % format_amount(fee, NEM_MAX_DIVISIBILITY))
    text.normal("for network fee?")
    # we use SignTx, not ConfirmOutput, for compatibility with T1
    await require_hold_to_confirm(ctx, text, ButtonRequestType.SignTx)
예제 #19
0
async def confirm_stake_pool_registration_final(
    ctx: wire.Context,
) -> None:

    page1 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
    page1.normal("Confirm signing the stake pool registration as an owner")

    await require_hold_to_confirm(ctx, page1)
예제 #20
0
async def show_warning_tx_different_staking_account(
    ctx: wire.Context,
    staking_account_path: List[int],
    amount: int,
) -> None:
    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.")

    page2 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
    page2.normal("Staking account %s:" % format_account_number(staking_account_path))
    page2.bold(address_n_to_str(staking_account_path))
    page2.normal("Change amount:")
    page2.bold(format_coin_amount(amount))

    await require_confirm(ctx, Paginated([page1, page2]))
예제 #21
0
async def _continue_dialog(ctx: wire.Context, msg: RecoveryDevice) -> None:
    if not msg.dry_run:
        text = Text("Recovery mode", ui.ICON_RECOVERY, new_lines=False)
        text.bold("Do you really want to")
        text.br()
        text.bold("recover a wallet?")

        text.br()
        text.br_half()
        text.normal("By continuing you agree")
        text.br()
        text.normal("to")
        text.bold("https://trezor.io/tos")
    else:
        text = Text("Seed check", ui.ICON_RECOVERY, new_lines=False)
        text.normal("Do you really want to", "check the recovery", "seed?")
    await require_confirm(ctx, text, code=ButtonRequestType.ProtectCall)
예제 #22
0
async def confirm_sending_token_bundle(
    ctx: wire.Context, token_bundle: List[CardanoAssetGroupType]
) -> None:
    for token_group in token_bundle:
        for token in token_group.tokens:
            page1 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
            page1.normal("Asset fingerprint:")
            page1.bold(
                format_asset_fingerprint(
                    policy_id=token_group.policy_id,
                    asset_name_bytes=token.asset_name_bytes,
                )
            )
            page2 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
            page2.normal("Amount sent:")
            page2.bold(format_amount(token.amount, 0))
            await require_confirm(ctx, Paginated([page1, page2]))
예제 #23
0
async def show_dry_run_different_type(ctx: wire.GenericContext) -> None:
    text = Text("Dry run failure", ui.ICON_CANCEL)
    text.normal("Seed in the device was")
    text.normal("created using another")
    text.normal("backup mechanism.")
    await require_confirm(
        ctx, text, ButtonRequestType.ProtectCall, cancel=None, confirm="Continue"
    )
예제 #24
0
async def confirm_action_deleteauth(ctx: wire.Context,
                                    msg: EosActionDeleteAuth) -> None:
    text = Text("Delete auth", ui.ICON_CONFIRM, icon_color=ui.GREEN)
    text.normal("Account:")
    text.normal(helpers.eos_name_to_string(msg.account))
    text.normal("Permission:")
    text.normal(helpers.eos_name_to_string(msg.permission))
    await require_confirm(ctx, text, ButtonRequestType.ConfirmOutput)
예제 #25
0
async def show_auxiliary_data_hash(
    ctx: wire.Context, auxiliary_data_hash: bytes
) -> None:
    page1 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
    page1.normal("Auxiliary data hash:")
    page1.bold(hexlify(auxiliary_data_hash).decode())

    await require_confirm(ctx, page1)
예제 #26
0
async def format_card_dialog(ctx: wire.GenericContext) -> bool:
    # Format card? yes/no
    text = Text("SD card error", ui.ICON_WRONG, ui.RED)
    text.bold("Unknown filesystem.")
    text.br_half()
    text.normal("Use a different card or")
    text.normal("format the SD card to")
    text.normal("the FAT32 filesystem.")
    if not await confirm(ctx, text, confirm="Format", cancel="Cancel"):
        return False

    # Confirm formatting
    text = Text("Format SD card", ui.ICON_WIPE, ui.RED)
    text.normal("Do you really want to", "format the SD card?")
    text.br_half()
    text.bold("All data on the SD card", "will be lost.")
    return await hold_to_confirm(ctx, text, confirm="Format SD card")
예제 #27
0
async def show_group_share_success(ctx: wire.GenericContext, share_index: int,
                                   group_index: int) -> None:
    text = Text("Success", ui.ICON_CONFIRM)
    text.bold("You have entered")
    text.bold("Share %s" % (share_index + 1))
    text.normal("from")
    text.bold("Group %s" % (group_index + 1))

    await confirm(ctx, text, confirm="Continue", cancel=None)
예제 #28
0
async def show_warning_tx_output_contains_tokens(ctx: wire.Context) -> None:
    page1 = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
    page1.normal("The following")
    page1.normal("transaction output")
    page1.normal("contains tokens.")
    page1.br_half()
    page1.normal("Continue?")

    await require_confirm(ctx, page1)
예제 #29
0
async def show_warning_address_pointer(
        ctx: wire.Context, pointer: CardanoBlockchainPointerType) -> None:
    text = Text("Warning", ui.ICON_WRONG, ui.RED)
    text.normal("Pointer address:")
    text.normal("Block: %s" % pointer.block_index)
    text.normal("Transaction: %s" % pointer.tx_index)
    text.normal("Certificate: %s" % pointer.certificate_index)
    text.normal("Continue?")
    await require_confirm(ctx, text)
예제 #30
0
async def require_confirm_data(ctx, data, data_total):
    data_str = hexlify(data[:36]).decode()
    if data_total > 36:
        data_str = data_str[:-2] + ".."
    text = Text("Confirm data", ui.ICON_SEND, ui.GREEN)
    text.bold("Size: %d bytes" % data_total)
    text.mono(*split_data(data_str))
    # we use SignTx, not ConfirmOutput, for compatibility with T1
    await require_confirm(ctx, text, ButtonRequestType.SignTx)