Browse Source

whitespace, variable renames (8 files)

The MMGen Project 2 months ago
parent
commit
3749ff4d7e

+ 2 - 2
mmgen/cfg.py

@@ -847,7 +847,7 @@ def check_opts(cfg): # Raises exception if any check fails
 
 		out_fmt = in_fmt
 
-		def hidden_incog_input_params():
+		def hidden_incog_params():
 			a = val.rsplit(',', 1) # permit comma in filename
 			if len(a) != 2:
 				display_opt(name, val)
@@ -879,7 +879,7 @@ def check_opts(cfg): # Raises exception if any check fails
 					die('UserOptError',
 						f'Option {fmt_opt(name)} conflicts with option {fmt_opt(key2)}={val2}')
 
-		hidden_incog_output_params = hidden_incog_input_params
+		hidden_incog_output_params = hidden_incog_input_params = hidden_incog_params
 
 		def subseeds():
 			from .subseed import SubSeedIdxRange

+ 6 - 2
mmgen/tool/wallet.py

@@ -68,8 +68,12 @@ class tool_cmd(tool_cmd_base):
 			wallet = ''):
 		"list the Seed IDs of the shares resulting from a split of default or specified wallet"
 		self.cfg._set_quiet(True)
-		return Wallet(self.cfg, fn=self._get_seed_file(wallet)).seed.split(
-			share_count, id_str=id_str, master_idx=master_share).format()
+		return Wallet(
+			self.cfg,
+			fn = self._get_seed_file(wallet)).seed.split(
+				share_count,
+				id_str = id_str,
+				master_idx = master_share).format()
 
 	def gen_key(self, mmgen_addr: str, *, wallet=''):
 		"generate a single WIF key for specified MMGen address from default or specified wallet"

+ 2 - 2
mmgen/wallet/mmgen.py

@@ -141,7 +141,7 @@ class wallet(wallet):
 		lmin, _, lmax = sorted(baseconv('b58').seedlen_map_rev) # 22, 33, 44
 		for i, key in (4, 'salt'), (5, 'enc_seed'):
 			l = lines[i].split(' ')
-			chk = l.pop(0)
+			chksum = l.pop(0)
 			b58_val = ''.join(l)
 
 			if len(b58_val) < lmin or len(b58_val) > lmax:
@@ -149,7 +149,7 @@ class wallet(wallet):
 				return False
 
 			if not self.cfg._util.compare_chksums(
-					chk,
+					chksum,
 					key,
 					make_chksum_6(b58_val),
 					'computed checksum',

+ 18 - 16
mmgen/wallet/mmhex.py

@@ -23,39 +23,41 @@ class wallet(wallet):
 	desc = 'hexadecimal seed data with checksum'
 
 	def _format(self):
-		h = self.seed.data.hex()
-		self.ssdata.chksum = make_chksum_6(h)
-		self.fmt_data = f'{self.ssdata.chksum} {split_into_cols(4, h)}\n'
+		seed_hex = self.seed.data.hex()
+		self.ssdata.chksum = make_chksum_6(seed_hex)
+		self.fmt_data = f'{self.ssdata.chksum} {split_into_cols(4, seed_hex)}\n'
 
 	def _deformat(self):
-		desc = self.desc
 		d = self.fmt_data.split()
 		try:
 			d[1]
-			chk, hstr = d[0], ''.join(d[1:])
+			chksum, hex_str = d[0], ''.join(d[1:])
 		except:
-			msg(f'{self.fmt_data.strip()!r}: invalid {desc}')
+			msg(f'{self.fmt_data.strip()!r}: invalid {self.desc}')
 			return False
 
-		if not len(hstr)*4 in Seed.lens:
-			msg(f'Invalid data length ({len(hstr)}) in {desc}')
+		if not len(hex_str) * 4 in Seed.lens:
+			msg(f'Invalid data length ({len(hex_str)}) in {self.desc}')
 			return False
 
-		if not is_chksum_6(chk):
-			msg(f'{chk!r}: invalid checksum format in {desc}')
+		if not is_chksum_6(chksum):
+			msg(f'{chksum!r}: invalid checksum format in {self.desc}')
 			return False
 
-		if not is_hex_str(hstr):
-			msg(f'{hstr!r}: not a hexadecimal string, in {desc}')
+		if not is_hex_str(hex_str):
+			msg(f'{hex_str!r}: not a hexadecimal string, in {self.desc}')
 			return False
 
-		self.cfg._util.vmsg_r(f'Validating {desc} checksum...')
+		self.cfg._util.vmsg_r(f'Validating {self.desc} checksum...')
 
-		if not self.cfg._util.compare_chksums(chk, 'file', make_chksum_6(hstr), 'computed', verbose=True):
+		if not self.cfg._util.compare_chksums(
+				chksum, 'file',
+				make_chksum_6(hex_str), 'computed',
+				verbose = True):
 			return False
 
-		self.seed = Seed(self.cfg, seed_bin=bytes.fromhex(hstr))
-		self.ssdata.chksum = chk
+		self.seed = Seed(self.cfg, seed_bin=bytes.fromhex(hex_str))
+		self.ssdata.chksum = chksum
 
 		self.check_usr_seed_len()
 

+ 13 - 10
mmgen/wallet/seed.py

@@ -38,30 +38,33 @@ class wallet(wallet):
 			msg(f'Invalid data length ({len(ld)}) in {desc}')
 			return False
 
-		a, b = ld[0], ''.join(ld[1:])
+		chksum, b58_seed = ld[0], ''.join(ld[1:])
 
-		if not is_chksum_6(a):
-			msg(f'{a!r}: invalid checksum format in {desc}')
+		if not is_chksum_6(chksum):
+			msg(f'{chksum!r}: invalid checksum format in {desc}')
 			return False
 
-		if not is_b58_str(b):
-			msg(f'{b!r}: not a base 58 string, in {desc}')
+		if not is_b58_str(b58_seed):
+			msg(f'{b58_seed!r}: not a base 58 string, in {desc}')
 			return False
 
 		self.cfg._util.vmsg_r(f'Validating {desc} checksum...')
 
-		if not self.cfg._util.compare_chksums(a, 'file', make_chksum_6(b), 'computed', verbose=True):
+		if not self.cfg._util.compare_chksums(
+				chksum, 'file',
+				make_chksum_6(b58_seed), 'computed',
+				verbose = True):
 			return False
 
-		ret = baseconv('b58').tobytes(b, pad='seed')
+		ret = baseconv('b58').tobytes(b58_seed, pad='seed')
 
 		if ret is False:
-			msg(f'Invalid base-58 encoded seed: {b}')
+			msg(f'Invalid base-58 encoded seed: {b58_seed}')
 			return False
 
 		self.seed = Seed(self.cfg, seed_bin=ret)
-		self.ssdata.chksum = a
-		self.ssdata.b58seed = b
+		self.ssdata.chksum = chksum
+		self.ssdata.b58seed = b58_seed
 
 		self.check_usr_seed_len()
 

+ 1 - 1
test/cmdtest_d/ethdev.py

@@ -875,7 +875,7 @@ class CmdTestEthdev(CmdTestEthdevMethods, CmdTestBase, CmdTestShared):
 
 		def init_genesis(fn):
 			cmd = f'{d.exec_fn} init --datadir {d.datadir} {fn}'
-			cp = run( cmd.split(), stdout=PIPE, stderr=PIPE)
+			cp = run(cmd.split(), stdout=PIPE, stderr=PIPE)
 			if cp.returncode:
 				die(1, cp.stderr.decode())
 

+ 2 - 2
test/cmdtest_d/input.py

@@ -479,8 +479,8 @@ class CmdTestInput(CmdTestBase):
 				t.expect(wcls.user_entropy_prompt, 'n')
 		if not usr_rand:
 			sid_chk = 'FE3C6545'
-			sid = t.expect_getend(f'Valid {wcls.desc} for Seed ID')
-			sid = strip_ansi_escapes(sid.split(',')[0])
+			sid = strip_ansi_escapes(
+				t.expect_getend(f'Valid {wcls.desc} for Seed ID').split(',')[0])
 			assert sid_chk in sid, f'Seed ID mismatch! {sid_chk} not found in {sid}'
 		t.expect('to confirm: ', 'YES\n')
 		return t

+ 1 - 1
test/modtest_d/baseconv.py

@@ -197,7 +197,7 @@ class unit_test:
 			for (hexstr, pad), ret_chk in data:
 				if type(pad) is int:
 					pad = len(hexstr)
-				ret = baseconv(base).tohex( ret_chk.split() if base == 'mmgen' else ret_chk, pad=pad )
+				ret = baseconv(base).tohex(ret_chk.split() if base == 'mmgen' else ret_chk, pad=pad)
 				if pad is None:
 					assert int(ret, 16) == int(hexstr, 16), rerr.format(int(ret, 16), int(hexstr, 16))
 				else: