From e7d75ff60d9e1c0f74e83a713b717259a09632de Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 12 Nov 2022 13:34:40 +0000 Subject: [PATCH] minor cleanups --- mmgen/proto/btc/tw/ctl.py | 2 +- mmgen/proto/btc/tw/unspent.py | 2 +- mmgen/proto/eth/tw/unspent.py | 2 +- mmgen/tw/addresses.py | 2 +- mmgen/tw/ctl.py | 11 +++-------- mmgen/tw/txhistory.py | 2 +- mmgen/tw/unspent.py | 10 +++++----- mmgen/tw/view.py | 2 +- 8 files changed, 14 insertions(+), 19 deletions(-) diff --git a/mmgen/proto/btc/tw/ctl.py b/mmgen/proto/btc/tw/ctl.py index 41b0611b..dffe7f4d 100755 --- a/mmgen/proto/btc/tw/ctl.py +++ b/mmgen/proto/btc/tw/ctl.py @@ -9,7 +9,7 @@ # https://gitlab.com/mmgen/mmgen """ -proto.btc.twctl: Bitcoin base protocol tracking wallet control class +proto.btc.tw.ctl: Bitcoin base protocol tracking wallet control class """ from ....globalvars import g diff --git a/mmgen/proto/btc/tw/unspent.py b/mmgen/proto/btc/tw/unspent.py index cff2ee7d..247275c0 100755 --- a/mmgen/proto/btc/tw/unspent.py +++ b/mmgen/proto/btc/tw/unspent.py @@ -9,7 +9,7 @@ # https://gitlab.com/mmgen/mmgen """ -proto.btc.twuo: Bitcoin base protocol tracking wallet unspent outputs class +proto.btc.tw.unspent: Bitcoin base protocol tracking wallet unspent outputs class """ from ....tw.unspent import TwUnspentOutputs diff --git a/mmgen/proto/eth/tw/unspent.py b/mmgen/proto/eth/tw/unspent.py index ed0eef47..17f8c2ae 100755 --- a/mmgen/proto/eth/tw/unspent.py +++ b/mmgen/proto/eth/tw/unspent.py @@ -17,7 +17,7 @@ # along with this program. If not, see . """ -proto.eth.twuo: Ethereum tracking wallet unspent outputs class +proto.eth.tw.unspent: Ethereum tracking wallet unspent outputs class """ from ....tw.shared import TwLabel diff --git a/mmgen/tw/addresses.py b/mmgen/tw/addresses.py index 58fee555..8be7cc16 100755 --- a/mmgen/tw/addresses.py +++ b/mmgen/tw/addresses.py @@ -22,7 +22,7 @@ from ..color import red,green from .view import TwView from .shared import TwMMGenID -class TwAddresses(MMGenObject,TwView,metaclass=AsyncInit): +class TwAddresses(TwView,metaclass=AsyncInit): hdr_lbl = 'tracking wallet addresses' desc = 'address list' diff --git a/mmgen/tw/ctl.py b/mmgen/tw/ctl.py index d4b3e23b..c4f263bc 100755 --- a/mmgen/tw/ctl.py +++ b/mmgen/tw/ctl.py @@ -20,17 +20,11 @@ twctl: Tracking wallet control class for the MMGen suite """ -import asyncio,json +import json from collections import namedtuple from ..globalvars import g -from ..util import ( - msg, - msg_r, - qmsg, - dmsg, - suf, - die ) +from ..util import msg,msg_r,qmsg,dmsg,suf,die from ..base_obj import AsyncInit from ..objmethods import MMGenObject from ..obj import TwComment,get_obj @@ -329,6 +323,7 @@ class TrackingWallet(MMGenObject,metaclass=AsyncInit): msg(f'done\n{len(ret)} addresses imported') else: if gather: # this seems to provide little performance benefit + import asyncio await asyncio.gather(*(do_import(*d) for d in out)) else: for d in out: diff --git a/mmgen/tw/txhistory.py b/mmgen/tw/txhistory.py index b5a7dc95..42685480 100755 --- a/mmgen/tw/txhistory.py +++ b/mmgen/tw/txhistory.py @@ -21,7 +21,7 @@ from ..obj import CoinTxID,MMGenList,Int from ..rpc import rpc_init from .view import TwView -class TwTxHistory(MMGenObject,TwView,metaclass=AsyncInit): +class TwTxHistory(TwView,metaclass=AsyncInit): class display_type(TwView.display_type): diff --git a/mmgen/tw/unspent.py b/mmgen/tw/unspent.py index 1b0107c6..081d844e 100755 --- a/mmgen/tw/unspent.py +++ b/mmgen/tw/unspent.py @@ -17,7 +17,7 @@ # along with this program. If not, see . """ -twuo: Tracking wallet unspent outputs class for the MMGen suite +tw.unspent: Tracking wallet unspent outputs class for the MMGen suite """ from ..globalvars import g @@ -38,7 +38,7 @@ from ..rpc import rpc_init from .view import TwView from .shared import TwMMGenID,get_tw_label -class TwUnspentOutputs(MMGenObject,TwView,metaclass=AsyncInit): +class TwUnspentOutputs(TwView,metaclass=AsyncInit): class display_type(TwView.display_type): @@ -51,6 +51,7 @@ class TwUnspentOutputs(MMGenObject,TwView,metaclass=AsyncInit): def __new__(cls,proto,*args,**kwargs): return MMGenObject.__new__(proto.base_proto_subclass(cls,'tw','unspent')) + show_mmid = True txid_w = 64 no_rpcdata_errmsg = """ No spendable outputs found! Import addresses with balances into your @@ -84,7 +85,6 @@ class TwUnspentOutputs(MMGenObject,TwView,metaclass=AsyncInit): async def __init__(self,proto,minconf=1,addrs=[]): self.proto = proto - self.show_mmid = True self.minconf = minconf self.addrs = addrs self.rpc = await rpc_init(proto) @@ -178,7 +178,7 @@ class TwUnspentOutputs(MMGenObject,TwView,metaclass=AsyncInit): for n,d in enumerate(data): yield fs.format( - n = str(n+1)+')', + n = str(n+1) + ')', t = (CoinTxID.fmtc('|' + '.'*(cw.txid-1),color=color) if d.skip == 'txid' else d.txid.truncate(width=cw.txid,color=color)) if cw.txid else None, v = ' ' + d.vout.fmt(width=cw.vout-1,color=color) if cw.vout else None, @@ -201,7 +201,7 @@ class TwUnspentOutputs(MMGenObject,TwView,metaclass=AsyncInit): a = 'Address', m = 'MMGenID', A = 'Amt({})'.format(self.proto.dcoin), - B = 'Amt({})'.format(self.proto.coin) if cw.amt2 else None, + B = 'Amt({})'.format(self.proto.coin), b = 'Block', D = 'Date/Time', c = 'Comment' ).rstrip() diff --git a/mmgen/tw/view.py b/mmgen/tw/view.py index 75520978..6dd8bfe2 100755 --- a/mmgen/tw/view.py +++ b/mmgen/tw/view.py @@ -30,7 +30,7 @@ from ..color import nocolor,yellow,green,red,blue from ..util import msg,msg_r,fmt,die,capfirst,make_timestr # base class for TwUnspentOutputs,TwAddresses,TwTxHistory: -class TwView: +class TwView(MMGenObject): dates_set = False cols = None