From 9037c1950d177fffb644dd63e22da751bb358a5e Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Mon, 21 Sep 2026 10:30:51 +0000 Subject: [PATCH] protocol: new `network_datadir` property --- mmgen/help/help_notes.py | 2 +- mmgen/protocol.py | 10 ++++++++++ mmgen/tw/store.py | 13 +++---------- mmgen/xmrwallet/__init__.py | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/mmgen/help/help_notes.py b/mmgen/help/help_notes.py index d8c5cea0..46774d6f 100755 --- a/mmgen/help/help_notes.py +++ b/mmgen/help/help_notes.py @@ -81,7 +81,7 @@ class help_notes: from ..tw.ctl import TwCtl twctl_cls = self.proto.base_proto_subclass(TwCtl, 'tw.ctl') if hasattr(twctl_cls, 'get_tw_dir'): - return twctl_cls.get_tw_dir(self.cfg, self.proto) + return twctl_cls.get_tw_dir(self.proto) else: raise ValueError(f'protocol {self.proto.name} does not support tracking wallet with store') diff --git a/mmgen/protocol.py b/mmgen/protocol.py index de3e2163..6a10fd43 100755 --- a/mmgen/protocol.py +++ b/mmgen/protocol.py @@ -125,6 +125,16 @@ class CoinProtocol(MMGenObject): def set_cfg_opts(self): pass + @property + def network_datadir(self): + from pathlib import Path + return Path( + self.cfg.data_dir_root, + self.cfg.test_user, + 'altcoins', + self.coin.lower(), + ('' if self.network == 'mainnet' else self.network)) + @property def dcoin(self): return self.coin diff --git a/mmgen/tw/store.py b/mmgen/tw/store.py index b06376aa..2edcfe03 100755 --- a/mmgen/tw/store.py +++ b/mmgen/tw/store.py @@ -13,7 +13,6 @@ tw.store: Tracking wallet control class with store """ import json -from pathlib import Path from ..base_obj import AsyncInit from ..obj import TwComment @@ -48,7 +47,7 @@ class TwCtlWithStore(TwCtl, metaclass=AsyncInit): if cfg.cached_balances: self.use_cached_balances = True - self.tw_dir = type(self).get_tw_dir(self.cfg, self.proto) + self.tw_dir = type(self).get_tw_dir(self.proto) self.tw_path = self.tw_dir / self.tw_fn if no_wallet_init: @@ -81,14 +80,8 @@ class TwCtlWithStore(TwCtl, metaclass=AsyncInit): msg('read-only wallet, doing nothing') @classmethod - def get_tw_dir(cls, cfg, proto): - return Path( - cfg.data_dir_root, - cfg.test_user, - 'altcoins', - proto.coin.lower(), - ('' if proto.network == 'mainnet' else proto.network), - (cls.tw_subdir or '')) + def get_tw_dir(cls, proto): + return proto.network_datadir / (cls.tw_subdir or '') def upgrade_wallet_maybe(self): pass diff --git a/mmgen/xmrwallet/__init__.py b/mmgen/xmrwallet/__init__.py index 707ff15e..1dba551d 100755 --- a/mmgen/xmrwallet/__init__.py +++ b/mmgen/xmrwallet/__init__.py @@ -130,5 +130,5 @@ def op(op, cfg, infile, wallets, *, spec=None, compat_call=False): 'no_start_wallet_daemon': cfg.no_start_wallet_daemon or compat_call, 'daemon': cfg.daemon or cfg.monero_daemon, 'watch_only': cfg.watch_only or cfg.autosign or bool(cfg.autosign_mountpoint), - 'wallet_dir': twctl_cls.get_tw_dir(cfg, cfg._proto)})) + 'wallet_dir': twctl_cls.get_tw_dir(cfg._proto)})) return op_cls(op)(cfg, uargs(infile, wallets, spec, compat_call))