fix: correct container type for settings.wifs; proper button text UX with parentheses
What changed, and why it matters
This commit fixes two small issues in the Coldcard firmware. First, it changes the on-screen prompt when enabling a high-security 'HSM' policy to put the button name in parentheses, matching how the device normally displays button labels. Second, it corrects a bug in the code that manages saved private key imports (WIFs): the code was treating a list as if it were a dictionary, which could cause the wrong entry to be deleted or an error to be silently ignored. The commit also updates a test to expect the new prompt text.
Review whether the WIF list/dict mismatch could have led to deletion of the wrong imported key or stale settings state; consider adding a regression test for WIF deletion. The HSM prompt change is cosmetic and does not require security action.
Security signals we found
Container type mismatch between expected list and default dict in WIF deletion path
Silent fall-through after IndexError could mask inconsistent state
HSM policy approval prompt UX change only, no access-control change
Evidence from the diff
The patch modifies three files. In shared/hsm_ux.py, the HSM policy approval prompt is changed from ‘Press %s’ to ‘Press (%s)’ for consistent UX. In shared/wif.py, the WIFStore.delete method is fixed: it now retrieves settings.wifs as a list ([]) instead of a dict ({}), renames the local variable to avoid shadowing the menu item, and returns explicitly on IndexError rather than falling through to UX pop/update. In testing/test_hsm.py, the assertion is updated to expect ‘Press (’ and the character offset is changed from 6 to 7. The WIF container-type mismatch is the main functional bug; the rest is UI/test alignment.
Changed components
shared/wif.py: WIFStore.delete()shared/hsm_ux.py: ApproveHSMPolicy approval prompttesting/test_hsm.py: HSM approval prompt testInspect captured patch +8 / −7
diff --git a/shared/hsm_ux.py b/shared/hsm_ux.py
index 2a8b4a4..35e113c 100644
--- a/shared/hsm_ux.py
+++ b/shared/hsm_ux.py
@@ -59,7 +59,7 @@ class ApproveHSMPolicy(UserAuthorizedAction):
msg = '''Last chance. You are defining a new policy which \
allows the Coldcard to sign specific transactions without any further user approval.\n\n\
Policy hash:\n%s\n\n
-Press %s to save policy and enable HSM mode.''' % (self.policy.hash(), confirm_char)
+Press (%s) to save policy and enable HSM mode.''' % (self.policy.hash(), confirm_char)
ch = await ux_show_story(msg, title=self.title,
escape='x'+confirm_char, strict_escape=True)
diff --git a/shared/wif.py b/shared/wif.py
index 4e91bb5..cc1d2bb 100644
--- a/shared/wif.py
+++ b/shared/wif.py
@@ -224,16 +224,17 @@ class WIFStore(MenuSystem):
return
idx, pubkey = item.arg
- wifs = settings.get('wifs', {})
+ wifs = settings.get('wifs', [])
if not wifs: return
try:
- item = wifs[idx]
- assert item[0] == pubkey
+ entry = wifs[idx]
+ assert entry[0] == pubkey
del wifs[idx]
settings.set('wifs', wifs)
settings.save()
- except IndexError: pass
+ except IndexError:
+ return
the_ux.pop() # pop submenu
self.update_contents()
diff --git a/testing/test_hsm.py b/testing/test_hsm.py
index f5e99ca..0a4158c 100644
--- a/testing/test_hsm.py
+++ b/testing/test_hsm.py
@@ -425,8 +425,8 @@ def start_hsm(request, dev, hsm_reset, hsm_status, need_keypress, press_select):
assert 'Last chance' in body2
assert 'Policy hash:' in body2
ll = body2.split('\n')[-1]
- assert ll.startswith("Press ")
- ch = ll[6]
+ assert ll.startswith("Press (")
+ ch = ll[7]
need_keypress(ch)
time.sleep(.100)
Why this scored 32/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.