mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-15 09:50:57 +00:00
src/apps: use address_n as description to show_address/show_qr dialogs
This commit is contained in:
parent
90868702ba
commit
939a932219
@ -12,9 +12,10 @@ from apps.common import HARDENED
|
||||
from apps.common.confirm import confirm, require_confirm
|
||||
|
||||
|
||||
async def show_address(ctx, address: str, address_n: list, network: str = None):
|
||||
text = Text("Confirm address", ui.ICON_RECEIVE, icon_color=ui.GREEN)
|
||||
# TODO: print address_n via address_n_to_str(address_n)
|
||||
async def show_address(ctx, address: str, desc: str = None, network: str = None):
|
||||
text = Text(
|
||||
desc if desc else "Confirm address", ui.ICON_RECEIVE, icon_color=ui.GREEN
|
||||
)
|
||||
if network:
|
||||
text.normal("%s network" % network)
|
||||
text.mono(*split_address(address))
|
||||
@ -23,13 +24,15 @@ async def show_address(ctx, address: str, address_n: list, network: str = None):
|
||||
)
|
||||
|
||||
|
||||
async def show_qr(ctx, address: str):
|
||||
async def show_qr(ctx, address: str, desc: str = None):
|
||||
qr_x = const(120)
|
||||
qr_y = const(115)
|
||||
qr_coef = const(4)
|
||||
|
||||
qr = Qr(address, (qr_x, qr_y), qr_coef)
|
||||
text = Text("Confirm address", ui.ICON_RECEIVE, icon_color=ui.GREEN)
|
||||
text = Text(
|
||||
desc if desc else "Confirm address", ui.ICON_RECEIVE, icon_color=ui.GREEN
|
||||
)
|
||||
content = Container(qr, text)
|
||||
return await confirm(
|
||||
ctx,
|
||||
@ -58,4 +61,7 @@ def address_n_to_str(address_n: list) -> str:
|
||||
else:
|
||||
return str(i)
|
||||
|
||||
if not address_n:
|
||||
return "m"
|
||||
|
||||
return "m/" + "/".join([path_item(i) for i in address_n])
|
||||
|
@ -1,4 +1,4 @@
|
||||
from apps.common.layout import show_address, show_qr
|
||||
from apps.common.layout import address_n_to_str, show_address, show_qr
|
||||
from apps.ethereum import networks
|
||||
|
||||
|
||||
@ -22,11 +22,11 @@ async def get_address(ctx, msg):
|
||||
else:
|
||||
network = None
|
||||
hex_addr = _ethereum_address_hex(address, network)
|
||||
|
||||
desc = address_n_to_str(address_n)
|
||||
while True:
|
||||
if await show_address(ctx, hex_addr, address_n):
|
||||
if await show_address(ctx, hex_addr, desc=desc):
|
||||
break
|
||||
if await show_qr(ctx, hex_addr):
|
||||
if await show_qr(ctx, hex_addr, desc=desc):
|
||||
break
|
||||
|
||||
return EthereumAddress(address=address)
|
||||
|
@ -3,7 +3,7 @@ from trezor.messages.LiskAddress import LiskAddress
|
||||
from .helpers import LISK_CURVE, get_address_from_public_key
|
||||
|
||||
from apps.common import seed
|
||||
from apps.common.layout import show_address, show_qr
|
||||
from apps.common.layout import address_n_to_str, show_address, show_qr
|
||||
|
||||
|
||||
async def get_address(ctx, msg):
|
||||
@ -15,10 +15,11 @@ async def get_address(ctx, msg):
|
||||
address = get_address_from_public_key(pubkey)
|
||||
|
||||
if msg.show_display:
|
||||
desc = address_n_to_str(address_n)
|
||||
while True:
|
||||
if await show_address(ctx, address, address_n):
|
||||
if await show_address(ctx, address, desc=desc):
|
||||
break
|
||||
if await show_qr(ctx, address):
|
||||
if await show_qr(ctx, address, desc=desc):
|
||||
break
|
||||
|
||||
return LiskAddress(address=address)
|
||||
|
@ -1,6 +1,6 @@
|
||||
from trezor.messages.MoneroAddress import MoneroAddress
|
||||
|
||||
from apps.common.layout import show_address, show_qr
|
||||
from apps.common.layout import address_n_to_str, show_address, show_qr
|
||||
from apps.monero import misc
|
||||
|
||||
|
||||
@ -8,10 +8,11 @@ async def get_address(ctx, msg):
|
||||
creds = await misc.get_creds(ctx, msg.address_n, msg.network_type)
|
||||
|
||||
if msg.show_display:
|
||||
desc = address_n_to_str(msg.address_n)
|
||||
while True:
|
||||
if await show_address(ctx, creds.address.decode("ascii"), msg.address_n):
|
||||
if await show_address(ctx, creds.address.decode(), desc=desc):
|
||||
break
|
||||
if await show_qr(ctx, creds.address.decode("ascii")):
|
||||
if await show_qr(ctx, creds.address.decode(), desc=desc):
|
||||
break
|
||||
|
||||
return MoneroAddress(address=creds.address)
|
||||
|
@ -4,7 +4,7 @@ from .helpers import NEM_CURVE, get_network_str
|
||||
from .validators import validate_network
|
||||
|
||||
from apps.common import seed
|
||||
from apps.common.layout import show_address, show_qr
|
||||
from apps.common.layout import address_n_to_str, show_address, show_qr
|
||||
|
||||
|
||||
async def get_address(ctx, msg):
|
||||
@ -13,12 +13,13 @@ async def get_address(ctx, msg):
|
||||
address = node.nem_address(network)
|
||||
|
||||
if msg.show_display:
|
||||
desc = address_n_to_str(msg.address_n)
|
||||
while True:
|
||||
if await show_address(
|
||||
ctx, address, msg.address_n, network=get_network_str(network)
|
||||
ctx, address, desc=desc, network=get_network_str(network)
|
||||
):
|
||||
break
|
||||
if await show_qr(ctx, address.upper()):
|
||||
if await show_qr(ctx, address.upper(), desc=desc):
|
||||
break
|
||||
|
||||
return NEMAddress(address=address)
|
||||
|
@ -4,7 +4,7 @@ from trezor.messages.RippleGetAddress import RippleGetAddress
|
||||
from . import helpers
|
||||
|
||||
from apps.common import seed
|
||||
from apps.common.layout import show_address, show_qr
|
||||
from apps.common.layout import address_n_to_str, show_address, show_qr
|
||||
|
||||
|
||||
async def get_address(ctx, msg: RippleGetAddress):
|
||||
@ -13,10 +13,11 @@ async def get_address(ctx, msg: RippleGetAddress):
|
||||
address = helpers.address_from_public_key(pubkey)
|
||||
|
||||
if msg.show_display:
|
||||
desc = address_n_to_str(msg.address_n)
|
||||
while True:
|
||||
if await show_address(ctx, address, msg.address_n):
|
||||
if await show_address(ctx, address, desc=desc):
|
||||
break
|
||||
if await show_qr(ctx, address.upper()):
|
||||
if await show_qr(ctx, address.upper(), desc=desc):
|
||||
break
|
||||
|
||||
return RippleAddress(address=address)
|
||||
|
@ -2,7 +2,7 @@ from trezor.messages.StellarAddress import StellarAddress
|
||||
from trezor.messages.StellarGetAddress import StellarGetAddress
|
||||
|
||||
from apps.common import seed
|
||||
from apps.common.layout import show_address, show_qr
|
||||
from apps.common.layout import address_n_to_str, show_address, show_qr
|
||||
from apps.stellar import helpers
|
||||
|
||||
|
||||
@ -12,10 +12,11 @@ async def get_address(ctx, msg: StellarGetAddress):
|
||||
address = helpers.address_from_public_key(pubkey)
|
||||
|
||||
if msg.show_display:
|
||||
desc = address_n_to_str(msg.address_n)
|
||||
while True:
|
||||
if await show_address(ctx, address, msg.address_n):
|
||||
if await show_address(ctx, address, desc=desc):
|
||||
break
|
||||
if await show_qr(ctx, address.upper()):
|
||||
if await show_qr(ctx, address.upper(), desc=desc):
|
||||
break
|
||||
|
||||
return StellarAddress(address=address)
|
||||
|
@ -2,7 +2,7 @@ from trezor.crypto import hashlib
|
||||
from trezor.messages.TezosAddress import TezosAddress
|
||||
|
||||
from apps.common import seed
|
||||
from apps.common.layout import show_address, show_qr
|
||||
from apps.common.layout import address_n_to_str, show_address, show_qr
|
||||
from apps.tezos.helpers import (
|
||||
TEZOS_CURVE,
|
||||
TEZOS_ED25519_ADDRESS_PREFIX,
|
||||
@ -19,10 +19,11 @@ async def get_address(ctx, msg):
|
||||
address = base58_encode_check(pkh, prefix=TEZOS_ED25519_ADDRESS_PREFIX)
|
||||
|
||||
if msg.show_display:
|
||||
desc = address_n_to_str(msg.address_n)
|
||||
while True:
|
||||
if await show_address(ctx, address, address_n):
|
||||
if await show_address(ctx, address, desc=desc):
|
||||
break
|
||||
if await show_qr(ctx, address):
|
||||
if await show_qr(ctx, address, desc=desc):
|
||||
break
|
||||
|
||||
return TezosAddress(address=address)
|
||||
|
@ -2,7 +2,7 @@ from trezor.messages import InputScriptType
|
||||
from trezor.messages.Address import Address
|
||||
|
||||
from apps.common import coins, seed
|
||||
from apps.common.layout import show_address, show_qr
|
||||
from apps.common.layout import address_n_to_str, show_address, show_qr
|
||||
from apps.wallet.sign_tx import addresses
|
||||
|
||||
|
||||
@ -15,14 +15,19 @@ async def get_address(ctx, msg):
|
||||
address_short = addresses.address_short(coin, address)
|
||||
|
||||
if msg.show_display:
|
||||
if msg.multisig:
|
||||
desc = "Multisig %d of %d" % (msg.multisig.m, len(msg.multisig.pubkeys))
|
||||
else:
|
||||
desc = address_n_to_str(msg.address_n)
|
||||
while True:
|
||||
if await show_address(ctx, address_short, msg.address_n):
|
||||
if await show_address(ctx, address_short, desc=desc):
|
||||
break
|
||||
if await show_qr(
|
||||
ctx,
|
||||
address.upper()
|
||||
if msg.script_type == InputScriptType.SPENDWITNESS
|
||||
else address,
|
||||
desc=desc,
|
||||
):
|
||||
break
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user