addrdata.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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.addrdata: Bitcoin base protocol addrdata classes
  12. """
  13. from ...addrdata import TwAddrData
  14. class BitcoinTwAddrData(TwAddrData):
  15. msgs = {
  16. 'multiple_acct_addrs': """
  17. ERROR: More than one address found for account: {acct!r}.
  18. Your 'wallet.dat' file appears to have been altered by a non-{proj} program.
  19. Please restore your tracking wallet from a backup or create a new one and
  20. re-import your addresses.
  21. """
  22. }
  23. async def get_tw_data(self, *, twctl=None):
  24. self.cfg._util.vmsg('Getting address data from tracking wallet')
  25. c = self.rpc
  26. if 'label_api' in c.caps:
  27. accts = await c.call('listlabels')
  28. ll = await c.batch_call('getaddressesbylabel', [(k,) for k in accts])
  29. alists = [list(a.keys()) for a in ll]
  30. else:
  31. accts = await c.call('listaccounts', 0, True)
  32. alists = await c.batch_call('getaddressesbyaccount', [(k,) for k in accts])
  33. return list(zip(accts, alists))