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
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
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 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