fix WIF store ownership showing QR address

This commit is contained in:
scgbckbone 2026-03-05 15:44:58 +01:00 committed by doc-hex
parent 398911c48a
commit 05d792cb79
2 changed files with 15 additions and 5 deletions

View File

@ -341,11 +341,12 @@ class OwnershipCache:
# nothing found among singlesig & registered multisig wallets
# check WIF store (single sig only)
if addr_fmt not in [AF_P2WSH]:
dis.fullscreen("WIF Store...")
from wif import iter_wif_store_addresses
target_af = AF_P2WPKH_P2SH if addr_fmt == AF_P2SH else addr_fmt
for i, store_addr in iter_wif_store_addresses(ch, target_af):
if store_addr == addr:
return False, "wif", i+1
return False, ("wif", target_af), i+1
raise UnknownAddressExplained('Searched %d candidate addresses in %d wallet(s)'
' without finding a match.' % (c, len(matches)))
@ -364,11 +365,13 @@ class OwnershipCache:
msg = show_single_address(addr)
esc = ""
if wallet == "wif":
if isinstance(wallet, tuple) and (wallet[0] == "wif"):
msg += '\n\nFound in WIF store at index %d' % subpath
addr_fmt = wallet[1]
else:
msg += '\n\nFound in wallet:\n' + wallet.name
msg += '\n\nDerivation path:\n'
addr_fmt = wallet.addr_fmt
if hasattr(wallet, "render_path"):
sp = wallet.render_path(*subpath)
msg += sp
@ -394,12 +397,12 @@ class OwnershipCache:
if ch in ("1"+KEY_QR):
await show_qr_code(
addr,
is_alnum=(wallet.addr_fmt & (AFC_BECH32 | AFC_BECH32M)),
is_alnum=(addr_fmt & (AFC_BECH32 | AFC_BECH32M)),
msg=addr, is_addrs=True
)
elif not is_complex and (ch == "0"): # only singlesig
from msgsign import sign_with_own_address
await sign_with_own_address(sp, wallet.addr_fmt)
await sign_with_own_address(sp, addr_fmt)
else:
break

View File

@ -726,7 +726,7 @@ def test_named_wallet_search(wname, valid, method, clear_miniscript, import_ms_w
@pytest.mark.parametrize("idx", [1, 3])
def test_wif_store(addr_fmt, idx, is_q1, goto_home, pick_menu_item, scan_a_qr, cap_story, need_keypress,
src_root_dir, sim_root_dir, nfc_write, settings_remove, import_wif_to_store,
load_shared_mod):
load_shared_mod, cap_screen_qr, press_cancel):
settings_remove("wifs")
@ -774,5 +774,12 @@ def test_wif_store(addr_fmt, idx, is_q1, goto_home, pick_menu_item, scan_a_qr, c
title, story = cap_story()
assert addr == addr_from_display_format(story.split("\n\n")[0])
assert f"Found in WIF store at index {idx}" in story
need_keypress(KEY_QR if is_q1 else '1')
addr_qr = cap_screen_qr().decode()
if addr_fmt == "p2wpkh":
addr_qr = addr_qr.lower()
assert addr == addr_qr
press_cancel()
# EOF