From b9486c0b33ca1ec40c90c0f698132658d9610720 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Tue, 18 Feb 2020 22:39:55 +0000 Subject: [PATCH] core: show yours/others in get_address for multisig --- core/src/apps/wallet/get_address.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/apps/wallet/get_address.py b/core/src/apps/wallet/get_address.py index 85d822e499..c6c13f40e8 100644 --- a/core/src/apps/wallet/get_address.py +++ b/core/src/apps/wallet/get_address.py @@ -6,6 +6,7 @@ from apps.common import coins from apps.common.layout import address_n_to_str, show_address, show_qr, show_xpub from apps.common.paths import validate_path from apps.wallet.sign_tx import addresses +from apps.wallet.sign_tx.multisig import multisig_pubkey_index if False: from typing import List @@ -15,7 +16,7 @@ if False: async def show_xpubs( - ctx: wire.Context, coin: CoinInfo, pubnodes: List[HDNodeType] + ctx: wire.Context, coin: CoinInfo, pubnodes: List[HDNodeType], multisig_index: int ) -> bool: for i, pubnode in enumerate(pubnodes): cancel = "Next" if i < len(pubnodes) - 1 else "Address" @@ -28,7 +29,9 @@ async def show_xpubs( curve_name=coin.curve_name, ) xpub = node.serialize_public(coin.xpub_magic) - if await show_xpub(ctx, xpub, desc="XPUB #%d" % (i + 1), cancel=cancel): + desc = "XPUB #%d" % (i + 1) + desc += " (yours)" if i == multisig_index else " (others)" + if await show_xpub(ctx, xpub, desc=desc, cancel=cancel): return True return False @@ -63,13 +66,14 @@ async def get_address(ctx, msg, keychain): pubnodes = msg.multisig.nodes else: pubnodes = [hd.node for hd in msg.multisig.pubkeys] + multisig_index = multisig_pubkey_index(msg.multisig, node.public_key()) desc = "Multisig %d of %d" % (msg.multisig.m, len(pubnodes)) while True: if await show_address(ctx, address_short, desc=desc): break if await show_qr(ctx, address_qr, desc=desc, cancel="XPUBs"): break - if await show_xpubs(ctx, coin, pubnodes): + if await show_xpubs(ctx, coin, pubnodes, multisig_index): break else: desc = address_n_to_str(msg.address_n)