From c493677595f537e75a857fddd77c1a7dfe0d5634 Mon Sep 17 00:00:00 2001 From: "Peter D. Gray" Date: Fri, 22 Aug 2025 10:49:11 -0400 Subject: [PATCH] word entry --- shared/actions.py | 1 + shared/ccc.py | 6 ++---- shared/seed.py | 36 ++++++++++++++++++++---------------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/shared/actions.py b/shared/actions.py index 1f2e3a01..d45d9600 100644 --- a/shared/actions.py +++ b/shared/actions.py @@ -880,6 +880,7 @@ async def start_login_sequence(): if sp_unlock and sssp_spending_policy('words'): # challenge them also for first and last seed word! (will reboot on fail) await sssp_word_challenge() + dis.fullscreen("Startup...") if sp_unlock: # Disable spending policy going forward; user has to re-enable. diff --git a/shared/ccc.py b/shared/ccc.py index cf9f4128..22225653 100644 --- a/shared/ccc.py +++ b/shared/ccc.py @@ -1129,7 +1129,6 @@ async def sssp_word_challenge(*a): want_words = words[:1] + words[-1:] assert len(want_words) == 2 - got_words = [] for retry in range(2): if version.has_qwerty: # see special rendering code for this case in ux_q1.py:ux_draw_words(num_words=2) @@ -1137,18 +1136,17 @@ async def sssp_word_challenge(*a): got_words = await seed_word_entry('First and Last Seed Words', 2, has_checksum=False) else: from seed import WordNestMenu - got_words = await WordNestMenu.login_sequence_word_check() + got_words = await WordNestMenu.get_n_words(2) if got_words == want_words: # success - done return await ux_show_story("Sorry, those words are incorrect.") - got_words = [] # they failed; log them out ... they can just try login again from actions import login_now - login_now() + await login_now() # NOT-REACHED diff --git a/shared/seed.py b/shared/seed.py index 1a8da8bb..c266cbc2 100644 --- a/shared/seed.py +++ b/shared/seed.py @@ -171,26 +171,30 @@ class WordNestMenu(MenuSystem): super(WordNestMenu, self).__init__(items) @classmethod - async def menu_done_cbf(cls, a, b, c): - if c.label[-1] == '-': - lc = c.label[0:-1] - else: - lc = "" - cls.words.append(c.label) - if len(cls.words) >= 2: - from glob import numpad - numpad.abort_ux() - return + async def get_n_words(cls, nwords): + # Just block until N words are provided. May only work before menus start? + from glob import numpad - m = cls(prefix=lc, menu_cbf=cls.menu_done_cbf) - the_ux.push(m) - await m.interact() + async def menu_done_cbf(menu, b, c): + # duplicates some of the logic of next_menu + if c.label[-1] == '-': + lc = c.label[0:-1] + else: + lc = "" + cls.words.append(c.label) + if len(cls.words) >= nwords: + numpad.abort_ux() + return + + m = cls(prefix=lc, menu_cbf=menu_done_cbf) + the_ux.push(m) + await m.interact() + + m = cls(num_words=nwords, menu_cbf=menu_done_cbf, has_checksum=False) - @classmethod - async def login_sequence_word_check(cls): - m = cls(num_words=2, menu_cbf=WordNestMenu.menu_done_cbf) the_ux.push(m) await the_ux.interact() + return cls.words @staticmethod