util.py 937 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env python3
  2. #
  3. # MMGen Wallet, a terminal-based cryptocurrency wallet
  4. # Copyright (C)2013-2025 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. tx.util: transaction utilities
  12. """
  13. def get_autosign_obj(cfg):
  14. from ..cfg import Config
  15. from ..autosign import Autosign
  16. return Autosign(
  17. Config({
  18. '_clone': cfg,
  19. 'mountpoint': cfg.autosign_mountpoint,
  20. 'coins': cfg.coin,
  21. # used only in online environment (xmrwallet, txcreate, txsend, txbump):
  22. 'online': not cfg.offline}))
  23. def mount_removable_device(cfg):
  24. asi = get_autosign_obj(cfg)
  25. if not asi.device_inserted:
  26. from ..util import die
  27. die(1, 'Removable device not present!')
  28. import atexit
  29. atexit.register(lambda: asi.do_umount())
  30. asi.do_mount()
  31. return asi