cfg.py: add cmd_caps attr
This commit is contained in:
parent
f6843a3fcd
commit
5cc4a20724
8 changed files with 55 additions and 22 deletions
|
|
@ -292,7 +292,7 @@ def make_proto(e,testnet=False):
|
|||
'wif_ver_num': { 'std': num2hexstr(e.wif_ver_num) },
|
||||
'mmtypes': ('L','C','S') if e.has_segwit else ('L','C'),
|
||||
'dfl_mmtype': 'L',
|
||||
'mmcaps': ('key','addr'),
|
||||
'mmcaps': (),
|
||||
},
|
||||
)
|
||||
)
|
||||
|
|
|
|||
29
mmgen/cfg.py
29
mmgen/cfg.py
|
|
@ -40,6 +40,7 @@ class GlobalConstants(Lockable):
|
|||
_autolock = True
|
||||
|
||||
proj_name = 'MMGen'
|
||||
proj_id = 'mmgen'
|
||||
proj_url = 'https://github.com/mmgen/mmgen-wallet'
|
||||
author = 'The MMGen Project'
|
||||
email = '<mmgen@tuta.io>'
|
||||
|
|
@ -52,8 +53,34 @@ class GlobalConstants(Lockable):
|
|||
# must match CoinProtocol.coins
|
||||
core_coins = ('btc','bch','ltc','eth','etc','zec','xmr')
|
||||
|
||||
_cc = namedtuple('cmd_cap', ['proto', 'rpc', 'coin', 'caps', 'platforms'])
|
||||
cmd_caps_data = {
|
||||
'addrgen': _cc(True, False, None, [], 'lmw'),
|
||||
'addrimport': _cc(True, True, 'R', ['tw'], 'lmw'),
|
||||
'autosign': _cc(True, True, 'r', ['rpc'], 'lm'),
|
||||
'keygen': _cc(True, False, None, [], 'lmw'),
|
||||
'msg': _cc(True, True, 'R', ['msg'], 'lmw'),
|
||||
'passchg': _cc(False, False, None, [], 'lmw'),
|
||||
'passgen': _cc(False, False, None, [], 'lmw'),
|
||||
'regtest': _cc(True, True, 'b', ['tw'], 'lmw'),
|
||||
'seedjoin': _cc(False, False, None, [], 'lmw'),
|
||||
'seedsplit': _cc(False, False, None, [], 'lmw'),
|
||||
'subwalletgen': _cc(False, False, None, [], 'lmw'),
|
||||
'tool': _cc(True, True, None, [], 'lmw'),
|
||||
'txbump': _cc(True, True, 'R', ['tw'], 'lmw'),
|
||||
'txcreate': _cc(True, True, 'R', ['tw'], 'lmw'),
|
||||
'txdo': _cc(True, True, 'R', ['tw'], 'lmw'),
|
||||
'txsend': _cc(True, True, 'R', ['tw'], 'lmw'),
|
||||
'txsign': _cc(True, True, 'R', ['tw'], 'lmw'),
|
||||
'walletchk': _cc(False, False, None, [], 'lmw'),
|
||||
'walletconv': _cc(False, False, None, [], 'lmw'),
|
||||
'walletgen': _cc(False, False, None, [], 'lmw'),
|
||||
'xmrwallet': _cc(True, True, 'xmr', ['rpc'], 'lmw'),
|
||||
}
|
||||
|
||||
prog_name = os.path.basename(sys.argv[0])
|
||||
is_txprog = prog_name == 'mmgen-regtest' or prog_name.startswith('mmgen-tx')
|
||||
prog_id = prog_name.removeprefix(f'{proj_id}-')
|
||||
cmd_caps = cmd_caps_data.get(prog_id)
|
||||
|
||||
if sys.platform not in ('linux', 'win32', 'darwin'):
|
||||
die2(1,f'{sys.platform!r}: platform not supported by {proj_name}')
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp
|
|||
_finfo(478559,'00000000000000000019f112ec0a9982926f1258cdcc558dd7c3b7e5dc7fa148','BCH',False),
|
||||
]
|
||||
caps = ('rbf','segwit')
|
||||
mmcaps = ('key','addr','rpc_init','tx')
|
||||
mmcaps = ('rpc', 'rpc_init', 'tw', 'msg')
|
||||
base_proto = 'Bitcoin'
|
||||
base_proto_coin = 'BTC'
|
||||
base_coin = 'BTC'
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class mainnet(CoinProtocol.DummyWIF,CoinProtocol.Secp256k1):
|
|||
chain_names = ['ethereum','foundation']
|
||||
sign_mode = 'standalone'
|
||||
caps = ('token',)
|
||||
mmcaps = ('key','addr','rpc_init','tx')
|
||||
mmcaps = ('rpc', 'rpc_init', 'tw', 'msg')
|
||||
base_proto = 'Ethereum'
|
||||
base_proto_coin = 'ETH'
|
||||
base_coin = 'ETH'
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class mainnet(CoinProtocol.DummyWIF,CoinProtocol.Base):
|
|||
pubkey_type = 'monero' # required by DummyWIF
|
||||
avg_bdi = 120
|
||||
privkey_len = 32
|
||||
mmcaps = ('key','addr')
|
||||
mmcaps = ('rpc',)
|
||||
ignore_daemon_version = False
|
||||
coin_amt = 'XMRAmt'
|
||||
sign_mode = 'standalone'
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class mainnet(mainnet):
|
|||
wif_ver_num = { 'std': '80', 'zcash_z': 'ab36' }
|
||||
pubkey_types = ('std','zcash_z')
|
||||
mmtypes = ('L','C','Z')
|
||||
mmcaps = ('key','addr')
|
||||
mmcaps = ()
|
||||
dfl_mmtype = 'L'
|
||||
avg_bdi = 75
|
||||
|
||||
|
|
|
|||
|
|
@ -84,9 +84,11 @@ class CoinProtocol(MMGenObject):
|
|||
self.addr_fmt_to_ver_bytes = {v:k for k,v in self.addr_ver_bytes.items()}
|
||||
self.addr_ver_bytes_len = len(list(self.addr_ver_bytes)[0])
|
||||
|
||||
if 'tx' not in self.mmcaps and gc.is_txprog:
|
||||
from .util import die
|
||||
die(2,f'Command {gc.prog_name!r} not supported for coin {self.coin}')
|
||||
if gc.cmd_caps:
|
||||
for cap in gc.cmd_caps.caps:
|
||||
if cap not in self.mmcaps:
|
||||
from .util import die
|
||||
die(2, f'Command {gc.prog_name!r} not supported for coin {self.coin}')
|
||||
|
||||
if self.chain_names:
|
||||
self.chain_name = self.chain_names[0] # first chain name is default
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import sys, os, time
|
|||
from mmgen.util import ymsg
|
||||
from mmgen.cfg import gc
|
||||
|
||||
from ..include.common import cfg, proto_cmds
|
||||
from ..include.common import cfg
|
||||
from .ct_base import CmdTestBase
|
||||
|
||||
class CmdTestHelp(CmdTestBase):
|
||||
|
|
@ -83,25 +83,29 @@ class CmdTestHelp(CmdTestBase):
|
|||
t.skip_ok = True
|
||||
return t
|
||||
|
||||
def helpscreens(self,arg='--help',scripts=(),expect='USAGE:.*OPTIONS:',pager=True):
|
||||
def helpscreens(self, arg='--help', scripts=(), expect='USAGE:.*OPTIONS:', pager=True):
|
||||
|
||||
scripts = list(scripts) or [s.replace('mmgen-','') for s in os.listdir('cmds')]
|
||||
scripts = list(scripts or gc.cmd_caps_data)
|
||||
|
||||
if 'tx' not in self.proto.mmcaps:
|
||||
scripts = [s for s in scripts if not (s == 'regtest' or s.startswith('tx'))]
|
||||
def gen_skiplist():
|
||||
for script in scripts:
|
||||
d = gc.cmd_caps_data[script]
|
||||
for cap in d.caps:
|
||||
if cap not in self.proto.mmcaps:
|
||||
yield script
|
||||
break
|
||||
else:
|
||||
if sys.platform == 'win32' and 'w' not in d.platforms:
|
||||
yield script
|
||||
elif d.coin and len(d.coin) > 1 and self.proto.coin.lower() not in (d.coin, 'btc'):
|
||||
yield script
|
||||
|
||||
if 'xmrwallet' in scripts and (cfg.no_altcoin or not self.proto.coin in ('BTC','XMR')):
|
||||
scripts.remove('xmrwallet')
|
||||
|
||||
if 'autosign' in scripts and sys.platform == 'win32':
|
||||
scripts.remove('autosign')
|
||||
|
||||
for cmdname in sorted(scripts):
|
||||
for cmdname in sorted(set(scripts) - set(list(gen_skiplist()))):
|
||||
t = self.spawn(
|
||||
f'mmgen-{cmdname}',
|
||||
[arg],
|
||||
extra_desc = f'(mmgen-{cmdname})',
|
||||
no_passthru_opts = not cmdname in proto_cmds)
|
||||
no_passthru_opts = not gc.cmd_caps_data[cmdname].proto)
|
||||
t.expect(expect,regex=True)
|
||||
if pager and t.pexpect_spawn:
|
||||
time.sleep(0.2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue