From 02a71f7443a6c5da875850846f1099268cf92f60 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Tue, 11 May 2021 10:22:09 +0000 Subject: [PATCH] mmgen-regtest: add 'start' command --- mmgen/main_regtest.py | 1 + mmgen/regtest.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/mmgen/main_regtest.py b/mmgen/main_regtest.py index 6cb95e08..52656ef2 100755 --- a/mmgen/main_regtest.py +++ b/mmgen/main_regtest.py @@ -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 diff --git a/mmgen/regtest.py b/mmgen/regtest.py index 45a8c55b..cd433cfc 100755 --- a/mmgen/regtest.py +++ b/mmgen/regtest.py @@ -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)