sign.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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.sign: Monero wallet ops for the MMGen Suite
  12. """
  13. from ..file.tx import MoneroMMGenTX
  14. from ..rpc import MoneroWalletRPC
  15. from .wallet import OpWallet
  16. class OpSign(OpWallet):
  17. action = 'signing transaction with'
  18. start_daemon = False
  19. async def main(self, fn, *, restart_daemon=True):
  20. if restart_daemon:
  21. await self.restart_wallet_daemon()
  22. tx = MoneroMMGenTX.Unsigned(self.cfg, fn)
  23. h = MoneroWalletRPC(self, self.addr_data[0])
  24. self.head_msg(tx.src_wallet_idx, h.fn)
  25. if restart_daemon:
  26. h.open_wallet(refresh=False)
  27. res = self.c.call(
  28. 'sign_transfer',
  29. unsigned_txset = tx.data.unsigned_txset,
  30. export_raw = True,
  31. get_tx_keys = True
  32. )
  33. new_tx = MoneroMMGenTX.NewColdSigned(
  34. cfg = self.cfg,
  35. txid = res['tx_hash_list'][0],
  36. unsigned_txset = None,
  37. signed_txset = res['signed_txset'],
  38. _in_tx = tx,
  39. )
  40. return new_tx