unenc.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/usr/bin/env python3
  2. #
  3. # MMGen Wallet, a terminal-based cryptocurrency wallet
  4. # Copyright (C)2013-2024 The MMGen Project <mmgen@tuta.io>
  5. # Licensed under the GNU General Public License, Version 3:
  6. # https://www.gnu.org/licenses
  7. # Public project repositories:
  8. # https://github.com/mmgen/mmgen-wallet
  9. # https://gitlab.com/mmgen/mmgen-wallet
  10. """
  11. wallet.unenc: unencrypted wallet base class
  12. """
  13. from ..color import blue,yellow
  14. from ..util import msg,msg_r,capfirst,is_int
  15. from .base import wallet
  16. class wallet(wallet):
  17. def _decrypt_retry(self):
  18. pass
  19. def _encrypt(self):
  20. pass
  21. def _filename(self):
  22. s = self.seed
  23. return '{}[{}].{}'.format(
  24. s.fn_stem,
  25. s.bitlen,
  26. self.ext )
  27. def _print_seed_type(self):
  28. msg('{} {}'.format(
  29. blue(f'{capfirst(self.base_type or self.type)} type:'),
  30. yellow(self.mn_type)
  31. ))
  32. def _choose_seedlen(self,ok_lens):
  33. from ..term import get_char
  34. def choose_len():
  35. prompt = self.choose_seedlen_prompt
  36. while True:
  37. r = get_char('\r'+prompt)
  38. if is_int(r) and 1 <= int(r) <= len(ok_lens):
  39. break
  40. msg_r(('\r','\n')[self.cfg.test_suite] + ' '*len(prompt) + '\r')
  41. return ok_lens[int(r)-1]
  42. while True:
  43. usr_len = choose_len()
  44. prompt = self.choose_seedlen_confirm.format(usr_len)
  45. from ..ui import keypress_confirm
  46. if keypress_confirm(
  47. self.cfg,
  48. prompt,
  49. default_yes = True,
  50. no_nl = not self.cfg.test_suite ):
  51. return usr_len