mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
core: show yours/others in get_address for multisig
This commit is contained in:
parent
b5446bd125
commit
b9486c0b33
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user