mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-12 09:28:10 +00:00
feat(contacts): new contact confirmation
This commit is contained in:
parent
951be5a1cd
commit
7c375bdc07
@ -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_prompt(hold)
|
||||
.with_hold(hold)
|
||||
.with_description_font(&theme::TEXT_SUB_GREY)
|
||||
.into_flow()
|
||||
.and_then(LayoutObj::new_root)
|
||||
.map(Into::into)
|
||||
|
@ -17,7 +17,7 @@ async def sign_message(
|
||||
from trezor.crypto.curve import secp256k1
|
||||
from trezor.enums import InputScriptType
|
||||
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.signverify import decode_message, message_digest
|
||||
@ -40,14 +40,26 @@ async def sign_message(
|
||||
address = get_address(script_type, coin, node)
|
||||
path = address_n_to_str(address_n)
|
||||
account = address_n_to_name_or_unknown(coin, address_n, script_type)
|
||||
await confirm_signverify(
|
||||
decode_message(message),
|
||||
address_short(coin, address),
|
||||
verify=False,
|
||||
account=account,
|
||||
path=path,
|
||||
chunkify=bool(msg.chunkify),
|
||||
)
|
||||
message_decoded = decode_message(message)
|
||||
if "/" in message_decoded:
|
||||
# message will have format <label>/<npub>
|
||||
# hackathon simplification
|
||||
await confirm_new_contact(
|
||||
label=message_decoded,
|
||||
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()
|
||||
|
||||
|
@ -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(
|
||||
image: bytes,
|
||||
) -> Awaitable[None]:
|
||||
|
Loading…
Reference in New Issue
Block a user