From 6eaf01f243b2230f79a212330862190fc1c1b447 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Wed, 6 Nov 2019 17:34:26 +0000 Subject: [PATCH] a few minor cleanups --- mmgen/altcoin.py | 11 ++++++----- mmgen/devtools.py | 4 ++-- mmgen/protocol.py | 6 ++++-- test/gentest.py | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/mmgen/altcoin.py b/mmgen/altcoin.py index 0c20fd64..c12747b5 100755 --- a/mmgen/altcoin.py +++ b/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': { diff --git a/mmgen/devtools.py b/mmgen/devtools.py index bd8d7e9c..18f40f7f 100755 --- a/mmgen/devtools.py +++ b/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)) diff --git a/mmgen/protocol.py b/mmgen/protocol.py index d66826dc..83ce786c 100755 --- a/mmgen/protocol.py +++ b/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),) diff --git a/test/gentest.py b/test/gentest.py index 57c77191..eecf0feb 100755 --- a/test/gentest.py +++ b/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