mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-18 03:10:58 +00:00
src/apps/wallet: finish GetPublicKey UI
This commit is contained in:
parent
eed57a6c44
commit
1b8217ca66
@ -1,12 +1,22 @@
|
||||
from trezor.messages.HDNodeType import HDNodeType
|
||||
from trezor.messages.PublicKey import PublicKey
|
||||
from trezor import ui
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.ui.text import Text
|
||||
from trezor.utils import chunks
|
||||
from apps.common import coins, seed
|
||||
from apps.common.confirm import require_confirm
|
||||
from ubinascii import hexlify
|
||||
|
||||
|
||||
async def get_public_key(ctx, msg):
|
||||
coin_name = msg.coin_name or 'Bitcoin'
|
||||
|
||||
node = await seed.derive_node(ctx, msg.address_n)
|
||||
curve_name = msg.ecdsa_curve_name
|
||||
if not curve_name:
|
||||
node = await seed.derive_node(ctx, msg.address_n)
|
||||
else:
|
||||
node = await seed.derive_node(ctx, msg.address_n, curve_name=curve_name)
|
||||
coin = coins.by_name(coin_name)
|
||||
|
||||
node_xpub = node.serialize_public(coin.xpub_magic)
|
||||
@ -16,4 +26,17 @@ async def get_public_key(ctx, msg):
|
||||
fingerprint=node.fingerprint(),
|
||||
chain_code=node.chain_code(),
|
||||
public_key=node.public_key())
|
||||
|
||||
if msg.show_display:
|
||||
await _show_pubkey(ctx, node.public_key())
|
||||
|
||||
return PublicKey(node=node_type, xpub=node_xpub)
|
||||
|
||||
|
||||
async def _show_pubkey(ctx, pubkey: bytes):
|
||||
lines = chunks(hexlify(pubkey).decode(), 18)
|
||||
content = Text('Confirm public key', ui.ICON_RECEIVE, ui.MONO, *lines, icon_color=ui.GREEN)
|
||||
return await require_confirm(
|
||||
ctx,
|
||||
content,
|
||||
code=ButtonRequestType.PublicKey)
|
||||
|
Loading…
Reference in New Issue
Block a user