コード例 #1
0
async def check_mnemonic(ctx, mnemonic: str) -> bool:
    words = mnemonic.split()
    index = random.uniform(len(words) // 2)  # first half
    result = await MnemonicKeyboard('Type the %s word:' % format_ordinal(index + 1))
    if result != words[index]:
        return False
    index = len(words) // 2 + random.uniform(len(words) // 2)  # second half
    result = await MnemonicKeyboard('Type the %s word:' % format_ordinal(index + 1))
    return result == words[index]
コード例 #2
0
async def check_word(ctx, words: list, index: int):
    if __debug__:
        debug.reset_word_index = index

    keyboard = MnemonicKeyboard("Type the %s word:" % format_ordinal(index + 1))
    result = await ctx.wait(keyboard)
    return result == words[index]
コード例 #3
0
async def request_mnemonic(ctx, count: int, slip39: bool) -> str:
    await ctx.call(ButtonRequest(code=ButtonRequestType.MnemonicInput), ButtonAck)

    words = []
    for i in range(count):
        if slip39:
            keyboard = Slip39Keyboard("Type the %s word:" % format_ordinal(i + 1))
        else:
            keyboard = Bip39Keyboard("Type the %s word:" % format_ordinal(i + 1))
        if __debug__:
            word = await ctx.wait(keyboard, input_signal)
        else:
            word = await ctx.wait(keyboard)
        words.append(word)

    return " ".join(words)
コード例 #4
0
async def request_mnemonic(ctx, count: int) -> str:
    await ctx.call(ButtonRequest(code=MnemonicInput), ButtonAck)

    words = []
    board = MnemonicKeyboard()
    for i in range(count):
        board.prompt = "Type the %s word:" % format_ordinal(i + 1)
        word = await ctx.wait(board)
        words.append(word)

    return " ".join(words)
コード例 #5
0
 def __init__(self, words, share_index, word_index):
     self.words = words
     self.share_index = share_index
     self.word_index = word_index
     self.buttons = []
     for i, word in enumerate(words):
         area = ui.grid(i + 2, n_x=1)
         btn = Button(area, word)
         btn.on_click = self.select(word)
         self.buttons.append(btn)
     if share_index is None:
         self.text = Text("Check seed")
     else:
         self.text = Text("Check share #%s" % (share_index + 1))
     self.text.normal("Select the %s word:" % utils.format_ordinal(word_index + 1))
コード例 #6
0
async def check_word(ctx, words: list, index: int):
    keyboard = MnemonicKeyboard('Type the %s word:' % format_ordinal(index + 1))
    result = await ctx.wait(keyboard)
    return result == words[index]