diff --git a/shared/address_explorer.py b/shared/address_explorer.py index ed95e48f..0332f60d 100644 --- a/shared/address_explorer.py +++ b/shared/address_explorer.py @@ -17,18 +17,7 @@ from glob import settings from auth import write_sig_file from charcodes import KEY_QR, KEY_NFC, KEY_PAGE_UP, KEY_PAGE_DOWN, KEY_HOME, KEY_LEFT, KEY_RIGHT from charcodes import KEY_CANCEL -from utils import show_single_address, problem_file_line - -def truncate_address(addr): - # Truncates address to width of screen, replacing middle chars - if not version.has_qwerty: - # - 16 chars screen width - # - but 2 lost at left (menu arrow, corner arrow) - # - want to show not truncated on right side - return addr[0:6] + '⋯' + addr[-6:] - else: - # tons of space on Q1 - return addr[0:12] + '⋯' + addr[-12:] +from utils import show_single_address, problem_file_line, truncate_address def censor_address(addr): # We don't like to show the user full multisig addresses because we cannot be certain diff --git a/shared/ccc.py b/shared/ccc.py index 3bd790fa..4c4aa98b 100644 --- a/shared/ccc.py +++ b/shared/ccc.py @@ -4,7 +4,7 @@ # import gc, chains, version, ngu, web2fa, bip39, re from chains import NLOCK_IS_TIME -from utils import swab32, a2b_hex, b2a_hex, xfp2str, truncate_address, pad_raw_secret +from utils import swab32, xfp2str, truncate_address, pad_raw_secret from glob import settings from ux import ux_confirm, ux_show_story, the_ux, OK, ux_dramatic_pause, ux_enter_number, ux_aborted from menu import MenuSystem, MenuItem, start_chooser @@ -364,9 +364,9 @@ be ready to show it as a QR, before proceeding.''' # - just a shortcut, since they have the words, and could enter them # - one-way trip because the CCC feature won't be enabled inside the temp seed settings if await ux_show_story( - 'Loads the CCC controlled seed (key C) as a Temporary Seed and allows ' - 'easy use of all Coldcard features on that key.\n\nIf you save into Seed Vault, ' - 'access to CCC Config menu is quick and easy.') != 'y': + 'Loads the CCC controlled seed (key C) as a Temporary Seed and allows ' + 'easy use of all Coldcard features on that key.\n\nIf you save into Seed Vault, ' + 'access to CCC Config menu is quick and easy.') != 'y': return from seed import set_ephemeral_seed diff --git a/shared/chains.py b/shared/chains.py index e77611b3..42e5e9f0 100644 --- a/shared/chains.py +++ b/shared/chains.py @@ -38,7 +38,7 @@ class ChainsBase: curve = 'secp256k1' menu_name = None # use 'name' if this isn't defined core_name = None # name of chain's "core" p2p software - CCC_MIN_BLOCK = 0 + ccc_min_block = 0 # b44_cointype comes from # @@ -299,7 +299,7 @@ class BitcoinMain(ChainsBase): # see ctype = 'BTC' name = 'Bitcoin Mainnet' - CCC_MIN_BLOCK = 865572 + ccc_min_block = 865572 slip132 = { AF_CLASSIC: Slip132Version(0x0488B21E, 0x0488ADE4, 'x'), diff --git a/shared/utils.py b/shared/utils.py index 13e17491..fd253e4d 100644 --- a/shared/utils.py +++ b/shared/utils.py @@ -714,4 +714,15 @@ def cleanup_payment_address(s): raise ValueError('bad address value: ' + s) +def truncate_address(addr): + # Truncates address to width of screen, replacing middle chars + if not version.has_qwerty: + # - 16 chars screen width + # - but 2 lost at left (menu arrow, corner arrow) + # - want to show not truncated on right side + return addr[0:6] + '⋯' + addr[-6:] + else: + # tons of space on Q1 + return addr[0:12] + '⋯' + addr[-12:] + # EOF diff --git a/shared/web2fa.py b/shared/web2fa.py index dcf62388..84f25d5a 100644 --- a/shared/web2fa.py +++ b/shared/web2fa.py @@ -72,16 +72,8 @@ async def perform_web2fa(label, shared_secret): # from ux_mk4 import ux_input_digits - def limit_len(n): - ll = len(n) - if ll == 8: - return n - if ll > 8: - return n[0:8] - return '' - while 1: - got = await ux_input_digits('', limit_len, maxlen=8, + got = await ux_input_digits('', maxlen=8, prompt="8-digits From Web") if not got: diff --git a/shared/xor_seed.py b/shared/xor_seed.py index e7163e66..465f5e86 100644 --- a/shared/xor_seed.py +++ b/shared/xor_seed.py @@ -69,7 +69,7 @@ Otherwise, press {ok} to continue.'''.format(n=num_parts, ok=OK), escape='2') raw_secret = bytes(32) try: - with stash.SensitiveValues() as sv: + with SensitiveValues() as sv: if sv.deltamode: # die rather than give up our secrets import callgate @@ -294,7 +294,7 @@ or press (2) for 18 words XOR.''' % OK, escape="12") if ch == 'x': return if ch == '1': dis.fullscreen("Wait...") - with stash.SensitiveValues() as sv: + with SensitiveValues() as sv: if sv.deltamode: # die rather than give up our secrets import callgate