cmdline.py (1355B)
1 from electrum.util import print_stderr, raw_input 2 from electrum.logging import get_logger 3 4 from .plugin import HardwareHandlerBase 5 6 7 _logger = get_logger(__name__) 8 9 10 class CmdLineHandler(HardwareHandlerBase): 11 12 def get_passphrase(self, msg, confirm): 13 import getpass 14 print_stderr(msg) 15 return getpass.getpass('') 16 17 def get_pin(self, msg, *, show_strength=True): 18 t = { 'a':'7', 'b':'8', 'c':'9', 'd':'4', 'e':'5', 'f':'6', 'g':'1', 'h':'2', 'i':'3'} 19 print_stderr(msg) 20 print_stderr("a b c\nd e f\ng h i\n-----") 21 o = raw_input() 22 try: 23 return ''.join(map(lambda x: t[x], o)) 24 except KeyError as e: 25 raise Exception("Character {} not in matrix!".format(e)) from e 26 27 def prompt_auth(self, msg): 28 import getpass 29 print_stderr(msg) 30 response = getpass.getpass('') 31 if len(response) == 0: 32 return None 33 return response 34 35 def yes_no_question(self, msg): 36 print_stderr(msg) 37 return raw_input() in 'yY' 38 39 def stop(self): 40 pass 41 42 def show_message(self, msg, on_cancel=None): 43 print_stderr(msg) 44 45 def show_error(self, msg, blocking=False): 46 print_stderr(msg) 47 48 def update_status(self, b): 49 _logger.info(f'hw device status {b}') 50 51 def finished(self): 52 pass