export.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. xmrwallet.ops.export: Monero wallet ops for the MMGen Suite
  12. """
  13. from ...util import gmsg, gmsg_r
  14. from ..file.outputs import MoneroWalletOutputsFile
  15. from ..rpc import MoneroWalletRPC
  16. from .wallet import OpWallet
  17. class OpExportOutputs(OpWallet):
  18. action = 'exporting outputs from'
  19. stem = 'process'
  20. sign = False
  21. async def process_wallet(self, d, fn, last):
  22. h = MoneroWalletRPC(self, d)
  23. h.open_wallet('source')
  24. if self.cfg.rescan_blockchain:
  25. gmsg_r('\n Rescanning blockchain...')
  26. self.c.call('rescan_blockchain')
  27. gmsg('done')
  28. if self.cfg.rescan_spent:
  29. gmsg_r('\n Rescanning spent outputs...')
  30. self.c.call('rescan_spent')
  31. gmsg('done')
  32. self.head_msg(d.idx, h.fn)
  33. for ftype in ('Unsigned', 'Signed'):
  34. old_fn = getattr(MoneroWalletOutputsFile, ftype).find_fn_from_wallet_fn(
  35. cfg = self.cfg,
  36. wallet_fn = fn,
  37. ret_on_no_match = True)
  38. if old_fn:
  39. old_fn.unlink()
  40. m = MoneroWalletOutputsFile.New(
  41. parent = self,
  42. wallet_fn = fn,
  43. data = self.c.call('export_outputs', all=True),
  44. sign = self.sign)
  45. m.write()
  46. return True
  47. class OpExportOutputsSign(OpExportOutputs):
  48. opts = ('rescan_spent', 'rescan_blockchain')
  49. sign = True