diff --git a/src/apps/ethereum/get_address.py b/src/apps/ethereum/get_address.py index 5b2475fb84..a5265ba5ed 100644 --- a/src/apps/ethereum/get_address.py +++ b/src/apps/ethereum/get_address.py @@ -1,4 +1,4 @@ -from trezor import ui +from apps.wallet.get_address import _show_address, _show_qr async def ethereum_get_address(ctx, msg): @@ -16,31 +16,16 @@ async def ethereum_get_address(ctx, msg): address = sha3_256(public_key[1:]).digest(True)[12:] # Keccak if msg.show_display: - await _show_address(ctx, address) + hex_addr = _ethereum_address_hex(address) + while True: + if await _show_address(ctx, hex_addr): + break + if await _show_qr(ctx, hex_addr): + break return EthereumAddress(address=address) -async def _show_address(ctx, address): - from trezor.messages.ButtonRequestType import Address - from trezor.ui.text import Text - from trezor.ui.qr import Qr - from trezor.ui.container import Container - from ..common.confirm import require_confirm - - address = _ethereum_address_hex(address) - lines = _split_address(address) - content = Container( - Qr(address, (120, 135), 3), - Text('Confirm address', ui.ICON_DEFAULT, ui.MONO, *lines)) - await require_confirm(ctx, content, code=Address) - - -def _split_address(address): - from trezor.utils import chunks - return chunks(address, 21) - - def _ethereum_address_hex(address): from ubinascii import hexlify from trezor.crypto.hashlib import sha3_256 diff --git a/src/apps/wallet/get_address.py b/src/apps/wallet/get_address.py index e185347a68..31c97587d2 100644 --- a/src/apps/wallet/get_address.py +++ b/src/apps/wallet/get_address.py @@ -22,7 +22,7 @@ async def get_address(ctx, msg): while True: if await _show_address(ctx, address): break - if await _show_qr(ctx, address, msg.script_type): + if await _show_qr(ctx, address.upper() if msg.script_type == InputScriptType.SPENDWITNESS else address): break return Address(address=address) @@ -39,14 +39,11 @@ async def _show_address(ctx, address: str): cancel_style=ui.BTN_KEY) -async def _show_qr(ctx, address: str, script_type: int): +async def _show_qr(ctx, address: str): qr_x = const(120) qr_y = const(115) qr_coef = const(4) - if script_type == InputScriptType.SPENDWITNESS: - address = address.upper() - content = Container( Qr(address, (qr_x, qr_y), qr_coef), Text('Confirm address', ui.ICON_RECEIVE, ui.MONO, icon_color=ui.GREEN))