From e119e8de965c8d651939fd42841a4ec25e88e89a Mon Sep 17 00:00:00 2001 From: Tomas Susanka Date: Wed, 14 Aug 2019 11:16:12 +0200 Subject: [PATCH] core/slip39: fix UI for 33 words closes #395 --- core/src/apps/management/common/layout.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core/src/apps/management/common/layout.py b/core/src/apps/management/common/layout.py index e64040fb7..4668e01e1 100644 --- a/core/src/apps/management/common/layout.py +++ b/core/src/apps/management/common/layout.py @@ -409,8 +409,17 @@ async def _slip39_show_share_words(ctx, share_index, share_words): def _slip39_split_share_into_pages(share_words): share = list(enumerate(share_words)) # we need to keep track of the word indices first = share[:2] # two words on the first page - middle = share[2:-2] - last = share[-2:] # two words on the last page + length = len(share_words) + if length == 20: + middle = share[2:-2] + last = share[-2:] # two words on the last page + elif length == 33: + middle = share[2:] + last = [] # no words at the last page, because it does not add up + else: + # Invalid number of shares. SLIP-39 allows 20 or 33 words. + raise RuntimeError + chunks = utils.chunks(middle, 4) # 4 words on the middle pages return first, list(chunks), last