async def _slip39_show_share_words(ctx, share_index, share_words): first, chunks, last = _slip39_split_share_into_pages(share_words) if share_index is None: header_title = "Recovery seed" else: header_title = "Recovery share #%s" % (share_index + 1) header_icon = ui.ICON_RESET pages = [] # ui page components shares_words_check = [] # check we display correct data # first page text = Text(header_title, header_icon) text.bold("Write down these") text.bold("%s words:" % len(share_words)) text.br_half() for index, word in first: text.mono("%s. %s" % (index + 1, word)) shares_words_check.append(word) pages.append(text) # middle pages for chunk in chunks: text = Text(header_title, header_icon) for index, word in chunk: text.mono("%s. %s" % (index + 1, word)) shares_words_check.append(word) pages.append(text) # last page text = Text(header_title, header_icon) for index, word in last: text.mono("%s. %s" % (index + 1, word)) shares_words_check.append(word) text.br_half() text.bold("I confirm that I wrote") text.bold("down all %s words." % len(share_words)) pages.append(text) # pagination paginated = Paginated(pages) if __debug__: word_pages = [first] + chunks + [last] def export_displayed_words(): # export currently displayed mnemonic words into debuglink debug.reset_current_words = [ w for _, w in word_pages[paginated.page] ] paginated.on_change = export_displayed_words export_displayed_words() # make sure we display correct data utils.ensure(share_words == shares_words_check) # confirm the share await hold_to_confirm(ctx, paginated) # TODO: customize the loader here
async def _bip39_show_mnemonic(ctx, words: list): # split mnemonic words into pages PER_PAGE = const(4) words = list(enumerate(words)) words = list(utils.chunks(words, PER_PAGE)) # display the pages, with a confirmation dialog on the last one pages = [_get_mnemonic_page(page) for page in words] paginated = Paginated(pages) if __debug__: def export_displayed_words(): # export currently displayed mnemonic words into debuglink debug.reset_current_words = [w for _, w in words[paginated.page]] paginated.on_change = export_displayed_words export_displayed_words() await hold_to_confirm(ctx, paginated, ButtonRequestType.ResetDevice)
async def _show_share_words(ctx, share_words, share_index=None, group_index=None): first, chunks, last = _split_share_into_pages(share_words) if share_index is None: header_title = "Recovery seed" elif group_index is None: header_title = "Recovery share #%s" % (share_index + 1) else: header_title = "Group %s - Share %s" % ((group_index + 1), (share_index + 1)) header_icon = ui.ICON_RESET pages = [] # ui page components shares_words_check = [] # check we display correct data # first page text = Text(header_title, header_icon) text.bold("Write down these") text.bold("%s words:" % len(share_words)) text.br_half() for index, word in first: text.mono("%s. %s" % (index + 1, word)) shares_words_check.append(word) pages.append(text) # middle pages for chunk in chunks: text = Text(header_title, header_icon) for index, word in chunk: text.mono("%s. %s" % (index + 1, word)) shares_words_check.append(word) pages.append(text) # last page text = Text(header_title, header_icon) for index, word in last: text.mono("%s. %s" % (index + 1, word)) shares_words_check.append(word) text.br_half() text.bold("I wrote down all %s" % len(share_words)) text.bold("words in order.") pages.append(text) # pagination paginated = Paginated(pages) if __debug__: word_pages = [first] + chunks + [last] def export_displayed_words(): # export currently displayed mnemonic words into debuglink words = [w for _, w in word_pages[paginated.page]] debug.reset_current_words.publish(words) paginated.on_change = export_displayed_words export_displayed_words() # make sure we display correct data utils.ensure(share_words == shares_words_check) # confirm the share await hold_to_confirm(ctx, paginated, ButtonRequestType.ResetDevice)