Browse Source

a few minor cleanups

The MMGen Project 5 years ago
parent
commit
6eaf01f243
4 changed files with 13 additions and 10 deletions
  1. 6 5
      mmgen/altcoin.py
  2. 2 2
      mmgen/devtools.py
  3. 4 2
      mmgen/protocol.py
  4. 1 1
      test/gentest.py

+ 6 - 5
mmgen/altcoin.py

@@ -43,7 +43,8 @@ class CoinInfo(object):
 	coin_constants['mainnet'] = (
 #   Trust levels: -1=disabled 0=untested 1=low 2=med 3=high 4=very high (no warn) 5=unconditional
 #   Trust levels apply to key/address generation only.
-#   Fork coins must be disabled here to prevent generation from incorrect sub-seed.
+#   Non core-coin fork coins (i.e. BCG) must be disabled here to prevent generation from
+#   incorrect scrambled seed.
 	ce('Bitcoin',               'BTC',     0x80,   (0x00,'1'),       (0x05,'3'),       True, -1),
 	ce('BitcoinSegwit2X',       'B2X',     0x80,   (0x00,'1'),       (0x05,'3'),       True, -1),
 	ce('BitcoinGold',           'BCG',     0x80,   (0x00,'1'),       (0x05,'3'),       True, -1),
@@ -579,9 +580,6 @@ class CoinInfo(object):
 				'DASH', # only compressed
 				'BTC','LTC','VIA','FTC','DOGE','MEC',
 				'JBS','MZC','RIC','DFC','FAI','ARG','ZEC','DCR'),
-			'ethkey': ('ETH','ETC'),
-			'zcash-mini': ('ZEC',),
-			'moneropy': ('XMR',),
 			'keyconv': (
 				# broken: PIVX
 				'42','AC','AIB','ANC','ARS','ATMOS','AUR','BLK','BQC','BTC','TEST','BTCD','CCC','CCN','CDN',
@@ -590,7 +588,10 @@ class CoinInfo(object):
 				'IXC','JBS','LBRY','LEAF','LTC','MMC','MONA','MUE','MYRIAD','MZC','NEOS','NLG','NMC','NVC',
 				'NYAN','OK','OMC','PIGGY','PINK','PKB','PND','POT','PPC','PTC','PTS','QTUM','RBY','RDD',
 				'RIC','SCA','SDC','SKC','SPR','START','SXC','TPC','UIS','UNO','VIA','VPN','VTC','WDC','WKC',
-				'WUBS', 'XC', 'XPM', 'YAC', 'ZOOM', 'ZRC')
+				'WUBS', 'XC', 'XPM', 'YAC', 'ZOOM', 'ZRC'),
+			'ethkey': ('ETH','ETC'),
+			'zcash-mini': ('ZEC',),
+			'moneropy': ('XMR',),
 		},
 		'testnet': {
 			'pycoin': {

+ 2 - 2
mmgen/devtools.py

@@ -27,10 +27,10 @@ if os.getenv('MMGEN_DEBUG') or os.getenv('MMGEN_TEST_SUITE') or os.getenv('MMGEN
 	def Pexit(*args):
 		pexit(*args,out=sys.stdout)
 
-	def print_stack_trace(message):
+	def print_stack_trace(message=None):
 		tb1 = traceback.extract_stack()
 		tb2 = [t for t in tb1 if t.filename[:1] != '<'][2:-2]
-		sys.stderr.write('STACK TRACE {}:\n'.format(message))
+		sys.stderr.write('STACK TRACE {}:\n'.format(message or '(unnamed)'))
 		fs = '    {}:{}: in {}:\n        {}\n'
 		for t in tb2:
 			fn = re.sub(r'^\./','',os.path.relpath(t.filename))

+ 4 - 2
mmgen/protocol.py

@@ -479,7 +479,9 @@ class CoinProtocol(MMGenObject):
 def init_genonly_altcoins(usr_coin=None):
 	"""
 	Initialize altcoin protocol class or classes for current network.
-	If usr_coin is None, initializes all supported altcoins for current network.
+	If usr_coin is a core coin, initialization is skipped.
+	If usr_coin has a trust level of -1, an exception is raised.
+	If usr_coin is None, initializes all coins for current network with trust level >-1.
 	Returns trust_level of usr_coin, or 0 (untrusted) if usr_coin is None.
 	"""
 	from mmgen.altcoin import CoinInfo as ci
@@ -491,7 +493,7 @@ def init_genonly_altcoins(usr_coin=None):
 			data[network] = ci.get_supported_coins(network)
 		trust_level = 0
 	else:
-		if usr_coin.lower() in CoinProtocol.coins:
+		if usr_coin.lower() in CoinProtocol.core_coins: # core coin, so return immediately
 			return CoinProtocol.coins[usr_coin.lower()].trust_level
 		for network in networks:
 			data[network] = (ci.get_entry(usr_coin,network),)

+ 1 - 1
test/gentest.py

@@ -32,7 +32,7 @@ from mmgen.common import *
 rounds = 100
 opts_data = {
 	'text': {
-		'desc': 'Test address generation of the MMGen suite in various ways',
+		'desc': 'Test key/address generation of the MMGen suite in various ways',
 		'usage':'[options] [spec] [rounds | dump file]',
 		'options': """
 -h, --help       Print this help message