Ejemplo n.º 1
0
async def slip39_advanced_prompt_group_threshold(ctx, num_of_groups):
    count = num_of_groups // 2 + 1
    min_count = 1
    max_count = num_of_groups

    while True:
        shares = Slip39NumInput(
            Slip39NumInput.SET_GROUP_THRESHOLD, count, min_count, max_count
        )
        confirmed = await confirm(
            ctx,
            shares,
            ButtonRequestType.ResetDevice,
            cancel="Info",
            confirm="Continue",
            major_confirm=True,
            cancel_style=ButtonDefault,
        )
        count = shares.input.count
        if confirmed:
            break
        else:
            info = InfoConfirm(
                "The group threshold "
                "specifies the number of "
                "groups required to "
                "recover your wallet. "
            )
            await info

    return count
Ejemplo n.º 2
0
async def slip39_prompt_threshold(ctx, num_of_shares):
    count = num_of_shares // 2 + 1
    min_count = 2
    max_count = num_of_shares

    while True:
        shares = ShamirNumInput(ShamirNumInput.SET_THRESHOLD, count, min_count,
                                max_count)
        confirmed = await confirm(
            ctx,
            shares,
            ButtonRequestType.ResetDevice,
            cancel="Info",
            confirm="Continue",
            major_confirm=True,
            cancel_style=ButtonDefault,
        )
        count = shares.input.count
        if confirmed:
            break
        else:
            info = InfoConfirm("The threshold sets the "
                               "number of shares "
                               "needed to recover your "
                               "wallet. Set it to %s and "
                               "you will need any %s "
                               "of your %s shares." %
                               (count, count, num_of_shares))
            await info

    return count
Ejemplo n.º 3
0
async def slip39_advanced_prompt_number_of_groups(ctx):
    count = 5
    min_count = 2
    max_count = 16

    while True:
        shares = Slip39NumInput(Slip39NumInput.SET_GROUPS, count, min_count, max_count)
        confirmed = await confirm(
            ctx,
            shares,
            ButtonRequestType.ResetDevice,
            cancel="Info",
            confirm="Continue",
            major_confirm=True,
            cancel_style=ButtonDefault,
        )
        count = shares.input.count
        if confirmed:
            break

        info = InfoConfirm(
            "Each group has a set "
            "number of shares and "
            "its own threshold. In the "
            "next steps you will set "
            "the numbers of shares "
            "and the thresholds."
        )
        await info

    return count
Ejemplo n.º 4
0
async def slip39_prompt_number_of_shares(ctx):
    count = 5
    min_count = 2
    max_count = 16

    while True:
        shares = ShamirNumInput(ShamirNumInput.SET_SHARES, count, min_count,
                                max_count)
        confirmed = await confirm(
            ctx,
            shares,
            ButtonRequestType.ResetDevice,
            cancel="Info",
            confirm="Continue",
            major_confirm=True,
            cancel_style=ButtonDefault,
        )
        count = shares.input.count
        if confirmed:
            break
        else:
            info = InfoConfirm("Each recovery share is "
                               "a sequence of 20 "
                               "words. Next you will "
                               "choose how many "
                               "shares you need to "
                               "recover your wallet.")
            await info

    return count
Ejemplo n.º 5
0
async def slip39_prompt_threshold(ctx, num_of_shares):
    count = num_of_shares // 2
    min_count = 2
    max_count = num_of_shares

    while True:
        shares = ShamirNumInput(ShamirNumInput.SET_THRESHOLD, count, min_count,
                                max_count)
        info = InfoConfirm("Threshold sets number "
                           "shares that you need "
                           "to recover your wallet. "
                           "i.e. Set it to %s and "
                           "you'll need any %s shares "
                           "of the total number." % (count, count))
        confirmed = await confirm(
            ctx,
            shares,
            ButtonRequestType.ResetDevice,
            cancel="Info",
            confirm="Set",
            major_confirm=True,
            cancel_style=ButtonDefault,
        )
        count = shares.input.count
        if confirmed:
            break
        else:
            await info

    return count
Ejemplo n.º 6
0
async def slip39_prompt_number_of_shares(ctx):
    count = 5
    min_count = 2
    max_count = 16

    while True:
        shares = ShamirNumInput(ShamirNumInput.SET_SHARES, count, min_count,
                                max_count)
        info = InfoConfirm("Shares are parts of "
                           "the recovery seed, "
                           "each containing 20 "
                           "words. You can later set "
                           "how many shares you "
                           "need to recover your "
                           "wallet.")
        confirmed = await confirm(
            ctx,
            shares,
            ButtonRequestType.ResetDevice,
            cancel="Info",
            confirm="Set",
            major_confirm=True,
            cancel_style=ButtonDefault,
        )
        count = shares.input.count
        if confirmed:
            break
        else:
            await info

    return count
Ejemplo n.º 7
0
async def slip39_prompt_number_of_shares(ctx, group_id=None):
    count = 5
    min_count = 1
    max_count = 16

    while True:
        shares = Slip39NumInput(
            Slip39NumInput.SET_SHARES, count, min_count, max_count, group_id
        )
        confirmed = await confirm(
            ctx,
            shares,
            ButtonRequestType.ResetDevice,
            cancel="Info",
            confirm="Continue",
            major_confirm=True,
            cancel_style=ButtonDefault,
        )
        count = shares.input.count
        if confirmed:
            break

        if group_id is None:
            info = InfoConfirm(
                "Each recovery share is a "
                "sequence of 20 words. "
                "Next you will choose "
                "how many shares you "
                "need to recover your "
                "wallet."
            )
        else:
            info = InfoConfirm(
                "Each recovery share is a "
                "sequence of 20 words. "
                "Next you will choose "
                "the threshold number of "
                "shares needed to form "
                "Group %s." % (group_id + 1)
            )
        await info

    return count
async def show_keyboard_info(ctx):
    await ctx.call(ButtonRequest(code=ButtonRequestType.Other), ButtonAck)

    info = InfoConfirm("One more thing. "
                       "You can type the letters "
                       "the old-fashioned way "
                       "one by one or use our "
                       "T9 keyboard and press "
                       "buttons only once.")
    if __debug__:
        await ctx.wait(info, confirm_signal)
    else:
        await ctx.wait(info)
Ejemplo n.º 9
0
async def show_keyboard_info(ctx: wire.Context) -> None:
    await ctx.call(ButtonRequest(code=ButtonRequestType.Other), ButtonAck)

    info = InfoConfirm(
        "Did you know? "
        "You can type the letters "
        "one by one or use it like "
        "a T9 keyboard.",
        "Great!",
    )
    if __debug__:
        await ctx.wait(info, confirm_signal)
    else:
        await ctx.wait(info)
Ejemplo n.º 10
0
async def slip39_prompt_threshold(ctx, num_of_shares, group_id=None):
    count = num_of_shares // 2 + 1
    # min value of share threshold is 2 unless the number of shares is 1
    # number of shares 1 is possible in advnaced slip39
    min_count = min(2, num_of_shares)
    max_count = num_of_shares

    while True:
        shares = Slip39NumInput(
            Slip39NumInput.SET_THRESHOLD, count, min_count, max_count, group_id
        )
        confirmed = await confirm(
            ctx,
            shares,
            ButtonRequestType.ResetDevice,
            cancel="Info",
            confirm="Continue",
            major_confirm=True,
            cancel_style=ButtonDefault,
        )
        count = shares.input.count
        if confirmed:
            break

        text = "The threshold sets the number of shares "
        if group_id is None:
            text += "needed to recover your wallet. "
            text += "Set it to %s and you will need " % count
            if num_of_shares == 1:
                text += "1 share."
            elif num_of_shares == count:
                text += "all %s of your %s shares." % (count, num_of_shares)
            else:
                text += "any %s of your %s shares." % (count, num_of_shares)
        else:
            text += "needed to form a group. "
            text += "Set it to %s and you will " % count
            if num_of_shares == 1:
                text += "need 1 share "
            elif num_of_shares == count:
                text += "need all %s of %s shares " % (count, num_of_shares)
            else:
                text += "need any %s of %s shares " % (count, num_of_shares)
            text += "to form Group %s." % (group_id + 1)
        info = InfoConfirm(text)
        await info

    return count