mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 06:18:07 +00:00
fix(core): remove the possibility of AssertionError in select_word
In case there are less than three unique word to choose from, duplicating the last word to make the length of 3. [no changelog]
This commit is contained in:
parent
9d7342e0aa
commit
aa283a8392
@ -90,7 +90,6 @@ async def select_word(
|
||||
count: int,
|
||||
group_index: int | None = None,
|
||||
) -> str:
|
||||
assert len(words) == 3
|
||||
if share_index is None:
|
||||
title: str = "CHECK SEED"
|
||||
elif group_index is None:
|
||||
@ -98,6 +97,13 @@ async def select_word(
|
||||
else:
|
||||
title = f"CHECK G{group_index + 1} - SHARE {share_index + 1}"
|
||||
|
||||
# It may happen (with a very low probability)
|
||||
# that there will be less than three unique words to choose from.
|
||||
# In that case, duplicating the last word to make it three.
|
||||
words = list(words)
|
||||
while len(words) < 3:
|
||||
words.append(words[-1])
|
||||
|
||||
result = await ctx.wait(
|
||||
RustLayout(
|
||||
trezorui2.select_word(
|
||||
|
Loading…
Reference in New Issue
Block a user