Browse Source

whitespace, minor cleanups

The MMGen Project 3 days ago
parent
commit
24a22e63e1

+ 13 - 13
mmgen/autosign.py

@@ -178,17 +178,17 @@ class Signable:
 
 	class transaction(base):
 		desc = 'non-automount transaction'
+		dir_name = 'tx_dir'
 		rawext = 'rawtx'
 		sigext = 'sigtx'
-		dir_name = 'tx_dir'
 		automount = False
 
 		async def sign(self, f):
 			from .tx import UnsignedTX
 			tx1 = UnsignedTX(
-					cfg       = self.cfg,
-					filename  = f,
-					automount = self.automount)
+				cfg       = self.cfg,
+				filename  = f,
+				automount = self.automount)
 			if tx1.proto.sign_mode == 'daemon':
 				from .rpc import rpc_init
 				tx1.rpc = await rpc_init(self.cfg, tx1.proto, ignore_wallet=True)
@@ -350,6 +350,13 @@ class Signable:
 			bmsg('\nAutosign summary:')
 			msg('\n'.join(s.get_info(indent='  ') for s in signables) + self.summary_footer)
 
+	class xmr_transaction(xmr_signable, automount_transaction):
+		desc = 'Monero non-compat transaction'
+		dir_name = 'xmr_tx_dir'
+		rawext = 'rawtx'
+		sigext = 'sigtx'
+		subext = 'subtx'
+
 		async def sign(self, f):
 			from . import xmrwallet
 			from .xmrwallet.file.tx import MoneroMMGenTX
@@ -363,18 +370,11 @@ class Signable:
 			tx2.write(ask_write=False)
 			return tx2
 
-	class xmr_transaction(xmr_signable, automount_transaction):
-		dir_name = 'xmr_tx_dir'
-		desc = 'Monero non-compat transaction'
-		rawext = 'rawtx'
-		sigext = 'sigtx'
-		subext = 'subtx'
-
 	class xmr_wallet_outputs_file(xmr_signable, base):
 		desc = 'Monero wallet outputs file'
+		dir_name = 'xmr_outputs_dir'
 		rawext = 'raw'
 		sigext = 'sig'
-		dir_name = 'xmr_outputs_dir'
 		clean_all = True
 		summary_footer = '\n'
 
@@ -400,9 +400,9 @@ class Signable:
 
 	class message(base):
 		desc = 'message file'
+		dir_name = 'msg_dir'
 		rawext = 'rawmsg.json'
 		sigext = 'sigmsg.json'
-		dir_name = 'msg_dir'
 		fail_msg = 'failed to sign or signed incompletely'
 
 		async def sign(self, f):

+ 5 - 2
mmgen/tx/new.py

@@ -385,16 +385,19 @@ class New(Base):
 			in_sum - out_sum if in_sum >= out_sum else out_sum - in_sum)
 
 	async def get_inputs(self, outputs_sum):
+
+		data = self.twuo.data
+
 		sel_nums = (
 			self.get_unspent_nums_from_inputs_opt if self.cfg.inputs else
 			self.get_unspent_nums_from_user
-		)(self.twuo.data)
+		)(data)
 
 		msg('Selected {}{}: {}'.format(
 			self.twuo.item_desc,
 			suf(sel_nums),
 			' '.join(str(n) for n in sel_nums)))
-		sel_unspent = MMGenList(self.twuo.data[i-1] for i in sel_nums)
+		sel_unspent = MMGenList(data[i-1] for i in sel_nums)
 
 		if not await self.precheck_sufficient_funds(
 				sum(s.amt for s in sel_unspent),

+ 3 - 4
mmgen/xmrwallet/ops/submit.py

@@ -100,9 +100,7 @@ class OpSubmit(OpWallet):
 			from ...util2 import format_elapsed_hr
 			msg(f'success\nRelay time: {format_elapsed_hr(t_start, rel_now=False, show_secs=True)}')
 
-		new_tx = MoneroMMGenTX.NewSubmitted(
-			cfg          = self.cfg,
-			_in_tx       = tx)
+		new_tx = MoneroMMGenTX.NewSubmitted(cfg=self.cfg, _in_tx=tx)
 
 		gmsg('\nOK')
 		new_tx.write(
@@ -120,7 +118,8 @@ class OpResubmit(OpSubmit):
 	def get_tx(self):
 		from ...autosign import Signable
 		fns = Signable.xmr_transaction(self.asi).get_submitted()
-		return sorted((MoneroMMGenTX.Submitted(self.cfg, Path(fn)) for fn in fns),
+		cls = MoneroMMGenTX.Submitted
+		return sorted((cls(self.cfg, Path(fn)) for fn in fns),
 			key = lambda x: getattr(x.data, 'submit_time', None) or x.data.create_time)[-1]
 
 class OpAbort(OpBase):

+ 5 - 5
mmgen/xmrwallet/ops/txview.py

@@ -16,7 +16,7 @@ from pathlib import Path
 
 from ...util import die
 
-from ..file.tx import MoneroMMGenTX
+from ..file.tx import MoneroMMGenTX as mtx
 
 from . import OpBase
 
@@ -34,12 +34,12 @@ class OpTxview(OpBase):
 
 		if self.cfg.autosign:
 			files = [f for f in self.asi.xmr_tx_dir.iterdir()
-						if f.name.endswith('.'+MoneroMMGenTX.Submitted.ext)]
+						if f.name.endswith('.' + mtx.Submitted.ext)]
 		else:
 			files = self.uargs.infile
 
 		txs = sorted(
-			(MoneroMMGenTX.View(self.cfg, Path(fn)) for fn in files),
+			(mtx.View(self.cfg, Path(fn)) for fn in files),
 				# old TX files have no ‘submit_time’ field:
 				key = lambda x: getattr(x.data, 'submit_time', None) or x.data.create_time)
 
@@ -58,7 +58,7 @@ class OpTxlist(OpTxview):
 	view_method = 'get_info_oneline'
 	add_nl = True
 	footer = '\n'
-	fixed_cols_w = MoneroMMGenTX.Base.oneline_fixed_cols_w
+	fixed_cols_w = mtx.Base.oneline_fixed_cols_w
 	min_addr_w = 10
 
 	@property
@@ -67,7 +67,7 @@ class OpTxlist(OpTxview):
 
 	@property
 	def col_hdr(self):
-		return MoneroMMGenTX.View.oneline_fs.format(
+		return mtx.View.oneline_fs.format(
 			a = 'Network',
 			b = 'Seed ID',
 			c = 'Submitted' if self.cfg.autosign else 'Date',

+ 3 - 3
mmgen/xmrwallet/rpc.py

@@ -20,7 +20,7 @@ from ..util import msg, msg_r, gmsg, gmsg_r, die
 from ..addr import CoinAddr
 
 from .include import gen_acct_addr_info, XMRWalletAddrSpec
-from .file.tx import MoneroMMGenTX
+from .file.tx import MoneroMMGenTX as mtx
 
 class MoneroWalletRPC:
 
@@ -32,8 +32,8 @@ class MoneroWalletRPC:
 		self.d = d
 		self.fn = parent.get_wallet_fn(d)
 		self.new_tx_cls = (
-			MoneroMMGenTX.NewUnsigned if self.cfg.watch_only else
-			MoneroMMGenTX.NewSigned)
+			mtx.NewUnsigned if self.cfg.watch_only else
+			mtx.NewSigned)
 
 	def open_wallet(self, desc=None, *, refresh=True):
 		add_desc = desc + ' ' if desc else self.parent.add_wallet_desc

+ 1 - 2
test/cmdtest_d/autosign.py

@@ -116,8 +116,7 @@ class CmdTestAutosignBase(CmdTestBase):
 					'test_suite_xmr_autosign': self.name == 'CmdTestXMRAutosign',
 					'test_suite_autosign_threaded': self.threaded,
 					'test_suite_root_pfx': None if self.live else self.tmpdir,
-					'online': subdir == 'online',
-				}))
+					'online': subdir == 'online'}))
 
 			if create_dirs and not self.live:
 				for k in ('mountpoint', 'shm_dir', 'wallet_dir'):

+ 6 - 1
test/cmdtest_d/xmr_autosign.py

@@ -17,7 +17,12 @@ import os, re, asyncio, json
 
 from mmgen.color import blue, cyan, brown
 
-from ..include.common import imsg, silence, end_silence, strip_ansi_escapes, read_from_file
+from ..include.common import (
+	imsg,
+	silence,
+	end_silence,
+	strip_ansi_escapes,
+	read_from_file)
 from .include.common import get_file_with_ext, cleanup_env
 
 from .xmrwallet import CmdTestXMRWallet

+ 2 - 2
test/cmdtest_d/xmrwallet.py

@@ -24,7 +24,7 @@ import sys, os, time, re, atexit, asyncio, shutil
 from subprocess import run, PIPE
 from collections import namedtuple
 
-from mmgen.util import capfirst, is_int, die, list_gen
+from mmgen.util import capfirst, is_int, die, suf, list_gen
 from mmgen.obj import MMGenRange
 from mmgen.amt import XMRAmt
 from mmgen.addrlist import ViewKeyAddrList, KeyAddrList, AddrIdxList
@@ -672,7 +672,7 @@ class CmdTestXMRWallet(CmdTestBase):
 	async def mine(self, nblks):
 		start_height = height = await self._get_height()
 		imsg(f'Height: {height}')
-		imsg_r(f'Mining {nblks} blocks...')
+		imsg_r(f'Mining {nblks} block{suf(nblks)}...')
 		await self.start_mining()
 		while height < start_height + nblks:
 			await asyncio.sleep(2)