Browse Source

class rename: TrackingWallet -> TwCtl

The MMGen Project 2 years ago
parent
commit
21b8084b37

+ 2 - 2
mmgen/main_addrimport.py

@@ -133,11 +133,11 @@ def check_opts(tw):
 	return batch,rescan
 	return batch,rescan
 
 
 async def main():
 async def main():
-	from .tw.ctl import TrackingWallet
+	from .tw.ctl import TwCtl
 	if opt.token_addr:
 	if opt.token_addr:
 		proto.tokensym = 'foo' # hack to trigger 'Token' in proto.base_proto_subclass()
 		proto.tokensym = 'foo' # hack to trigger 'Token' in proto.base_proto_subclass()
 
 
-	tw = await TrackingWallet(
+	tw = await TwCtl(
 		proto      = proto,
 		proto      = proto,
 		token_addr = opt.token_addr,
 		token_addr = opt.token_addr,
 		mode       = 'i' )
 		mode       = 'i' )

+ 2 - 2
mmgen/main_txbump.py

@@ -130,11 +130,11 @@ async def main():
 	kl = get_keylist(orig_tx.proto,opt)
 	kl = get_keylist(orig_tx.proto,opt)
 	sign_and_send = bool(seed_files or kl or kal)
 	sign_and_send = bool(seed_files or kl or kal)
 
 
-	from .tw.ctl import TrackingWallet
+	from .tw.ctl import TwCtl
 	tx = await BumpTX(
 	tx = await BumpTX(
 		data = orig_tx.__dict__,
 		data = orig_tx.__dict__,
 		send = sign_and_send,
 		send = sign_and_send,
-		tw   = await TrackingWallet(orig_tx.proto) if orig_tx.proto.tokensym else None )
+		tw   = await TwCtl(orig_tx.proto) if orig_tx.proto.tokensym else None )
 
 
 	from .rpc import rpc_init
 	from .rpc import rpc_init
 	tx.rpc = await rpc_init(tx.proto)
 	tx.rpc = await rpc_init(tx.proto)

+ 1 - 1
mmgen/main_txcreate.py

@@ -82,7 +82,7 @@ async def main():
 	proto = init_proto_from_opts(need_amt=True)
 	proto = init_proto_from_opts(need_amt=True)
 
 
 	from .tx import NewTX
 	from .tx import NewTX
-	from .tw.ctl import TrackingWallet
+	from .tw.ctl import TwCtl
 	tx1 = await NewTX(proto=proto)
 	tx1 = await NewTX(proto=proto)
 
 
 	from .rpc import rpc_init
 	from .rpc import rpc_init

+ 1 - 1
mmgen/main_txdo.py

@@ -122,7 +122,7 @@ from .tx.sign import *
 seed_files = get_seed_files(opt,cmd_args)
 seed_files = get_seed_files(opt,cmd_args)
 
 
 async def main():
 async def main():
-	from .tw.ctl import TrackingWallet
+	from .tw.ctl import TwCtl
 
 
 	from .protocol import init_proto_from_opts
 	from .protocol import init_proto_from_opts
 	proto = init_proto_from_opts(need_amt=True)
 	proto = init_proto_from_opts(need_amt=True)

+ 2 - 2
mmgen/proto/btc/tw/ctl.py

@@ -13,10 +13,10 @@ proto.btc.tw.ctl: Bitcoin base protocol tracking wallet control class
 """
 """
 
 
 from ....globalvars import g
 from ....globalvars import g
-from ....tw.ctl import TrackingWallet,write_mode
+from ....tw.ctl import TwCtl,write_mode
 from ....util import msg,msg_r,rmsg,vmsg,die,suf,fmt_list
 from ....util import msg,msg_r,rmsg,vmsg,die,suf,fmt_list
 
 
-class BitcoinTrackingWallet(TrackingWallet):
+class BitcoinTwCtl(TwCtl):
 
 
 	def init_empty(self):
 	def init_empty(self):
 		self.data = { 'coin': self.proto.coin, 'addresses': {} }
 		self.data = { 'coin': self.proto.coin, 'addresses': {} }

+ 2 - 2
mmgen/proto/eth/addrdata.py

@@ -33,10 +33,10 @@ class EthereumTwAddrData(TwAddrData):
 	}
 	}
 
 
 	async def get_tw_data(self,wallet=None):
 	async def get_tw_data(self,wallet=None):
-		from ...tw.ctl import TrackingWallet
+		from ...tw.ctl import TwCtl
 		from ...util import vmsg
 		from ...util import vmsg
 		vmsg('Getting address data from tracking wallet')
 		vmsg('Getting address data from tracking wallet')
-		tw = (wallet or await TrackingWallet(self.proto)).mmid_ordered_dict
+		tw = (wallet or await TwCtl(self.proto)).mmid_ordered_dict
 		# emulate the output of RPC 'listaccounts' and 'getaddressesbyaccount'
 		# emulate the output of RPC 'listaccounts' and 'getaddressesbyaccount'
 		return [(mmid+' '+d['comment'],[d['addr']]) for mmid,d in list(tw.items())]
 		return [(mmid+' '+d['comment'],[d['addr']]) for mmid,d in list(tw.items())]
 
 

+ 1 - 1
mmgen/proto/eth/tw/addresses.py

@@ -13,7 +13,7 @@ proto.eth.tw.addresses: Ethereum base protocol tracking wallet address list clas
 """
 """
 
 
 from ....tw.addresses import TwAddresses
 from ....tw.addresses import TwAddresses
-from ....tw.ctl import TrackingWallet
+from ....tw.ctl import TwCtl
 from ....addr import CoinAddr
 from ....addr import CoinAddr
 from .view import EthereumTwView
 from .view import EthereumTwView
 from .rpc import EthereumTwRPC
 from .rpc import EthereumTwRPC

+ 2 - 2
mmgen/proto/eth/tw/bal.py

@@ -20,7 +20,7 @@
 proto.eth.twbal: Ethereum tracking wallet getbalance class
 proto.eth.twbal: Ethereum tracking wallet getbalance class
 """
 """
 
 
-from ....tw.ctl import TrackingWallet
+from ....tw.ctl import TwCtl
 from ....tw.bal import TwGetBalance
 from ....tw.bal import TwGetBalance
 
 
 class EthereumTwGetBalance(TwGetBalance):
 class EthereumTwGetBalance(TwGetBalance):
@@ -31,7 +31,7 @@ class EthereumTwGetBalance(TwGetBalance):
 	}
 	}
 
 
 	async def __init__(self,proto,*args,**kwargs):
 	async def __init__(self,proto,*args,**kwargs):
-		self.wallet = await TrackingWallet(proto,mode='w')
+		self.wallet = await TwCtl(proto,mode='w')
 		await super().__init__(proto,*args,**kwargs)
 		await super().__init__(proto,*args,**kwargs)
 
 
 	async def create_data(self):
 	async def create_data(self):

+ 4 - 4
mmgen/proto/eth/tw/ctl.py

@@ -21,12 +21,12 @@ proto.eth.twctl: Ethereum tracking wallet control class
 """
 """
 
 
 from ....util import msg,ymsg,die
 from ....util import msg,ymsg,die
-from ....tw.ctl import TrackingWallet,write_mode
+from ....tw.ctl import TwCtl,write_mode
 from ....addr import is_coin_addr,is_mmgen_id
 from ....addr import is_coin_addr,is_mmgen_id
 from ....amt import ETHAmt
 from ....amt import ETHAmt
 from ..contract import Token,TokenResolve
 from ..contract import Token,TokenResolve
 
 
-class EthereumTrackingWallet(TrackingWallet):
+class EthereumTwCtl(TwCtl):
 
 
 	caps = ('batch',)
 	caps = ('batch',)
 	data_key = 'accounts'
 	data_key = 'accounts'
@@ -166,7 +166,7 @@ class EthereumTrackingWallet(TrackingWallet):
 	def mmid_ordered_dict(self):
 	def mmid_ordered_dict(self):
 		return dict((x['mmid'],{'addr':x['addr'],'comment':x['comment']}) for x in self.sorted_list)
 		return dict((x['mmid'],{'addr':x['addr'],'comment':x['comment']}) for x in self.sorted_list)
 
 
-class EthereumTokenTrackingWallet(EthereumTrackingWallet):
+class EthereumTokenTwCtl(EthereumTwCtl):
 
 
 	desc = 'Ethereum token tracking wallet'
 	desc = 'Ethereum token tracking wallet'
 	decimals = None
 	decimals = None
@@ -183,7 +183,7 @@ class EthereumTokenTrackingWallet(EthereumTrackingWallet):
 			if not is_coin_addr(proto,token_addr):
 			if not is_coin_addr(proto,token_addr):
 				die( 'InvalidTokenAddress', f'{token_addr!r}: invalid token address' )
 				die( 'InvalidTokenAddress', f'{token_addr!r}: invalid token address' )
 		else:
 		else:
-			assert token_addr == None,'EthereumTokenTrackingWallet_chk1'
+			assert token_addr == None,'EthereumTokenTwCtl_chk1'
 			token_addr = await self.sym2addr(proto.tokensym) # returns None on failure
 			token_addr = await self.sym2addr(proto.tokensym) # returns None on failure
 			if not is_coin_addr(proto,token_addr):
 			if not is_coin_addr(proto,token_addr):
 				die( 'UnrecognizedTokenSymbol', f'Specified token {proto.tokensym!r} could not be resolved!' )
 				die( 'UnrecognizedTokenSymbol', f'Specified token {proto.tokensym!r} could not be resolved!' )

+ 1 - 1
mmgen/proto/eth/tw/rpc.py

@@ -12,7 +12,7 @@
 proto.eth.tw.rpc: Ethereum base protocol tracking wallet RPC class
 proto.eth.tw.rpc: Ethereum base protocol tracking wallet RPC class
 """
 """
 
 
-from ....tw.ctl import TrackingWallet
+from ....tw.ctl import TwCtl
 from ....addr import CoinAddr
 from ....addr import CoinAddr
 from ....tw.shared import TwLabel
 from ....tw.shared import TwLabel
 from ....tw.rpc import TwRPC
 from ....tw.rpc import TwRPC

+ 2 - 2
mmgen/proto/eth/tx/new.py

@@ -20,7 +20,7 @@ from ....opts import opt
 from ....obj import Int,ETHNonce,MMGenTxID,Str,HexStr
 from ....obj import Int,ETHNonce,MMGenTxID,Str,HexStr
 from ....amt import ETHAmt
 from ....amt import ETHAmt
 from ....util import msg,is_int,is_hex_str,make_chksum_6
 from ....util import msg,is_int,is_hex_str,make_chksum_6
-from ....tw.ctl import TrackingWallet
+from ....tw.ctl import TwCtl
 from ....addr import is_mmgen_id,is_coin_addr
 from ....addr import is_mmgen_id,is_coin_addr
 from ..contract import Token
 from ..contract import Token
 
 
@@ -144,7 +144,7 @@ class New(Base,TxBase.New):
 	async def get_cmdline_input_addrs(self):
 	async def get_cmdline_input_addrs(self):
 		ret = []
 		ret = []
 		if opt.inputs:
 		if opt.inputs:
-			data_root = (await TrackingWallet(self.proto)).data_root # must create new instance here
+			data_root = (await TwCtl(self.proto)).data_root # must create new instance here
 			errmsg = 'Address {!r} not in tracking wallet'
 			errmsg = 'Address {!r} not in tracking wallet'
 			for addr in opt.inputs.split(','):
 			for addr in opt.inputs.split(','):
 				if is_mmgen_id(self.proto,addr):
 				if is_mmgen_id(self.proto,addr):

+ 10 - 10
mmgen/tool/rpc.py

@@ -140,8 +140,8 @@ class tool_cmd(tool_cmd_base):
 
 
 	async def add_label(self,mmgen_or_coin_addr:str,label:str):
 	async def add_label(self,mmgen_or_coin_addr:str,label:str):
 		"add descriptive label for address in tracking wallet"
 		"add descriptive label for address in tracking wallet"
-		from ..tw.ctl import TrackingWallet
-		return await (await TrackingWallet(self.proto,mode='w')).set_comment(mmgen_or_coin_addr,label)
+		from ..tw.ctl import TwCtl
+		return await (await TwCtl(self.proto,mode='w')).set_comment(mmgen_or_coin_addr,label)
 
 
 	async def remove_label(self,mmgen_or_coin_addr:str):
 	async def remove_label(self,mmgen_or_coin_addr:str):
 		"remove descriptive label for address in tracking wallet"
 		"remove descriptive label for address in tracking wallet"
@@ -150,9 +150,9 @@ class tool_cmd(tool_cmd_base):
 
 
 	async def remove_address(self,mmgen_or_coin_addr:str):
 	async def remove_address(self,mmgen_or_coin_addr:str):
 		"remove an address from tracking wallet"
 		"remove an address from tracking wallet"
-		from ..tw.ctl import TrackingWallet
+		from ..tw.ctl import TwCtl
 		# returns None on failure:
 		# returns None on failure:
-		ret = await (await TrackingWallet(self.proto,mode='w')).remove_address(mmgen_or_coin_addr)
+		ret = await (await TwCtl(self.proto,mode='w')).remove_address(mmgen_or_coin_addr)
 		if ret:
 		if ret:
 			from ..util import msg
 			from ..util import msg
 			msg(f'Address {ret!r} deleted from tracking wallet')
 			msg(f'Address {ret!r} deleted from tracking wallet')
@@ -160,8 +160,8 @@ class tool_cmd(tool_cmd_base):
 
 
 	async def resolve_address(self,mmgen_or_coin_addr:str):
 	async def resolve_address(self,mmgen_or_coin_addr:str):
 		"resolve an MMGen address in the tracking wallet to a coin address or vice-versa"
 		"resolve an MMGen address in the tracking wallet to a coin address or vice-versa"
-		from ..tw.ctl import TrackingWallet
-		ret = await (await TrackingWallet(self.proto,mode='w')).resolve_address( mmgen_or_coin_addr )
+		from ..tw.ctl import TwCtl
+		ret = await (await TwCtl(self.proto,mode='w')).resolve_address( mmgen_or_coin_addr )
 		if ret:
 		if ret:
 			from ..util import Msg
 			from ..util import Msg
 			from ..addr import is_coin_addr
 			from ..addr import is_coin_addr
@@ -171,8 +171,8 @@ class tool_cmd(tool_cmd_base):
 
 
 	async def rescan_address(self,mmgen_or_coin_addr:str):
 	async def rescan_address(self,mmgen_or_coin_addr:str):
 		"rescan an address in the tracking wallet to update its balance"
 		"rescan an address in the tracking wallet to update its balance"
-		from ..tw.ctl import TrackingWallet
-		return await (await TrackingWallet(self.proto,mode='w')).rescan_address( mmgen_or_coin_addr )
+		from ..tw.ctl import TwCtl
+		return await (await TwCtl(self.proto,mode='w')).rescan_address( mmgen_or_coin_addr )
 
 
 	async def rescan_blockchain(self,
 	async def rescan_blockchain(self,
 			start_block: int = None,
 			start_block: int = None,
@@ -186,8 +186,8 @@ class tool_cmd(tool_cmd_base):
 		  using Ctrl-C.  An interrupted rescan may be resumed using the ‘start_block’
 		  using Ctrl-C.  An interrupted rescan may be resumed using the ‘start_block’
 		  parameter.
 		  parameter.
 		"""
 		"""
-		from ..tw.ctl import TrackingWallet
-		ret = await (await TrackingWallet(self.proto,mode='w')).rescan_blockchain(start_block,stop_block)
+		from ..tw.ctl import TwCtl
+		ret = await (await TwCtl(self.proto,mode='w')).rescan_blockchain(start_block,stop_block)
 		return True
 		return True
 
 
 	async def twexport(self,include_amts=True,pretty=False):
 	async def twexport(self,include_amts=True,pretty=False):

+ 5 - 5
mmgen/tw/ctl.py

@@ -34,7 +34,7 @@ from .shared import TwMMGenID,TwLabel
 
 
 addr_info = namedtuple('addr_info',['twmmid','coinaddr'])
 addr_info = namedtuple('addr_info',['twmmid','coinaddr'])
 
 
-# decorator for TrackingWallet
+# decorator for TwCtl
 def write_mode(orig_func):
 def write_mode(orig_func):
 	def f(self,*args,**kwargs):
 	def f(self,*args,**kwargs):
 		if self.mode != 'w':
 		if self.mode != 'w':
@@ -45,7 +45,7 @@ def write_mode(orig_func):
 		return orig_func(self,*args,**kwargs)
 		return orig_func(self,*args,**kwargs)
 	return f
 	return f
 
 
-class TrackingWallet(MMGenObject,metaclass=AsyncInit):
+class TwCtl(MMGenObject,metaclass=AsyncInit):
 
 
 	caps = ('rescan','batch')
 	caps = ('rescan','batch')
 	data_key = 'addresses'
 	data_key = 'addresses'
@@ -122,9 +122,9 @@ class TrackingWallet(MMGenObject,metaclass=AsyncInit):
 
 
 	def __del__(self):
 	def __del__(self):
 		"""
 		"""
-		TrackingWallet instances opened in write or import mode must be explicitly destroyed
-		with 'del twctl', 'del twuo.wallet' and the like to ensure the instance is deleted and
-		wallet is written before global vars are destroyed by the interpreter at shutdown.
+		TwCtl instances opened in write or import mode must be explicitly destroyed with 'del
+		twuo.twctl' and the like to ensure the instance is deleted and wallet is written before
+		global vars are destroyed by the interpreter at shutdown.
 
 
 		Not that this code can only be debugged by examining the program output, as exceptions
 		Not that this code can only be debugged by examining the program output, as exceptions
 		are ignored within __del__():
 		are ignored within __del__():

+ 3 - 3
mmgen/tw/json.py

@@ -19,7 +19,7 @@ from ..util import msg,ymsg,fmt,die,make_timestamp,make_chksum_8,compare_or_die
 from ..base_obj import AsyncInit
 from ..base_obj import AsyncInit
 from ..objmethods import MMGenObject
 from ..objmethods import MMGenObject
 from ..rpc import json_encoder
 from ..rpc import json_encoder
-from .ctl import TrackingWallet
+from .ctl import TwCtl
 
 
 class TwJSON:
 class TwJSON:
 
 
@@ -66,7 +66,7 @@ class TwJSON:
 
 
 			super().__init__(proto)
 			super().__init__(proto)
 
 
-			self.tw = await TrackingWallet( proto, mode='i', rpc_ignore_wallet=True )
+			self.tw = await TwCtl( proto, mode='i', rpc_ignore_wallet=True )
 
 
 			def check_network(data):
 			def check_network(data):
 				coin,network = data['network'].split('_')
 				coin,network = data['network'].split('_')
@@ -132,7 +132,7 @@ class TwJSON:
 			if not include_amts:
 			if not include_amts:
 				self.keys.remove('amount')
 				self.keys.remove('amount')
 
 
-			self.tw = await TrackingWallet( proto )
+			self.tw = await TwCtl( proto )
 
 
 			self.entries = await self.get_entries()
 			self.entries = await self.get_entries()
 
 

+ 2 - 2
mmgen/tw/view.py

@@ -119,8 +119,8 @@ class TwView(MMGenObject,metaclass=AsyncInit):
 		self.proto = proto
 		self.proto = proto
 		self.rpc = await rpc_init(proto)
 		self.rpc = await rpc_init(proto)
 		if self.has_wallet:
 		if self.has_wallet:
-			from .ctl import TrackingWallet
-			self.wallet = await TrackingWallet(proto,mode='w')
+			from .ctl import TwCtl
+			self.wallet = await TwCtl(proto,mode='w')
 		self.amt_keys = {'amt':'iwidth','amt2':'iwidth2'} if self.has_amt2 else {'amt':'iwidth'}
 		self.amt_keys = {'amt':'iwidth','amt2':'iwidth2'} if self.has_amt2 else {'amt':'iwidth'}
 
 
 	@property
 	@property

+ 2 - 2
mmgen/tx/__init__.py

@@ -71,8 +71,8 @@ async def _get_obj_async( _clsname, _modname, *args, **kwargs ):
 	# No tracking wallet required for the Unsigned and Signed(data=unsigned.__dict__) classes used
 	# No tracking wallet required for the Unsigned and Signed(data=unsigned.__dict__) classes used
 	# during signing.
 	# during signing.
 	if proto and proto.tokensym and clsname in ('New','OnlineSigned'):
 	if proto and proto.tokensym and clsname in ('New','OnlineSigned'):
-		from ..tw.ctl import TrackingWallet
-		kwargs['tw'] = await TrackingWallet(proto)
+		from ..tw.ctl import TwCtl
+		kwargs['tw'] = await TwCtl(proto)
 
 
 	return _base_proto_subclass( clsname, modname, proto )(*args,**kwargs)
 	return _base_proto_subclass( clsname, modname, proto )(*args,**kwargs)
 
 

+ 4 - 4
test/test_py_d/ts_ethdev.py

@@ -1322,8 +1322,8 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
 
 
 	async def twmove(self):
 	async def twmove(self):
 		self.spawn('',msg_only=True)
 		self.spawn('',msg_only=True)
-		from mmgen.tw.ctl import TrackingWallet
-		tw = await TrackingWallet(self.proto)
+		from mmgen.tw.ctl import TwCtl
+		tw = await TwCtl(self.proto)
 		imsg(f'Moving tracking wallet')
 		imsg(f'Moving tracking wallet')
 		bakfile = tw.tw_fn + '.bak.json'
 		bakfile = tw.tw_fn + '.bak.json'
 		if os.path.exists(bakfile):
 		if os.path.exists(bakfile):
@@ -1354,8 +1354,8 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
 
 
 	async def twcompare(self):
 	async def twcompare(self):
 		self.spawn('',msg_only=True)
 		self.spawn('',msg_only=True)
-		from mmgen.tw.ctl import TrackingWallet
-		tw = await TrackingWallet(self.proto)
+		from mmgen.tw.ctl import TwCtl
+		tw = await TwCtl(self.proto)
 		fn = tw.tw_fn
 		fn = tw.tw_fn
 		imsg(f'Comparing imported tracking wallet with original')
 		imsg(f'Comparing imported tracking wallet with original')
 		data = [json.dumps(json.loads(read_from_file(f)),sort_keys=True) for f in (fn,fn+'.bak.json')]
 		data = [json.dumps(json.loads(read_from_file(f)),sort_keys=True) for f in (fn,fn+'.bak.json')]