new_swap.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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.btc.tx.new_swap: Bitcoin new swap transaction class
  12. """
  13. from ....tx.new_swap import NewSwap as TxNewSwap
  14. from ....tx.new_swap import get_swap_proto_mod
  15. from .new import New
  16. class NewSwap(New, TxNewSwap):
  17. desc = 'Bitcoin swap transaction'
  18. def update_data_output(self, trade_limit):
  19. sp = get_swap_proto_mod(self.swap_proto)
  20. o = self.data_output._asdict()
  21. parsed_memo = sp.data.parse(o['data'].decode())
  22. memo = sp.data(
  23. self.recv_proto,
  24. self.recv_proto.coin_addr(parsed_memo.address),
  25. trade_limit = trade_limit)
  26. o['data'] = f'data:{memo}'
  27. self.data_output = self.Output(self.proto, **o)
  28. @property
  29. def vault_idx(self):
  30. return self._chg_output_ops('idx', 'is_vault')
  31. @property
  32. def vault_output(self):
  33. return self._chg_output_ops('output', 'is_vault')