From a19275e280384c201cc9a078ec42046fb4ca5d81 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Thu, 27 Jan 2022 11:08:08 +0000 Subject: [PATCH] CoinProtocol.core_coins -> g.core_coins --- mmgen/altcoin.py | 3 ++- mmgen/globalvars.py | 3 +++ mmgen/opts.py | 2 +- mmgen/protocol.py | 5 +++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/mmgen/altcoin.py b/mmgen/altcoin.py index 6374f52b..9c9f9d1d 100755 --- a/mmgen/altcoin.py +++ b/mmgen/altcoin.py @@ -434,9 +434,10 @@ class CoinInfo(object): @classmethod def verify_core_coin_data(cls,quiet=False,verbose=False): from .protocol import CoinProtocol,init_proto + from .globalvars import g for network in ('mainnet','testnet'): - for coin in CoinProtocol.core_coins: + for coin in g.core_coins: e = cls.get_entry(coin,network) if e: proto = init_proto(coin,testnet=network=='testnet') diff --git a/mmgen/globalvars.py b/mmgen/globalvars.py index 7bcb841d..c2fb3afa 100755 --- a/mmgen/globalvars.py +++ b/mmgen/globalvars.py @@ -142,6 +142,9 @@ class GlobalContext(Lockable): daemon_data_dir = '' # set by user daemon_id = '' + # must match CoinProtocol.coins + core_coins = ('btc','bch','ltc','eth','etc','zec','xmr') + # global var sets user opt: global_sets_opt = ( 'debug', diff --git a/mmgen/opts.py b/mmgen/opts.py index bb77b51b..44ffbce0 100755 --- a/mmgen/opts.py +++ b/mmgen/opts.py @@ -147,7 +147,7 @@ def override_globals_from_cfg_file(ucfg): for d in ucfg.get_lines(): if d.name in g.cfg_file_opts: ns = d.name.split('_') - if ns[0] in CoinProtocol.coins: + if ns[0] in g.core_coins: nse,tn = ( (ns[2:],ns[1]=='testnet') if len(ns) > 2 and ns[1] in ('mainnet','testnet') else (ns[1:],False) diff --git a/mmgen/protocol.py b/mmgen/protocol.py index 3871a31b..90a821c3 100755 --- a/mmgen/protocol.py +++ b/mmgen/protocol.py @@ -68,6 +68,8 @@ _nw = namedtuple('coin_networks',['mainnet','testnet','regtest']) class CoinProtocol(MMGenObject): proto_info = namedtuple('proto_info',['name','trust_level']) # trust levels: see altcoin.py + + # keys are mirrored in g.core_coins: coins = { 'btc': proto_info('Bitcoin', 5), 'bch': proto_info('BitcoinCash', 5), @@ -77,7 +79,6 @@ class CoinProtocol(MMGenObject): 'zec': proto_info('Zcash', 2), 'xmr': proto_info('Monero', 4) } - core_coins = tuple(coins) # coins may be added by init_genonly_altcoins(), so save class Base(MMGenObject): base_proto = None @@ -590,7 +591,7 @@ def init_genonly_altcoins(usr_coin=None,testnet=False): data[network] = CoinInfo.get_supported_coins(network) trust_level = 0 else: - if usr_coin.lower() in CoinProtocol.core_coins: # core coin, so return immediately + if usr_coin.lower() in g.core_coins: # core coin, so return immediately return CoinProtocol.coins[usr_coin.lower()].trust_level from .altcoin import CoinInfo for network in networks: