You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
2.7 KiB

# SPDX-FileCopyrightText: 2020 Foundation Devices, Inc. <hello@foundationdevices.com>
4 years ago
# SPDX-License-Identifier: GPL-3.0-or-later
#
# SPDX-FileCopyrightText: 2018 Coinkite, Inc. <coldcardwallet.com>
4 years ago
# SPDX-License-Identifier: GPL-3.0-only
#
# (c) Copyright 2018 by Coinkite Inc. This file is part of Coldcard <coldcardwallet.com>
# and is covered by GPLv3 license found in COPYING.
#
# choosers.py - various interactive menus for setting config values.
#
from common import settings
def shutdown_timeout_chooser():
DEFAULT_SHUTDOWN_TIMEOUT = (2*60) # 2 minutes
4 years ago
timeout = settings.get('shutdown_timeout', DEFAULT_SHUTDOWN_TIMEOUT) # in seconds
4 years ago
ch = [' 1 minute',
' 2 minutes',
4 years ago
' 5 minutes',
'15 minutes',
'30 minutes',
'60 minutes',
'Never']
va = [1*60, 2*60, 5*60, 15*60, 30*60, 60*60, 0]
4 years ago
try:
which = va.index(timeout)
except ValueError:
which = 1
4 years ago
def set_shutdown_timeout(idx, text):
settings.set('shutdown_timeout', va[idx])
4 years ago
return which, ch, set_shutdown_timeout
4 years ago
def brightness_chooser():
screen_brightness = settings.get('screen_brightness', 100)
ch = ['Off', '25%', '50%', '75%', '100%'] # , 'Automatic']
va = [0, 25, 50, 75, 100] # , 999]
4 years ago
try:
which = va.index(screen_brightness)
except ValueError:
which = 4
4 years ago
def set(idx, text):
from common import dis
dis.set_brightness(va[idx])
settings.set('screen_brightness', va[idx])
4 years ago
return which, ch, set
def enable_passphrase_chooser():
# Should the Passphrase menu be enabled in the main menu?
ch = ['Disabled', 'Enabled']
va = [False, True]
assert len(ch) == len(va)
enable_passphrase = settings.get('enable_passphrase', False)
try:
which = va.index(enable_passphrase)
except ValueError:
which = 0
def set_enable_passphrase(idx, text):
settings.set('enable_passphrase', va[idx])
return which, ch, set_enable_passphrase
PASS1-128: Add support back for Bitcoin testnet (#29) * Fixes part of PASS-91 Show address and index of the address being verified * Second half of fix for ENV1-91 Add better messaging for address range searching Fix a bug when saving next_addrs (was comparing dicts by ref) * Fixes PASS1-122 Check change addresses in addition to receive address in &#34;Verify Address&#34; * Fix comment punctuation * Show backup filename to user after successful backup (#18) Fix PASS1-92 * Auto-truncate multisig config names (#19) Fix PASS1-101 * PASS1-101: Auto-truncate multisig config names (#19) Fix PASS1-101 * Remove unnecessary comments * PASS1-92 (#20) * Show backup filename to user after successful backup Fix PASS1-92 * Add missing &#39;card&#39; parameter to `get_backups_folder_path()` calls * Revert path function changes since &#39;card&#39; is not available * PASS1-102: Fix backwards microSD issue Found that `ErrorCode` in `SD_HandleTypeDef` was not reset after a failure. Updated `HAL_SD_Init()` to reset it before attempting initialization. * PASS1-102: Fix backwards microSD issue (#21) Found that `ErrorCode` in `SD_HandleTypeDef` was not reset after a failure. Updated `HAL_SD_Init()` to reset it before attempting initialization. * PASS1-102_b (#22) * PASS1-102: Fix backwards microSD issue Found that `ErrorCode` in `SD_HandleTypeDef` was not reset after a failure. Updated `HAL_SD_Init()` to reset it before attempting initialization. * Switch back to hard-coded path for now * PASS1-122_b (#23) * PASS1-102: Fix backwards microSD issue Found that `ErrorCode` in `SD_HandleTypeDef` was not reset after a failure. Updated `HAL_SD_Init()` to reset it before attempting initialization. * Update user messaging for found/not found case of Verify Address Fix bug with trailing space at end of line in `word_wrap()` * Strip ever time through the loop * PASS1-125: Add Git commit-msg hook to check for Linear ID (#24) * PASS1-125: Add Git commit-msg hook to check for Linear ID * Update .githooks/commit-msg Co-authored-by: Jean Pierre Dudey &lt;jeandudey@hotmail.com&gt; Co-authored-by: Jean Pierre Dudey &lt;jeandudey@hotmail.com&gt; * PASS1-122: Minor updates to text (#27) * PASS1-127: Fix `reuse lint` issues in the repo (#26) * PASS1-113: Give the user a way to clear the developer pubkey slot (#25) * PASS1-122: Added &#34;Address Verified&#34; text to new wallet pairing (#28) * PASS1-122: Minor updates to text * PASS1-122: Added &#34;Address Verified&#34; text to new wallet pairing * PASS1-128: Add support back for Bitcoin testnet Co-authored-by: Ken Carpenter &lt;ken@foundationdevices.com&gt; Co-authored-by: Ken Carpenter &lt;62639971+FoundationKen@users.noreply.github.com&gt; Co-authored-by: Jean Pierre Dudey &lt;jeandudey@hotmail.com&gt;
4 years ago
def chain_chooser():
from chains import AllChains
chain = settings.get('chain', 'BTC')
ch = [(i.ctype, i.menu_name or i.name) for i in AllChains ]
# find index of current choice
try:
which = [n for n, (k,v) in enumerate(ch) if k == chain][0]
except IndexError:
which = 0
def set_chain(idx, text):
val = ch[idx][0]
assert ch[idx][1] == text
settings.set('chain', val)
try:
# update xpub stored in settings
import stash
with stash.SensitiveValues() as sv:
sv.capture_xpub()
except ValueError:
# no secrets yet, not an error
pass
return which, [t for _,t in ch], set_chain
4 years ago
# EOF