1010from trezor .lvglui .i18n import gettext as _ , keys as i18n_keys
1111from trezor .messages import Success
1212from trezor .ui .layouts import show_onekey_app_guide , show_popup , show_success
13+ from trezor .ui .layouts .lvgl .recovery import request_word
1314
1415from apps .base import set_homescreen
1516from apps .common import mnemonic
@@ -104,24 +105,26 @@ async def _continue_recovery_process(
104105 await _request_share_first_screen (ctx , word_count )
105106
106107 secret = None
108+ words = None
107109 while secret is None :
108- if is_first_step :
109- # If we are starting recovery, ask for word count first...
110- if not word_count :
111- word_count = await _request_word_count (ctx , dry_run )
112- # ...and only then show the starting screen with word count.
113- await _request_share_first_screen (ctx , word_count )
114- assert word_count is not None
115-
116- # ask for mnemonic words one by one
117- try :
118- words = await layout .request_mnemonic (ctx , word_count , backup_type )
119- except wire .ActionCancelled :
120- continue
121-
122- # if they were invalid or some checks failed we continue and request them again
123110 if not words :
124- continue
111+ if is_first_step :
112+ # If we are starting recovery, ask for word count first...
113+ if not word_count :
114+ word_count = await _request_word_count (ctx , dry_run )
115+ # ...and only then show the starting screen with word count.
116+ await _request_share_first_screen (ctx , word_count )
117+ assert word_count is not None
118+
119+ # ask for mnemonic words one by one
120+ try :
121+ words = await layout .request_mnemonic (ctx , word_count , backup_type )
122+ except wire .ActionCancelled :
123+ continue
124+
125+ # if they were invalid or some checks failed we continue and request them again
126+ if not words :
127+ continue
125128
126129 try :
127130 secret , backup_type = await _process_words (ctx , words )
@@ -130,7 +133,27 @@ async def _continue_recovery_process(
130133 # that the first step is complete.
131134 is_first_step = False
132135 except MnemonicError :
133- await layout .show_invalid_mnemonic (ctx , word_count )
136+ words_list = words .split (" " )
137+ while True :
138+ result = await layout .show_invalid_mnemonic (ctx , words_list )
139+ if result is not None :
140+ assert word_count is not None
141+ try :
142+ word = await request_word (
143+ ctx ,
144+ result ,
145+ word_count ,
146+ is_slip39 = backup_types .is_slip39_word_count (word_count ),
147+ )
148+ except wire .ActionCancelled :
149+ continue
150+ else :
151+ words_list [result ] = word
152+ words = " " .join (words_list )
153+ break
154+ else :
155+ words = None
156+ break
134157
135158 assert backup_type is not None
136159 if dry_run :
0 commit comments