tool_api: warn on low trust-level altcoins
This commit is contained in:
parent
4493a7b10f
commit
4fc344dfe5
3 changed files with 20 additions and 17 deletions
|
|
@ -168,21 +168,6 @@ def override_from_env():
|
||||||
gname = name[(6,14)[disable]:].lower()
|
gname = name[(6,14)[disable]:].lower()
|
||||||
setattr(g,gname,set_for_type(val,getattr(g,gname),name,disable))
|
setattr(g,gname,set_for_type(val,getattr(g,gname),name,disable))
|
||||||
|
|
||||||
def warn_altcoins(trust_level):
|
|
||||||
if trust_level > 3:
|
|
||||||
return
|
|
||||||
tl = (red('COMPLETELY UNTESTED'),red('LOW'),yellow('MEDIUM'),green('HIGH'))
|
|
||||||
m = """
|
|
||||||
Support for coin '{}' is EXPERIMENTAL. The {pn} project assumes no
|
|
||||||
responsibility for any loss of funds you may incur.
|
|
||||||
This coin's {pn} testing status: {}
|
|
||||||
Are you sure you want to continue?
|
|
||||||
""".strip().format(g.coin,tl[trust_level],pn=g.proj_name)
|
|
||||||
if g.test_suite:
|
|
||||||
qmsg(m); return
|
|
||||||
if not keypress_confirm(m,default_yes=True):
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
def common_opts_code(s):
|
def common_opts_code(s):
|
||||||
from mmgen.protocol import CoinProtocol
|
from mmgen.protocol import CoinProtocol
|
||||||
return s.format(
|
return s.format(
|
||||||
|
|
@ -345,7 +330,7 @@ def init(opts_data,add_opts=[],opt_filter=None,parse_only=False):
|
||||||
opt.verbose,opt.quiet = (True,None)
|
opt.verbose,opt.quiet = (True,None)
|
||||||
if g.debug_opts: opt_postproc_debug()
|
if g.debug_opts: opt_postproc_debug()
|
||||||
|
|
||||||
warn_altcoins(altcoin_trust_level)
|
warn_altcoins(g.coin,altcoin_trust_level)
|
||||||
|
|
||||||
# We don't need this data anymore
|
# We don't need this data anymore
|
||||||
del mmgen.share.Opts, opts_data
|
del mmgen.share.Opts, opts_data
|
||||||
|
|
|
||||||
|
|
@ -1139,7 +1139,8 @@ class tool_api(
|
||||||
Valid choices for network: 'mainnet','testnet','regtest'
|
Valid choices for network: 'mainnet','testnet','regtest'
|
||||||
"""
|
"""
|
||||||
from mmgen.protocol import init_coin,init_genonly_altcoins
|
from mmgen.protocol import init_coin,init_genonly_altcoins
|
||||||
init_genonly_altcoins(coinsym)
|
altcoin_trust_level = init_genonly_altcoins(coinsym)
|
||||||
|
warn_altcoins(coinsym,altcoin_trust_level)
|
||||||
if network == 'regtest':
|
if network == 'regtest':
|
||||||
g.regtest = True
|
g.regtest = True
|
||||||
return init_coin(coinsym,{'mainnet':False,'testnet':True,'regtest':True}[network])
|
return init_coin(coinsym,{'mainnet':False,'testnet':True,'regtest':True}[network])
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,23 @@ def pp_msg(d):
|
||||||
CUR_HIDE = '\033[?25l'
|
CUR_HIDE = '\033[?25l'
|
||||||
CUR_SHOW = '\033[?25h'
|
CUR_SHOW = '\033[?25h'
|
||||||
|
|
||||||
|
def warn_altcoins(coinsym,trust_level):
|
||||||
|
if trust_level > 3:
|
||||||
|
return
|
||||||
|
|
||||||
|
tl = (red('COMPLETELY UNTESTED'),red('LOW'),yellow('MEDIUM'),green('HIGH'))
|
||||||
|
m = """
|
||||||
|
Support for coin '{}' is EXPERIMENTAL. The {pn} project assumes no
|
||||||
|
responsibility for any loss of funds you may incur.
|
||||||
|
This coin's {pn} testing status: {}
|
||||||
|
Are you sure you want to continue?
|
||||||
|
""".strip().format(coinsym.upper(),tl[trust_level],pn=g.proj_name)
|
||||||
|
|
||||||
|
if g.test_suite:
|
||||||
|
qmsg(m); return
|
||||||
|
if not keypress_confirm(m,default_yes=True):
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
def set_for_type(val,refval,desc,invert_bool=False,src=None):
|
def set_for_type(val,refval,desc,invert_bool=False,src=None):
|
||||||
src_str = (''," in '{}'".format(src))[bool(src)]
|
src_str = (''," in '{}'".format(src))[bool(src)]
|
||||||
if type(refval) == bool:
|
if type(refval) == bool:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue