new parameter to "force_msg" during QR display
This commit is contained in:
parent
633120b760
commit
cd1728b81d
@ -328,7 +328,8 @@ class Display:
|
||||
# no status bar on Mk4
|
||||
return
|
||||
|
||||
def draw_qr_display(self, qr_data, msg, is_alnum, sidebar, idx_hint, invert, is_addr=False):
|
||||
def draw_qr_display(self, qr_data, msg, is_alnum, sidebar, idx_hint, invert,
|
||||
is_addr=False, force_msg=False):
|
||||
# 'sidebar' is a pre-formated obj to show to right of QR -- oled life
|
||||
# - 'msg' will appear to right if very short, else under in tiny
|
||||
# - ignores "is_addr" because exactly zero space to do anything special
|
||||
|
||||
@ -655,7 +655,8 @@ class Display:
|
||||
|
||||
return prev_x
|
||||
|
||||
def draw_qr_display(self, qr_data, msg, is_alnum, sidebar, idx_hint, invert, partial_bar=None, is_addr=False):
|
||||
def draw_qr_display(self, qr_data, msg, is_alnum, sidebar, idx_hint, invert, partial_bar=None,
|
||||
is_addr=False, force_msg=False):
|
||||
# Show a QR code on screen w/ some text under it
|
||||
# - invert not supported on Q1
|
||||
# - sidebar not supported here (see users.py)
|
||||
@ -705,20 +706,21 @@ class Display:
|
||||
fullscreen = False
|
||||
trim_lines = 0
|
||||
|
||||
# always try to show the biggest possible QR code
|
||||
if num_lines:
|
||||
# better with text dropped?
|
||||
e2 = max(1, ACTIVE_H // (w + 2))
|
||||
if e2 > expand:
|
||||
num_lines = 0
|
||||
expand = e2
|
||||
# always try to show the biggest possible QR code if not force_msg
|
||||
if not force_msg:
|
||||
if num_lines:
|
||||
# better with text dropped?
|
||||
e2 = max(1, ACTIVE_H // (w + 2))
|
||||
if e2 > expand:
|
||||
num_lines = 0
|
||||
expand = e2
|
||||
|
||||
# fullscreen ?
|
||||
e3 = (ACTIVE_H + 20) // (w + 2)
|
||||
if expand < e3:
|
||||
expand = e3
|
||||
fullscreen = True
|
||||
num_lines = 0
|
||||
# fullscreen ?
|
||||
e3 = (ACTIVE_H + 20) // (w + 2)
|
||||
if expand < e3:
|
||||
expand = e3
|
||||
fullscreen = True
|
||||
num_lines = 0
|
||||
|
||||
# vert center in available space
|
||||
qw = (w+2) * expand
|
||||
|
||||
@ -6,7 +6,7 @@ import stash, chains, ustruct, ure, uio, sys, ngu, uos, ujson, version
|
||||
from utils import xfp2str, str2xfp, swab32, cleanup_deriv_path, keypath_to_str, to_ascii_printable
|
||||
from utils import str_to_keypath, problem_file_line, parse_extended_key, get_filesize
|
||||
from ux import ux_show_story, ux_confirm, ux_dramatic_pause, ux_clear_keys
|
||||
from ux import import_export_prompt, ux_enter_bip32_index, show_qr_code, ux_enter_number, OK, X
|
||||
from ux import import_export_prompt, ux_enter_bip32_index, ux_enter_number, OK, X
|
||||
from files import CardSlot, CardMissingError, needs_microsd
|
||||
from descriptor import MultisigDescriptor, multisig_descriptor_template
|
||||
from public_constants import AF_P2SH, AF_P2WSH_P2SH, AF_P2WSH, AFC_SCRIPT, MAX_SIGNERS
|
||||
|
||||
@ -17,7 +17,8 @@ MAX_V11_CHAR_LIMIT = const(321)
|
||||
class QRDisplaySingle(UserInteraction):
|
||||
# Show a single QR code for (typically) a list of addresses, or a single value.
|
||||
|
||||
def __init__(self, addrs, is_alnum, start_n=0, sidebar=None, msg=None, is_addrs=False):
|
||||
def __init__(self, addrs, is_alnum, start_n=0, sidebar=None, msg=None,
|
||||
is_addrs=False, force_msg=False):
|
||||
self.is_alnum = is_alnum
|
||||
self.idx = 0 # start with first address
|
||||
self.invert = False # looks better, but neither mode is ideal
|
||||
@ -27,6 +28,7 @@ class QRDisplaySingle(UserInteraction):
|
||||
self.is_addrs = is_addrs
|
||||
self.msg = msg
|
||||
self.qr_data = None
|
||||
self.force_msg = force_msg
|
||||
|
||||
def calc_qr(self, msg):
|
||||
# Version 2 would be nice, but can't hold what we need, even at min error correction,
|
||||
@ -77,7 +79,8 @@ class QRDisplaySingle(UserInteraction):
|
||||
# draw display
|
||||
dis.busy_bar(False)
|
||||
dis.draw_qr_display(self.qr_data, self.msg or body, self.is_alnum,
|
||||
self.sidebar, self.idx_hint(), self.invert, is_addr=self.is_addrs)
|
||||
self.sidebar, self.idx_hint(), self.invert,
|
||||
is_addr=self.is_addrs, force_msg=False)
|
||||
|
||||
async def interact_bare(self):
|
||||
from glob import NFC, dis
|
||||
|
||||
@ -120,7 +120,8 @@ async def web2fa_enroll(label, ss=None):
|
||||
|
||||
while 1:
|
||||
# show QR for enroll
|
||||
await show_qr_code(qr, is_alnum=False, msg="Import into 2FA Mobile App")
|
||||
await show_qr_code(qr, is_alnum=False, msg="Import into 2FA Mobile App",
|
||||
force_msg=True)
|
||||
|
||||
# important: force them to prove they store it correctly
|
||||
ok = await perform_web2fa('Enroll: ' + label, ss)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user