bal.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/env python3
  2. #
  3. # mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
  4. # Copyright (C)2013-2024 The MMGen Project <mmgen@tuta.io>
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. """
  19. proto.eth.tw.bal: Ethereum tracking wallet getbalance class
  20. """
  21. from ....tw.ctl import TwCtl
  22. from ....tw.bal import TwGetBalance
  23. class EthereumTwGetBalance(TwGetBalance):
  24. start_labels = ('TOTAL','Non-MMGen')
  25. conf_cols = {
  26. 'ge_minconf': 'Balance',
  27. }
  28. async def __init__(self,cfg,proto,*args,**kwargs):
  29. self.twctl = await TwCtl(cfg,proto,mode='w')
  30. await super().__init__(cfg,proto,*args,**kwargs)
  31. async def create_data(self):
  32. in_data = self.twctl.mmid_ordered_dict
  33. for d in in_data:
  34. if d.type == 'mmgen':
  35. label = d.obj.sid
  36. if label not in self.data:
  37. self.data[label] = self.balance_info()
  38. else:
  39. label = 'Non-MMGen'
  40. amt = await self.twctl.get_balance(in_data[d]['addr'])
  41. self.data['TOTAL']['ge_minconf'] += amt
  42. self.data[label]['ge_minconf'] += amt
  43. del self.twctl
  44. class EthereumTokenTwGetBalance(EthereumTwGetBalance):
  45. pass