mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
previously, client.handler was sometimes - an InstallWizard - a QtHandlerBase where win was an ElectrumWindow - a QtHandlerBase where win was an InstallWizard - a CmdLineHandler That's just too much dynamic untyped undocumented polymorphism... Now it will never be an InstallWizard (replaced with QtHandlerBase where win is an InstallWizard), and now in all cases client.handler is an instance of HardwareHandlerBase, yay. related: #6063
52 lines
1.3 KiB
Python
52 lines
1.3 KiB
Python
from electrum.util import print_stderr, raw_input
|
|
from electrum.logging import get_logger
|
|
|
|
from .plugin import HardwareHandlerBase
|
|
|
|
|
|
_logger = get_logger(__name__)
|
|
|
|
|
|
class CmdLineHandler(HardwareHandlerBase):
|
|
|
|
def get_passphrase(self, msg, confirm):
|
|
import getpass
|
|
print_stderr(msg)
|
|
return getpass.getpass('')
|
|
|
|
def get_pin(self, msg):
|
|
t = { 'a':'7', 'b':'8', 'c':'9', 'd':'4', 'e':'5', 'f':'6', 'g':'1', 'h':'2', 'i':'3'}
|
|
print_stderr(msg)
|
|
print_stderr("a b c\nd e f\ng h i\n-----")
|
|
o = raw_input()
|
|
try:
|
|
return ''.join(map(lambda x: t[x], o))
|
|
except KeyError as e:
|
|
raise Exception("Character {} not in matrix!".format(e)) from e
|
|
|
|
def prompt_auth(self, msg):
|
|
import getpass
|
|
print_stderr(msg)
|
|
response = getpass.getpass('')
|
|
if len(response) == 0:
|
|
return None
|
|
return response
|
|
|
|
def yes_no_question(self, msg):
|
|
print_stderr(msg)
|
|
return raw_input() in 'yY'
|
|
|
|
def stop(self):
|
|
pass
|
|
|
|
def show_message(self, msg, on_cancel=None):
|
|
print_stderr(msg)
|
|
|
|
def show_error(self, msg, blocking=False):
|
|
print_stderr(msg)
|
|
|
|
def update_status(self, b):
|
|
_logger.info(f'hw device status {b}')
|
|
|
|
def finished(self):
|
|
pass
|