1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-07-07 07:12:34 +00:00
trezor-firmware/core/src/apps/binance/get_public_key.py
grdddj 9fc5bb546b style(core): full pyright-based type-checking
Changes many fields to required -- as far as we were able to figure out,
signing would fail if these fields aren't provided anyway, so this
should not pose a compatibility problem.

Co-authored-by: matejcik <ja@matejcik.cz>
2022-01-07 21:41:17 +01:00

26 lines
718 B
Python

from typing import TYPE_CHECKING
from ubinascii import hexlify
from trezor.messages import BinanceGetPublicKey, BinancePublicKey
from trezor.ui.layouts import show_pubkey
from apps.common import paths
from apps.common.keychain import Keychain, auto_keychain
if TYPE_CHECKING:
from trezor.wire import Context
@auto_keychain(__name__)
async def get_public_key(
ctx: Context, msg: BinanceGetPublicKey, keychain: Keychain
) -> BinancePublicKey:
await paths.validate_path(ctx, keychain, msg.address_n)
node = keychain.derive(msg.address_n)
pubkey = node.public_key()
if msg.show_display:
await show_pubkey(ctx, hexlify(pubkey).decode())
return BinancePublicKey(public_key=pubkey)