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]
pull/2821/head
grdddj 1 year ago committed by Jiří Musil
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…
Cancel
Save