CoinProtocol.core_coins -> g.core_coins

This commit is contained in:
The MMGen Project 2022-01-27 11:08:08 +00:00
commit a19275e280
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 9 additions and 4 deletions

View file

@ -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')

View file

@ -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',

View file

@ -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)

View file

@ -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: