Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mmgen-tool listaddresses: fully reimplement
- reimplemented using the new tracking wallet display framework - command is now interactive, with the same UI as 'twview' and 'txhist' - the new 'Used' column shows whether an address has received funds - the new tristate 'showused' filter allows display of only unused, used or all used addresses - adding, removal and editing of labels is supported Testing/demo: # Run the regtest test partially, leaving coin daemon running: $ test/test.py -De regtest.label # Try out the interactive sorting, filtering and label editing features: $ PYTHONPATH=. MMGEN_TEST_SUITE=1 cmds/mmgen-tool --bob listaddresses interactive=1 # When finished, gracefully shut down the daemon: $ test/stop-coin-daemons.py btc_rt
- Loading branch information
Showing
12 changed files
with
507 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
13.3.dev16 | ||
13.3.dev17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# mmgen = Multi-Mode GENerator, a command-line cryptocurrency wallet | ||
# Copyright (C)2013-2022 The MMGen Project <mmgen@tuta.io> | ||
# Licensed under the GNU General Public License, Version 3: | ||
# https://www.gnu.org/licenses | ||
# Public project repositories: | ||
# https://github.com/mmgen/mmgen | ||
# https://gitlab.com/mmgen/mmgen | ||
|
||
""" | ||
proto.btc.tw.addresses: Bitcoin base protocol tracking wallet address list class | ||
""" | ||
|
||
from ....tw.addresses import TwAddresses | ||
from ....tw.common import TwLabel,get_obj | ||
from ....util import msg,msg_r | ||
from ....addr import CoinAddr | ||
from ....obj import NonNegativeInt | ||
from .common import BitcoinTwCommon | ||
|
||
class BitcoinTwAddresses(TwAddresses,BitcoinTwCommon): | ||
|
||
has_age = True | ||
prompt = """ | ||
Sort options: [a]mt, [A]ge, [M]mid, [r]everse | ||
Column options: toggle [D]ays/date/confs/block | ||
Filters: show [E]mpty addrs, [u]sed addrs, all [L]abels | ||
View/Print: pager [v]iew, [w]ide view, [p]rint | ||
Actions: [q]uit, r[e]draw, add [l]abel: | ||
""" | ||
key_mappings = { | ||
'a':'s_amt', | ||
'A':'s_age', | ||
'M':'s_twmmid', | ||
'r':'d_reverse', | ||
'D':'d_days', | ||
'e':'d_redraw', | ||
'E':'d_showempty', | ||
'u':'d_showused', | ||
'L':'d_all_labels', | ||
'q':'a_quit', | ||
'v':'a_view', | ||
'w':'a_view_detail', | ||
'p':'a_print_detail', | ||
'l':'a_comment_add' } | ||
|
||
squeezed_fs_fs = ' {{n:>{nw}}} {{m:}} {{u:}}%s {{c:}} {{b:}} {{d:}}' | ||
squeezed_hdr_fs_fs = ' {{n:>{nw}}} {{m:{mw}}} {{u:{uw}}}%s {{c:{cw}}} {{b:{bw}}} {{d:}}' | ||
wide_fs_fs = ' {{n:>{nw}}} {{m:}} {{u:}} {{a:}} {{c:}} {{b:}} {{B:<{Bw}}} {{d:}}' | ||
wide_hdr_fs_fs = ' {{n:>{nw}}} {{m:{mw}}} {{u:{uw}}} {{a:{aw}}} {{c:{cw}}} {{b:{bw}}} {{B:{Bw}}} {{d:}}' | ||
|
||
async def get_rpc_data(self): | ||
|
||
msg_r('Getting unspent outputs...') | ||
addrs = await self.get_unspent_by_mmid(self.minconf) | ||
msg('done') | ||
|
||
amt0 = self.proto.coin_amt('0') | ||
self.total = sum((v['amt'] for v in addrs.values()), start=amt0 ) | ||
|
||
msg_r('Getting labels and associated addresses...') | ||
for label,addr in await self.get_addr_label_pairs(): | ||
if label and label.mmid not in addrs: | ||
addrs[label.mmid] = { | ||
'addr': addr, | ||
'amt': amt0, | ||
'recvd': amt0, | ||
'confs': 0, | ||
'lbl': label } | ||
msg('done') | ||
|
||
msg_r('Getting received funds data...') | ||
# args: 1:minconf, 2:include_empty, 3:include_watchonly, 4:include_immature_coinbase | ||
for d in await self.rpc.call( 'listreceivedbylabel', 1, False, True ): | ||
label = get_obj( TwLabel, proto=self.proto, text=d['label'] ) | ||
if label: | ||
assert label.mmid in addrs, f'{label.mmid!r} not found in addrlist!' | ||
addrs[label.mmid]['recvd'] = d['amount'] | ||
addrs[label.mmid]['confs'] = d['confirmations'] | ||
msg('done') | ||
|
||
return addrs |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# mmgen = Multi-Mode GENerator, a command-line cryptocurrency wallet | ||
# Copyright (C)2013-2022 The MMGen Project <mmgen@tuta.io> | ||
# Licensed under the GNU General Public License, Version 3: | ||
# https://www.gnu.org/licenses | ||
# Public project repositories: | ||
# https://github.com/mmgen/mmgen | ||
# https://gitlab.com/mmgen/mmgen | ||
|
||
""" | ||
proto.eth.tw.addresses: Ethereum base protocol tracking wallet address list class | ||
""" | ||
|
||
from ....tw.addresses import TwAddresses | ||
from ....tw.ctl import TrackingWallet | ||
from ....addr import CoinAddr | ||
from .common import EthereumTwCommon | ||
|
||
class EthereumTwAddresses(TwAddresses,EthereumTwCommon): | ||
|
||
has_age = False | ||
prompt = """ | ||
Sort options: [a]mt, [M]mid, [r]everse | ||
Filters: show [E]mpty addrs, all [L]abels | ||
View/Print: pager [v]iew, [w]ide view, [p]rint | ||
Actions: [q]uit, r[e]draw, [D]elete address, add [l]abel: | ||
""" | ||
key_mappings = { | ||
'a':'s_amt', | ||
'M':'s_twmmid', | ||
'r':'d_reverse', | ||
'e':'d_redraw', | ||
'E':'d_showempty', | ||
'L':'d_all_labels', | ||
'q':'a_quit', | ||
'l':'a_comment_add', | ||
'D':'a_addr_delete', | ||
'v':'a_view', | ||
'w':'a_view_detail', | ||
'p':'a_print_detail' } | ||
|
||
squeezed_fs_fs = ' {{n:>{nw}}} {{m:}}%s {{c:}} {{b:}}' | ||
squeezed_hdr_fs_fs = ' {{n:>{nw}}} {{m:{mw}}}%s {{c:{cw}}} {{b:{bw}}}' | ||
wide_fs_fs = ' {{n:>{nw}}} {{m:}} {{a:}} {{c:}} {{b:}}' | ||
wide_hdr_fs_fs = ' {{n:>{nw}}} {{m:{mw}}} {{a:{aw}}} {{c:{cw}}} {{b:{bw}}}' | ||
|
||
async def get_rpc_data(self): | ||
|
||
amt0 = self.proto.coin_amt('0') | ||
self.total = amt0 | ||
self.minconf = None | ||
addrs = {} | ||
|
||
for label,addr in await self.get_addr_label_pairs(): | ||
bal = await self.wallet.get_balance(addr) | ||
addrs[label.mmid] = { | ||
'addr': addr, | ||
'amt': bal, | ||
'recvd': amt0, | ||
'confs': 0, | ||
'lbl': label } | ||
self.total += bal | ||
|
||
return addrs | ||
|
||
class EthereumTokenTwAddresses(EthereumTwAddresses): | ||
pass |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.