Browse Source

relocate modules: txfile -> tx.file, txsign -> tx.sign

The MMGen Project 3 years ago
parent
commit
24cdd98037

+ 1 - 1
mmgen/main_autosign.py

@@ -138,7 +138,7 @@ if opt.mnemonic_fmt:
 
 from .wallet import Wallet
 from .tx import UnsignedTX
-from .txsign import txsign
+from .tx.sign import txsign
 from .protocol import init_proto
 from .rpc import rpc_init
 

+ 1 - 1
mmgen/main_txbump.py

@@ -107,7 +107,7 @@ from .fileutil import check_infile
 check_infile(tx_file)
 
 from .tx import *
-from .txsign import *
+from .tx.sign import *
 
 seed_files = get_seed_files(opt,cmd_args) if (cmd_args or opt.send) else None
 

+ 1 - 1
mmgen/main_txdo.py

@@ -117,7 +117,7 @@ FMT CODES:
 cmd_args = opts.init(opts_data)
 
 from .tx import NewTX,OnlineSignedTX
-from .txsign import *
+from .tx.sign import *
 
 seed_files = get_seed_files(opt,cmd_args)
 

+ 1 - 1
mmgen/main_txsign.py

@@ -108,7 +108,7 @@ for i in infiles:
 if not opt.info and not opt.terse_info:
 	do_license_msg(immed=True)
 
-from .txsign import *
+from .tx.sign import *
 
 tx_files   = get_tx_files(opt,infiles)
 seed_files = get_seed_files(opt,infiles)

+ 1 - 1
mmgen/tx/__init__.py

@@ -32,7 +32,7 @@ def _get_cls_info(clsname,modname,args,kwargs):
 	elif 'data' in kwargs:
 		proto = kwargs['data']['proto']
 	elif 'filename' in kwargs:
-		from ..txfile import MMGenTxFile
+		from .file import MMGenTxFile
 		proto = MMGenTxFile.get_proto( kwargs['filename'], quiet_open=True )
 	elif clsname == 'Base':
 		proto = None

+ 2 - 2
mmgen/tx/completed.py

@@ -31,7 +31,7 @@ class Completed(Base):
 			self.__dict__ = data
 			self.name = type(self).__name__
 		else:
-			from ..txfile import MMGenTxFile
+			from .file import MMGenTxFile
 			MMGenTxFile(self).parse(filename,quiet_open=quiet_open)
 
 			self.check_serialized_integrity()
@@ -49,7 +49,7 @@ class Completed(Base):
 
 	@property
 	def file(self):
-		from ..txfile import MMGenTxFile
+		from .file import MMGenTxFile
 		return MMGenTxFile(self)
 
 	@classmethod

+ 9 - 9
mmgen/txfile.py → mmgen/tx/file.py

@@ -17,11 +17,11 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 """
-txfile.py:  Transaction file operations for the MMGen suite
+tx.file:  Transaction file operations for the MMGen suite
 """
 
-from .common import *
-from .obj import MMGenObject,HexStr,MMGenTxID,CoinTxID,MMGenTxLabel
+from ..common import *
+from ..obj import MMGenObject,HexStr,MMGenTxID,CoinTxID,MMGenTxLabel
 
 class MMGenTxFile(MMGenObject):
 
@@ -54,7 +54,7 @@ class MMGenTxFile(MMGenObject):
 			}[desc]
 			return io_list( parent=tx, data=[io(tx.proto,**e) for e in d] )
 
-		from .fileutil import get_data_from_file
+		from ..fileutil import get_data_from_file
 		tx_data = get_data_from_file(infile,tx.desc+' data',quiet=quiet_open)
 
 		try:
@@ -78,7 +78,7 @@ class MMGenTxFile(MMGenObject):
 				c = tx_data.pop(-1)
 				if c != '-':
 					desc = 'encoded comment (not base58)'
-					from .baseconv import baseconv
+					from ..baseconv import baseconv
 					comment = baseconv('b58').tobytes(c).decode()
 					assert comment != False,'invalid comment'
 					desc = 'comment'
@@ -100,7 +100,7 @@ class MMGenTxFile(MMGenObject):
 			desc = 'chain token in metadata'
 			tx.chain = metadata.pop(0).lower() if len(metadata) == 5 else 'mainnet'
 
-			from .protocol import CoinProtocol,init_proto
+			from ..protocol import CoinProtocol,init_proto
 			network = CoinProtocol.Base.chain_name_to_network(coin,tx.chain)
 
 			desc = 'initialization of protocol'
@@ -175,7 +175,7 @@ class MMGenTxFile(MMGenObject):
 		]
 
 		if tx.label:
-			from .baseconv import baseconv
+			from ..baseconv import baseconv
 			lines.append(baseconv('b58').frombytes(tx.label.encode(),tostr=True))
 
 		if tx.coin_txid:
@@ -205,7 +205,7 @@ class MMGenTxFile(MMGenObject):
 		if not self.fmt_data:
 			self.fmt_data = self.format()
 
-		from .fileutil import write_data_to_file
+		from ..fileutil import write_data_to_file
 		write_data_to_file(
 			outfile               = self.filename,
 			data                  = self.fmt_data,
@@ -217,7 +217,7 @@ class MMGenTxFile(MMGenObject):
 
 	@classmethod
 	def get_proto(cls,filename,quiet_open=False):
-		from .tx import BaseTX
+		from . import BaseTX
 		tmp_tx = BaseTX()
 		cls(tmp_tx).parse(filename,metadata_only=True,quiet_open=quiet_open)
 		return tmp_tx.proto

+ 9 - 9
mmgen/txsign.py → mmgen/tx/sign.py

@@ -17,14 +17,14 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 """
-txsign: Sign a transaction generated by 'mmgen-txcreate'
+tx.sign: Sign a transaction generated by 'mmgen-txcreate'
 """
 
-from .common import *
-from .obj import MMGenList
-from .addr import MMGenAddrType
-from .addrlist import AddrIdxList,KeyAddrList
-from .wallet import Wallet,get_wallet_extensions,get_wallet_cls
+from ..common import *
+from ..obj import MMGenList
+from ..addr import MMGenAddrType
+from ..addrlist import AddrIdxList,KeyAddrList
+from ..wallet import Wallet,get_wallet_extensions,get_wallet_cls
 
 saved_seeds = {}
 
@@ -109,7 +109,7 @@ def _pop_matching_fns(args,cmplist): # strips found args
 	return list(reversed([args.pop(args.index(a)) for a in reversed(args) if get_extension(a) in cmplist]))
 
 def get_tx_files(opt,args):
-	from .tx.unsigned import Unsigned
+	from .unsigned import Unsigned
 	ret = _pop_matching_fns(args,[Unsigned.ext])
 	if not ret:
 		die(1,'You must specify a raw transaction file!')
@@ -118,7 +118,7 @@ def get_tx_files(opt,args):
 def get_seed_files(opt,args):
 	# favor unencrypted seed sources first, as they don't require passwords
 	ret = _pop_matching_fns( args, get_wallet_extensions('unenc') )
-	from .filename import find_file_in_dir
+	from ..filename import find_file_in_dir
 	wf = find_file_in_dir(get_wallet_cls('mmgen'),g.data_dir) # Make this the first encrypted ss in the list
 	if wf:
 		ret.append(wf)
@@ -134,7 +134,7 @@ def get_keyaddrlist(proto,opt):
 
 def get_keylist(proto,opt):
 	if opt.keys_from_file:
-		from .fileutil import get_lines_from_file
+		from ..fileutil import get_lines_from_file
 		return get_lines_from_file(opt.keys_from_file,'key-address data',trim_comments=True)
 	return None
 

+ 1 - 1
test/test_py_d/ts_ref_altcoin.py

@@ -86,7 +86,7 @@ class TestSuiteRefAltcoin(TestSuiteRef,TestSuiteBase):
 		"""
 		self.write_to_tmpfile(pwfile,dfl_wpasswd)
 		passfile = joinpath(self.tmpdir,pwfile)
-		from mmgen.txfile import MMGenTxFile
+		from mmgen.tx.file import MMGenTxFile
 		src = TestSuiteRef.sources['ref_tx_file']
 		for coin,files in src.items():
 			if coin == 'mm1':

+ 1 - 1
test/unit_tests_d/ut_tx.py

@@ -7,7 +7,7 @@ import re
 
 from mmgen.common import *
 from mmgen.tx import NewTX,CompletedTX
-from mmgen.txfile import MMGenTxFile
+from mmgen.tx.file import MMGenTxFile
 from mmgen.daemon import CoinDaemon
 from mmgen.protocol import init_proto