unspent.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/env python3
  2. #
  3. # MMGen Wallet, a terminal-based 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.btc.tw.unspent: Bitcoin base protocol tracking wallet unspent outputs class
  12. """
  13. from ....tw.unspent import TwUnspentOutputs
  14. class BitcoinTwUnspentOutputs(TwUnspentOutputs):
  15. class MMGenTwUnspentOutput(TwUnspentOutputs.MMGenTwUnspentOutput):
  16. # required by gen_unspent(); setting valid_attrs explicitly is also more efficient
  17. valid_attrs = {'txid','vout','amt','amt2','comment','twmmid','addr','confs','date','scriptPubKey','skip'}
  18. invalid_attrs = {'proto'}
  19. has_age = True
  20. can_group = True
  21. hdr_lbl = 'unspent outputs'
  22. desc = 'unspent outputs'
  23. item_desc = 'unspent output'
  24. no_data_errmsg = 'No unspent outputs in tracking wallet!'
  25. dump_fn_pfx = 'listunspent'
  26. prompt_fs_in = [
  27. 'Sort options: [t]xid, [a]mount, [A]ge, a[d]dr, [M]mgen addr, [r]everse',
  28. 'Column options: toggle [D]ays/date/confs/block, gr[o]up, show [m]mgen addr',
  29. 'View options: pager [v]iew, [w]ide pager view{s}',
  30. 'Actions: [q]uit menu, [p]rint, r[e]draw, add [l]abel:']
  31. prompt_fs_repl = {
  32. 'BCH': (1, 'Column options: toggle [D]ate/confs, cas[h]addr, gr[o]up, show [m]mgen addr')
  33. }
  34. key_mappings = {
  35. 't':'s_txid',
  36. 'a':'s_amt',
  37. 'd':'s_addr',
  38. 'A':'s_age',
  39. 'M':'s_twmmid',
  40. 'r':'s_reverse',
  41. 'D':'d_days',
  42. 'o':'d_group',
  43. 'm':'d_mmid',
  44. 'e':'d_redraw',
  45. 'p':'a_print_detail',
  46. 'v':'a_view',
  47. 'w':'a_view_detail',
  48. 'l':'i_comment_add' }
  49. async def get_rpc_data(self):
  50. # bitcoin-cli help listunspent:
  51. # Arguments:
  52. # 1. minconf (numeric, optional, default=1) The minimum confirmations to filter
  53. # 2. maxconf (numeric, optional, default=9999999) The maximum confirmations to filter
  54. # 3. addresses (json array, optional, default=empty array) A json array of bitcoin addresses
  55. # 4. include_unsafe (boolean, optional, default=true) Include outputs that are not safe to spend
  56. # 5. query_options (json object, optional) JSON with query options
  57. # for now, self.addrs is just an empty list for Bitcoin and friends
  58. add_args = (9999999,self.addrs) if self.addrs else ()
  59. return await self.rpc.call('listunspent',self.minconf,*add_args)