Browse Source

CoinProtocol.core_coins -> g.core_coins

The MMGen Project 3 years ago
parent
commit
a19275e280
4 changed files with 9 additions and 4 deletions
  1. 2 1
      mmgen/altcoin.py
  2. 3 0
      mmgen/globalvars.py
  3. 1 1
      mmgen/opts.py
  4. 3 2
      mmgen/protocol.py

+ 2 - 1
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')

+ 3 - 0
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',

+ 1 - 1
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)

+ 3 - 2
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: