mmgen-regtest: add 'start' command

This commit is contained in:
The MMGen Project 2021-05-11 10:22:09 +00:00
commit 02a71f7443
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
2 changed files with 13 additions and 2 deletions

View file

@ -41,6 +41,7 @@ opts_data = {
AVAILABLE COMMANDS
setup - set up Bob and Alice regtest mode
start - start the regtest coin daemon
stop - stop the regtest coin daemon
bob - switch to Bob's wallet, starting daemon if necessary
alice - switch to Alice's wallet, starting daemon if necessary

View file

@ -46,7 +46,7 @@ class MMGenRegtest(MMGenObject):
rpc_password = 'hodltothemoon'
users = ('bob','alice','miner')
coins = ('btc','bch','ltc')
usr_cmds = ('setup','generate','send','stop', 'state', 'balances','mempool','cli')
usr_cmds = ('setup','generate','send','start','stop', 'state', 'balances','mempool','cli')
def __init__(self,coin):
self.coin = coin.lower()
@ -136,8 +136,18 @@ class MMGenRegtest(MMGenObject):
rpc = await rpc_init(self.proto,backend=None,daemon=self.d)
return await rpc.call(*args,wallet=wallet)
async def start(self):
if self.d.state == 'stopped':
await self.start_daemon(silent=False)
else:
msg(f'{g.coin} regtest daemon already started')
async def stop(self):
await self.rpc_call('stop')
if self.d.state == 'stopped':
msg(f'{g.coin} regtest daemon already stopped')
else:
msg(f'Stopping {g.coin} regtest daemon')
await self.rpc_call('stop',start_daemon=False)
def state(self):
msg(self.d.state)