mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 12:28:09 +00:00
common: show pubkey moved to common
This commit is contained in:
parent
0acd9d8918
commit
e13a3a70c8
@ -1,4 +1,5 @@
|
|||||||
from micropython import const
|
from micropython import const
|
||||||
|
from ubinascii import hexlify
|
||||||
|
|
||||||
from trezor import ui
|
from trezor import ui
|
||||||
from trezor.messages import ButtonRequestType
|
from trezor.messages import ButtonRequestType
|
||||||
@ -8,6 +9,7 @@ from trezor.ui.text import Text
|
|||||||
from trezor.utils import chunks
|
from trezor.utils import chunks
|
||||||
|
|
||||||
from apps.common.confirm import confirm
|
from apps.common.confirm import confirm
|
||||||
|
from apps.common.confirm import require_confirm
|
||||||
|
|
||||||
|
|
||||||
async def show_address(ctx, address: str):
|
async def show_address(ctx, address: str):
|
||||||
@ -38,3 +40,10 @@ async def show_qr(ctx, address: str):
|
|||||||
|
|
||||||
def split_address(address: str):
|
def split_address(address: str):
|
||||||
return chunks(address, 17)
|
return chunks(address, 17)
|
||||||
|
|
||||||
|
|
||||||
|
async def show_pubkey(ctx, pubkey: bytes):
|
||||||
|
lines = chunks(hexlify(pubkey).decode(), 18)
|
||||||
|
text = Text("Confirm public key", ui.ICON_RECEIVE, icon_color=ui.GREEN)
|
||||||
|
text.mono(*lines)
|
||||||
|
return await require_confirm(ctx, text, code=ButtonRequestType.PublicKey)
|
||||||
|
@ -2,8 +2,7 @@ from trezor.messages.LiskPublicKey import LiskPublicKey
|
|||||||
|
|
||||||
from .helpers import LISK_CURVE
|
from .helpers import LISK_CURVE
|
||||||
|
|
||||||
from apps.common import seed
|
from apps.common import seed, display_address
|
||||||
from apps.wallet.get_public_key import _show_pubkey
|
|
||||||
|
|
||||||
|
|
||||||
async def lisk_get_public_key(ctx, msg):
|
async def lisk_get_public_key(ctx, msg):
|
||||||
@ -14,6 +13,6 @@ async def lisk_get_public_key(ctx, msg):
|
|||||||
pubkey = pubkey[1:] # skip ed25519 pubkey marker
|
pubkey = pubkey[1:] # skip ed25519 pubkey marker
|
||||||
|
|
||||||
if msg.show_display:
|
if msg.show_display:
|
||||||
await _show_pubkey(ctx, pubkey)
|
await display_address.show_pubkey(ctx, pubkey)
|
||||||
|
|
||||||
return LiskPublicKey(public_key=pubkey)
|
return LiskPublicKey(public_key=pubkey)
|
||||||
|
@ -6,7 +6,7 @@ from trezor.utils import chunks
|
|||||||
from .helpers import get_vote_tx_text
|
from .helpers import get_vote_tx_text
|
||||||
|
|
||||||
from apps.common.confirm import require_confirm, require_hold_to_confirm
|
from apps.common.confirm import require_confirm, require_hold_to_confirm
|
||||||
from apps.wallet.get_public_key import _show_pubkey
|
from apps.common.display_address import show_pubkey
|
||||||
|
|
||||||
|
|
||||||
async def require_confirm_tx(ctx, to, value):
|
async def require_confirm_tx(ctx, to, value):
|
||||||
@ -32,7 +32,7 @@ async def require_confirm_vote_tx(ctx, votes):
|
|||||||
|
|
||||||
|
|
||||||
async def require_confirm_public_key(ctx, public_key):
|
async def require_confirm_public_key(ctx, public_key):
|
||||||
return await _show_pubkey(ctx, public_key)
|
return await show_pubkey(ctx, public_key)
|
||||||
|
|
||||||
|
|
||||||
async def require_confirm_multisig(ctx, multisignature):
|
async def require_confirm_multisig(ctx, multisignature):
|
||||||
|
@ -1,14 +1,7 @@
|
|||||||
from ubinascii import hexlify
|
|
||||||
|
|
||||||
from trezor import ui
|
|
||||||
from trezor.messages import ButtonRequestType
|
|
||||||
from trezor.messages.HDNodeType import HDNodeType
|
from trezor.messages.HDNodeType import HDNodeType
|
||||||
from trezor.messages.PublicKey import PublicKey
|
from trezor.messages.PublicKey import PublicKey
|
||||||
from trezor.ui.text import Text
|
|
||||||
from trezor.utils import chunks
|
|
||||||
|
|
||||||
from apps.common import coins, seed
|
from apps.common import coins, seed, display_address
|
||||||
from apps.common.confirm import require_confirm
|
|
||||||
|
|
||||||
|
|
||||||
async def get_public_key(ctx, msg):
|
async def get_public_key(ctx, msg):
|
||||||
@ -33,13 +26,6 @@ async def get_public_key(ctx, msg):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if msg.show_display:
|
if msg.show_display:
|
||||||
await _show_pubkey(ctx, pubkey)
|
await display_address.show_pubkey(ctx, pubkey)
|
||||||
|
|
||||||
return PublicKey(node=node_type, xpub=node_xpub)
|
return PublicKey(node=node_type, xpub=node_xpub)
|
||||||
|
|
||||||
|
|
||||||
async def _show_pubkey(ctx, pubkey: bytes):
|
|
||||||
lines = chunks(hexlify(pubkey).decode(), 18)
|
|
||||||
text = Text("Confirm public key", ui.ICON_RECEIVE, icon_color=ui.GREEN)
|
|
||||||
text.mono(*lines)
|
|
||||||
return await require_confirm(ctx, text, code=ButtonRequestType.PublicKey)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user