show ms address qr is msas=1

This commit is contained in:
scgbckbone 2025-02-04 16:31:14 +01:00 committed by doc-hex
parent cc7097b4f7
commit 38c92ef0c1
3 changed files with 32 additions and 13 deletions

View File

@ -286,6 +286,7 @@ Press (3) if you really understand and accept these risks.
from wallet import MAX_BIP32_IDX
start = self.start
allow_qr = (not ms_wallet) or settings.get("msas", 0)
def make_msg(change=0):
# Build message and CTA about export, plus the actual addresses.
@ -332,9 +333,11 @@ Press (3) if you really understand and accept these risks.
# export options
k0 = 'to show change addresses' if allow_change and change == 0 else None
export_msg, escape = export_prompt_builder('address summary file',
no_qr=bool(ms_wallet), key0=k0,
force_prompt=True)
export_msg, escape = export_prompt_builder(
'address summary file',
no_qr=not allow_qr,
key0=k0, force_prompt=True
)
if version.has_qwerty:
escape += KEY_LEFT+KEY_RIGHT+KEY_HOME+KEY_PAGE_UP+KEY_PAGE_DOWN
else:
@ -375,14 +378,11 @@ Press (3) if you really understand and accept these risks.
# continue on same screen in case they want to write to multiple cards
elif choice == KEY_QR:
# switch into a mode that shows them as QR codes
if ms_wallet:
# requires not multisig
continue
from ux import show_qr_codes
is_alnum = bool(addr_fmt & (AFC_BECH32 | AFC_BECH32M))
await show_qr_codes(addrs, is_alnum, start)
if allow_qr:
addr_fmt = addr_fmt or ms_wallet.addr_fmt
is_alnum = bool(addr_fmt & (AFC_BECH32 | AFC_BECH32M))
await show_qr_codes(addrs, is_alnum, start)
continue

View File

@ -2,7 +2,7 @@
#
# Test the address explorer.
#
# Only single-sig here. Multisig cases are elsewhere.
# Only single-sig here. Multisig cases are in test_multisig.py.
#
import pytest, time, io, csv, bech32
from ckcc_protocol.constants import *

View File

@ -2159,7 +2159,8 @@ def test_danger_warning(request, descriptor, clear_ms, import_ms_wallet, cap_sto
def test_ms_addr_explorer(change, M_N, addr_fmt, start_idx, clear_ms, cap_menu,
need_keypress, goto_home, pick_menu_item, cap_story,
import_ms_wallet, make_multisig, settings_set,
enter_number, set_addr_exp_start_idx, desc, msas):
enter_number, set_addr_exp_start_idx, desc, msas,
cap_screen_qr, press_cancel, press_right):
clear_ms()
M, N = M_N
wal_name = f"ax{M}-{N}-{addr_fmt}"
@ -2232,6 +2233,22 @@ def test_ms_addr_explorer(change, M_N, addr_fmt, start_idx, clear_ms, cap_menu,
else:
assert len(maps) == (MAX_BIP32_IDX - start_idx) + 1
if msas:
need_keypress(KEY_QR)
qr_addrs = []
for i in range(10):
addr_qr = cap_screen_qr().decode()
if addr_fmt == AF_P2WSH:
# segwit addresses are case insensitive
addr_qr = addr_qr.lower()
qr_addrs.append(addr_qr)
press_right()
time.sleep(.2)
press_cancel()
else:
assert "show QR code" not in story
c = 0
for idx, (subpath, addr) in enumerate(maps, start=start_idx):
chng_idx = 1 if change else 0
path_mapper = lambda co_idx: str_to_path(derivs[co_idx]) + [chng_idx, idx]
@ -2243,12 +2260,14 @@ def test_ms_addr_explorer(change, M_N, addr_fmt, start_idx, clear_ms, cap_menu,
#print('../0/%s => \n %s' % (idx, B2A(script)))
if msas:
assert addr == expect
assert addr == expect == qr_addrs[c]
else:
start, end = addr.strip().split('___')
assert expect.startswith(start)
assert expect.endswith(end)
c += 1
def test_dup_ms_wallet_bug(goto_home, pick_menu_item, press_select, import_ms_wallet,
clear_ms, is_q1):