1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-12 17:38:13 +00:00

feat(contacts): new contact confirmation

This commit is contained in:
obrusvit 2024-12-11 13:55:54 +01:00
parent 951be5a1cd
commit 7c375bdc07
3 changed files with 58 additions and 9 deletions

View File

@ -810,6 +810,7 @@ extern "C" fn new_confirm_value(n_args: usize, args: *const Obj, kwargs: *mut Ma
.with_text_mono(text_mono) .with_text_mono(text_mono)
.with_prompt(hold) .with_prompt(hold)
.with_hold(hold) .with_hold(hold)
.with_description_font(&theme::TEXT_SUB_GREY)
.into_flow() .into_flow()
.and_then(LayoutObj::new_root) .and_then(LayoutObj::new_root)
.map(Into::into) .map(Into::into)

View File

@ -17,7 +17,7 @@ async def sign_message(
from trezor.crypto.curve import secp256k1 from trezor.crypto.curve import secp256k1
from trezor.enums import InputScriptType from trezor.enums import InputScriptType
from trezor.messages import MessageSignature from trezor.messages import MessageSignature
from trezor.ui.layouts import confirm_signverify from trezor.ui.layouts import confirm_signverify, confirm_new_contact
from apps.common.paths import address_n_to_str, validate_path from apps.common.paths import address_n_to_str, validate_path
from apps.common.signverify import decode_message, message_digest from apps.common.signverify import decode_message, message_digest
@ -40,14 +40,26 @@ async def sign_message(
address = get_address(script_type, coin, node) address = get_address(script_type, coin, node)
path = address_n_to_str(address_n) path = address_n_to_str(address_n)
account = address_n_to_name_or_unknown(coin, address_n, script_type) account = address_n_to_name_or_unknown(coin, address_n, script_type)
await confirm_signverify( message_decoded = decode_message(message)
decode_message(message), if "/" in message_decoded:
address_short(coin, address), # message will have format <label>/<npub>
verify=False, # hackathon simplification
account=account, await confirm_new_contact(
path=path, label=message_decoded,
chunkify=bool(msg.chunkify), contact_id=address,
) account=account,
path=path,
chunkify=bool(msg.chunkify),
)
else:
await confirm_signverify(
message_decoded,
address_short(coin, address),
verify=False,
account=account,
path=path,
chunkify=bool(msg.chunkify),
)
seckey = node.private_key() seckey = node.private_key()

View File

@ -148,6 +148,42 @@ def confirm_multisig_different_paths_warning() -> Awaitable[None]:
) )
async def confirm_new_contact(
label: str,
contact_id: str,
path: str | None = None,
account: str | None = None,
chunkify: bool = True,
) -> None:
info_items = []
if path:
info_items.append(("Path", path))
if account:
info_items.append(("Account", account))
await confirm_value(
title="New contact",
value=contact_id,
description="NPub",
br_name="confirm_new_contact",
value_text_mono=True,
info_items=info_items or None,
info_title=TR.buttons__more_info,
verb=TR.buttons__confirm,
chunkify=chunkify,
)
await confirm_value(
title="New contact",
value=label,
description="Contact label",
br_name="confirm_new_contact",
value_text_mono=False,
info_items=info_items or None,
info_title=TR.buttons__more_info,
hold=True,
chunkify=False,
)
def confirm_homescreen( def confirm_homescreen(
image: bytes, image: bytes,
) -> Awaitable[None]: ) -> Awaitable[None]: