unenc.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/usr/bin/env python3
  2. #
  3. # mmgen = Multi-Mode GENerator, a command-line cryptocurrency wallet
  4. # Copyright (C)2013-2023 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 _choose_seedlen(self,ok_lens):
  28. from ..term import get_char
  29. def choose_len():
  30. prompt = self.choose_seedlen_prompt
  31. while True:
  32. r = get_char('\r'+prompt)
  33. if is_int(r) and 1 <= int(r) <= len(ok_lens):
  34. break
  35. msg_r(('\r','\n')[self.cfg.test_suite] + ' '*len(prompt) + '\r')
  36. return ok_lens[int(r)-1]
  37. msg('{} {}'.format(
  38. blue(f'{capfirst(self.base_type or self.type)} type:'),
  39. yellow(self.mn_type)
  40. ))
  41. while True:
  42. usr_len = choose_len()
  43. prompt = self.choose_seedlen_confirm.format(usr_len)
  44. from ..ui import keypress_confirm
  45. if keypress_confirm(
  46. self.cfg,
  47. prompt,
  48. default_yes = True,
  49. no_nl = not self.cfg.test_suite ):
  50. return usr_len