protocol: new network_datadir property

This commit is contained in:
The MMGen Project 2026-09-21 10:30:51 +00:00
commit 9037c1950d
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 15 additions and 12 deletions

View file

@ -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')

View file

@ -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

View file

@ -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

View file

@ -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))