completed.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/usr/bin/env python3
  2. #
  3. # mmgen = Multi-Mode GENerator, a command-line cryptocurrency wallet
  4. # Copyright (C)2013-2024 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.eth.tx.completed: Ethereum completed transaction class
  12. """
  13. from ....tx import completed as TxBase
  14. from .base import Base,TokenBase
  15. class Completed(Base,TxBase.Completed):
  16. fn_fee_unit = 'Mwei'
  17. def __init__(self,*args,**kwargs):
  18. self.txobj = {}
  19. super().__init__(*args,**kwargs)
  20. self.gas = self.proto.coin_amt(self.dfl_gas,'wei')
  21. self.start_gas = self.proto.coin_amt(self.dfl_start_gas,'wei')
  22. @property
  23. def send_amt(self):
  24. return self.outputs[0].amt if self.outputs else self.proto.coin_amt('0')
  25. @property
  26. def fee(self):
  27. return self.fee_gasPrice2abs(self.txobj['gasPrice'].toWei())
  28. @property
  29. def change(self):
  30. return self.sum_inputs() - self.send_amt - self.fee
  31. def check_txfile_hex_data(self):
  32. pass
  33. def check_sigs(self): # TODO
  34. from ....util import is_hex_str
  35. if is_hex_str(self.serialized):
  36. return True
  37. return False
  38. def check_pubkey_scripts(self):
  39. pass
  40. def get_serialized_locktime(self):
  41. return None # TODO
  42. class TokenCompleted(TokenBase,Completed):
  43. @property
  44. def change(self):
  45. return self.sum_inputs() - self.send_amt