new.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. proto.xmr.tx.new: Monero new transaction class
  12. """
  13. from ....tx.new import New as TxNew
  14. from .base import Base
  15. class New(Base, TxNew):
  16. async def get_input_addrs_from_inputs_opt(self):
  17. return [] # TODO
  18. async def set_gas(self):
  19. pass
  20. async def get_fee(self, fee, outputs_sum, start_fee_desc):
  21. return True
  22. def copy_inputs_from_tw(self, tw_unspent_data):
  23. self.inputs = tw_unspent_data
  24. def get_unspent_nums_from_user(self, accts_data):
  25. from ....util import msg, is_int
  26. from ....ui import line_input
  27. prompt = 'Enter an account number to spend from: '
  28. while True:
  29. if reply := line_input(self.cfg, prompt).strip():
  30. if is_int(reply) and 1 <= int(reply) <= len(accts_data):
  31. return [int(reply)]
  32. msg(f'Account number must be an integer between 1 and {len(accts_data)} inclusive')
  33. async def compat_create(self):
  34. from ....xmrwallet import op as xmrwallet_op
  35. i = self.inputs[0]
  36. o = self.outputs[0]
  37. op = xmrwallet_op(
  38. 'transfer',
  39. self.cfg,
  40. None,
  41. None,
  42. spec = f'{i.idx}:{i.acct_idx}:{o.addr},{o.amt}',
  43. compat_call = True)
  44. await op.restart_wallet_daemon()
  45. return await op.main()