tw.view.TwView: add __init__() method
This commit is contained in:
parent
d513035aad
commit
e237cf0e39
4 changed files with 23 additions and 28 deletions
|
|
@ -13,16 +13,14 @@ tw.addresses: Tracking wallet listaddresses class for the MMGen suite
|
|||
"""
|
||||
|
||||
from ..util import suf
|
||||
from ..base_obj import AsyncInit
|
||||
from ..objmethods import MMGenObject
|
||||
from ..obj import MMGenListItem,ImmutableAttr,ListItemAttr,TwComment,NonNegativeInt
|
||||
from ..rpc import rpc_init
|
||||
from ..addr import CoinAddr,MMGenID
|
||||
from ..color import red,green
|
||||
from .view import TwView
|
||||
from .shared import TwMMGenID
|
||||
|
||||
class TwAddresses(TwView,metaclass=AsyncInit):
|
||||
class TwAddresses(TwView):
|
||||
|
||||
hdr_lbl = 'tracking wallet addresses'
|
||||
desc = 'address list'
|
||||
|
|
@ -76,14 +74,11 @@ class TwAddresses(TwView,metaclass=AsyncInit):
|
|||
def __new__(cls,proto,*args,**kwargs):
|
||||
return MMGenObject.__new__(proto.base_proto_subclass(cls,'tw','addresses'))
|
||||
|
||||
async def __init__(self,proto,minconf=1,mmgen_addrs='',wallet=None,get_data=False):
|
||||
async def __init__(self,proto,minconf=1,mmgen_addrs='',get_data=False):
|
||||
|
||||
await super().__init__(proto)
|
||||
|
||||
self.proto = proto
|
||||
self.minconf = NonNegativeInt(minconf)
|
||||
self.rpc = await rpc_init(proto)
|
||||
|
||||
from .ctl import TrackingWallet
|
||||
self.wallet = wallet or await TrackingWallet(proto,mode='w')
|
||||
|
||||
if mmgen_addrs:
|
||||
a = mmgen_addrs.rsplit(':',1)
|
||||
|
|
|
|||
|
|
@ -13,13 +13,11 @@ tw.txhistory: Tracking wallet transaction history class for the MMGen suite
|
|||
"""
|
||||
|
||||
from ..util import fmt
|
||||
from ..base_obj import AsyncInit
|
||||
from ..objmethods import MMGenObject
|
||||
from ..rpc import rpc_init
|
||||
from ..obj import NonNegativeInt
|
||||
from .view import TwView
|
||||
|
||||
class TwTxHistory(TwView,metaclass=AsyncInit):
|
||||
class TwTxHistory(TwView):
|
||||
|
||||
class display_type(TwView.display_type):
|
||||
|
||||
|
|
@ -42,9 +40,8 @@ class TwTxHistory(TwView,metaclass=AsyncInit):
|
|||
filters = ('show_unconfirmed',)
|
||||
|
||||
async def __init__(self,proto,sinceblock=0):
|
||||
self.proto = proto
|
||||
self.rpc = await rpc_init(proto)
|
||||
self.sinceblock = NonNegativeIntInt( sinceblock if sinceblock >= 0 else self.rpc.blockcount + sinceblock )
|
||||
await super().__init__(proto)
|
||||
self.sinceblock = NonNegativeInt( sinceblock if sinceblock >= 0 else self.rpc.blockcount + sinceblock )
|
||||
|
||||
@property
|
||||
def no_rpcdata_errmsg(self):
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ tw.unspent: Tracking wallet unspent outputs class for the MMGen suite
|
|||
|
||||
from ..globalvars import g
|
||||
from ..util import msg,suf,fmt
|
||||
from ..base_obj import AsyncInit
|
||||
from ..objmethods import MMGenObject
|
||||
from ..obj import (
|
||||
ImmutableAttr,
|
||||
|
|
@ -33,11 +32,10 @@ from ..obj import (
|
|||
CoinTxID,
|
||||
NonNegativeInt )
|
||||
from ..addr import CoinAddr,MMGenID
|
||||
from ..rpc import rpc_init
|
||||
from .view import TwView
|
||||
from .shared import TwMMGenID,get_tw_label
|
||||
from .view import TwView
|
||||
|
||||
class TwUnspentOutputs(TwView,metaclass=AsyncInit):
|
||||
class TwUnspentOutputs(TwView):
|
||||
|
||||
class display_type(TwView.display_type):
|
||||
|
||||
|
|
@ -82,14 +80,10 @@ class TwUnspentOutputs(TwView,metaclass=AsyncInit):
|
|||
return self.proto.coin_amt(value)
|
||||
|
||||
async def __init__(self,proto,minconf=1,addrs=[]):
|
||||
self.proto = proto
|
||||
self.minconf = minconf
|
||||
self.addrs = addrs
|
||||
self.rpc = await rpc_init(proto)
|
||||
self.min_cols = g.min_screen_width
|
||||
|
||||
from .ctl import TrackingWallet
|
||||
self.wallet = await TrackingWallet(proto,mode='w')
|
||||
await super().__init__(proto)
|
||||
self.minconf = minconf
|
||||
self.addrs = addrs
|
||||
self.min_cols = g.min_screen_width
|
||||
|
||||
@property
|
||||
def total(self):
|
||||
|
|
|
|||
|
|
@ -28,9 +28,11 @@ from ..objmethods import Hilite,InitErrors,MMGenObject
|
|||
from ..obj import get_obj,MMGenIdx,MMGenList
|
||||
from ..color import nocolor,yellow,green,red,blue
|
||||
from ..util import msg,msg_r,fmt,die,capfirst,make_timestr
|
||||
from ..rpc import rpc_init
|
||||
from ..base_obj import AsyncInit
|
||||
|
||||
# base class for TwUnspentOutputs,TwAddresses,TwTxHistory:
|
||||
class TwView(MMGenObject):
|
||||
class TwView(MMGenObject,metaclass=AsyncInit):
|
||||
|
||||
class display_type:
|
||||
|
||||
|
|
@ -109,6 +111,13 @@ class TwView(MMGenObject):
|
|||
Please resize your screen to at least {} characters and hit any key:
|
||||
"""
|
||||
|
||||
async def __init__(self,proto):
|
||||
self.proto = proto
|
||||
self.rpc = await rpc_init(proto)
|
||||
if self.has_wallet:
|
||||
from .ctl import TrackingWallet
|
||||
self.wallet = await TrackingWallet(proto,mode='w')
|
||||
|
||||
@property
|
||||
def age_w(self):
|
||||
return self.age_col_params[self.age_fmt][0]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue