From 20af051e4367ed63289d08395381dc079474c89a Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 15 Nov 2025 09:50:21 +0000 Subject: [PATCH] cfg: `regtest_user` -> `test_user` --- mmgen/cfg.py | 29 +++++++++++++++++------------ mmgen/proto/btc/rpc/local.py | 6 +++--- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/mmgen/cfg.py b/mmgen/cfg.py index a2c97932..db48c248 100755 --- a/mmgen/cfg.py +++ b/mmgen/cfg.py @@ -231,7 +231,7 @@ class Config(Lockable): bob = False alice = False carol = False - regtest_user = '' + test_user = '' # altcoin: cashaddr = True @@ -441,11 +441,15 @@ class Config(Lockable): location of wallet and other data - same as data_dir_root for mainnet """ if not hasattr(self, '_data_dir'): - self._data_dir = os.path.normpath(os.path.join(*{ - 'regtest': (self.data_dir_root, 'regtest', (self.regtest_user or 'none')), - 'testnet': (self.data_dir_root, 'testnet'), - 'mainnet': (self.data_dir_root,), - }[self.network])) + def make_path(): + match self.network: + case 'mainnet': + return (self.data_dir_root, self.test_user) + case 'testnet': + return (self.data_dir_root, 'testnet', self.test_user) + case 'regtest': + return (self.data_dir_root, 'regtest', (self.test_user or 'none')) + self._data_dir = os.path.normpath(os.path.join(*make_path())) return self._data_dir def __init__( @@ -547,15 +551,16 @@ class Config(Lockable): if opts_data and 'sets' in opts_data: self._set_opts_data_sets_opts(opts_data) - if self.regtest or self.bob or self.alice or self.carol or gc.prog_name == f'{gc.proj_id}-regtest': - self.network = 'regtest' - self.regtest_user = 'bob' if self.bob else 'alice' if self.alice else 'carol' if self.carol else None - else: - self.network = 'testnet' if self.testnet else 'mainnet' - self.coin = self.coin.upper() self.token = self.token.upper() if self.token else None + if self.regtest or self.bob or self.alice or self.carol or gc.prog_name == f'{gc.proj_id}-regtest': + if self.coin != 'XMR': + self.network = 'regtest' + self.test_user = 'bob' if self.bob else 'alice' if self.alice else 'carol' if self.carol else '' + else: + self.network = 'testnet' if self.testnet else 'mainnet' + if 'usage' in self._uopts: # requires self.coin import importlib getattr(importlib.import_module(UserOpts.help_pkg), 'usage')(self) # exits diff --git a/mmgen/proto/btc/rpc/local.py b/mmgen/proto/btc/rpc/local.py index 2df2f98a..b08aa497 100755 --- a/mmgen/proto/btc/rpc/local.py +++ b/mmgen/proto/btc/rpc/local.py @@ -213,7 +213,7 @@ class BitcoinRPCClient(RPCClient, metaclass=AsyncInit): self.proto = proto self.daemon = daemon self.call_sigs = getattr(CallSigs, daemon.id)(cfg, self) - self.twname = TrackingWalletName(cfg.regtest_user or proto.tw_name or cfg.tw_name or self.dfl_twname) + self.twname = TrackingWalletName(cfg.test_user or proto.tw_name or cfg.tw_name or self.dfl_twname) super().__init__( cfg = cfg, @@ -287,7 +287,7 @@ class BitcoinRPCClient(RPCClient, metaclass=AsyncInit): await self.check_or_create_daemon_wallet() # for regtest, wallet_path must remain '/' until Carol’s user wallet has been created - if self.chain != 'regtest' or cfg.regtest_user: + if self.chain != 'regtest' or cfg.test_user: self.wallet_path = f'/wallet/{self.twname}' @property @@ -334,7 +334,7 @@ class BitcoinRPCClient(RPCClient, metaclass=AsyncInit): async def check_or_create_daemon_wallet(self): - if self.chain == 'regtest' and self.cfg.regtest_user != 'carol': + if self.chain == 'regtest' and self.cfg.test_user != 'carol': return loaded_wnames = await self.call('listwallets')