mmgen-xmrwallet: new --compat option

This commit is contained in:
The MMGen Project 2025-11-15 09:50:21 +00:00
commit 68fba89e96
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
11 changed files with 57 additions and 3 deletions

View file

@ -801,6 +801,7 @@ class Autosign:
'autosign': True,
'autosign_mountpoint': str(self.mountpoint),
'offline': True,
'compat': False,
'passwd_file': str(self.keyfile)})
return self._xmrwallet_cfg

View file

@ -239,6 +239,7 @@ class Config(Lockable):
# Monero:
monero_wallet_rpc_user = 'monero'
monero_wallet_rpc_password = ''
xmrwallet_compat = False
priority = 0
# test suite:
@ -308,6 +309,7 @@ class Config(Lockable):
'max_input_size',
'max_tx_file_size',
'mnemonic_entry_modes',
'xmrwallet_compat',
'monero_wallet_rpc_password',
'monero_wallet_rpc_user',
'no_license',

View file

@ -152,6 +152,10 @@
# Set the Monero wallet RPC password to something secure:
# monero_wallet_rpc_password passw0rd
# Configure mmgen-xmrwallet for compatibility with mmgen-tx{create,sign,send}
# family of commands (equivalent to mmgen-xmrwallet --compat option)
# xmrwallet_compat true
#######################################################################
## The following options are probably of interest only to developers ##
#######################################################################

View file

@ -51,6 +51,14 @@ class help_notes:
from ..proto.btc.rpc.local import BitcoinRPCClient
return BitcoinRPCClient.dfl_twname
def tw_dir(self):
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)
else:
raise ValueError(f'protocol {self.proto.name} does not support tracking wallet with store')
def MasterShareIdx(self):
from ..seedsplit import MasterShareIdx
return MasterShareIdx

View file

@ -47,6 +47,10 @@ opts_data = {
When this option is in effect, filename argu-
ments must be omitted, as files are located
automatically.
-c, --compat Adjust configuration for compatibility with
the mmgen-tx{{create,sign,send}} family of
commands. Currently equivalent to
-w {tw_dir}
-f, --priority=N Specify an integer priority N for inclusion
of a transaction in the blockchain (higher
number means higher fee). Valid parameters:
@ -88,11 +92,12 @@ opts_data = {
"""
},
'code': {
'options': lambda cfg, s: s.format(
'options': lambda cfg, help_notes, s: s.format(
D = xmrwallet.uarg_info['daemon'].annot,
R = xmrwallet.uarg_info['tx_relay_daemon'].annot,
cfg = cfg,
gc = gc,
tw_dir = help_notes('tw_dir'),
tp = fmt_dict(xmrwallet.tx_priorities, fmt='equal_compact')
),
'notes': lambda help_mod, s: s.format(

View file

@ -25,6 +25,7 @@ class MoneroViewKey(HexStr):
# https://github.com/monero-project/monero/blob/master/src/cryptonote_config.h
class mainnet(CoinProtocol.RPC, CoinProtocol.DummyWIF, CoinProtocol.Base):
mod_clsname = 'Monero'
network_names = _nw('mainnet', 'stagenet', None)
base_proto = 'Monero'
base_proto_coin = 'XMR'

19
mmgen/proto/xmr/tw/ctl.py Executable file
View file

@ -0,0 +1,19 @@
#!/usr/bin/env python3
#
# MMGen Wallet, a terminal-based cryptocurrency wallet
# Copyright (C)2013-2025 The MMGen Project <mmgen@tuta.io>
# Licensed under the GNU General Public License, Version 3:
# https://www.gnu.org/licenses
# Public project repositories:
# https://github.com/mmgen/mmgen-wallet
# https://gitlab.com/mmgen/mmgen-wallet
"""
proto.xmr.tw.ctl: Monero tracking wallet control class
"""
from ....tw.store import TwCtlWithStore
class MoneroTwCtl(TwCtlWithStore):
tw_subdir = 'tracking-wallets'

View file

@ -26,6 +26,7 @@ from .ctl import TwCtl, write_mode, label_addr_pair
class TwCtlWithStore(TwCtl, metaclass=AsyncInit):
caps = ('batch',)
tw_subdir = None
tw_fn = 'tracking-wallet.json'
aggressive_sync = False
@ -85,7 +86,7 @@ class TwCtlWithStore(TwCtl, metaclass=AsyncInit):
cfg.data_dir_root,
'altcoins',
proto.coin.lower(),
('' if proto.network == 'mainnet' else proto.network))
('' if proto.network == 'mainnet' else proto.network)) / (cls.tw_subdir or '')
def upgrade_wallet_maybe(self):
pass

View file

@ -17,7 +17,7 @@ from collections import namedtuple
from ..proto.btc.common import b58a
from ..util import capfirst
from ..util import die, capfirst
tx_priorities = {
1: 'low',
@ -113,4 +113,14 @@ def op_cls(op_name):
return cls
def op(op, cfg, infile, wallets, *, spec=None):
if cfg.compat if cfg.compat is not None else cfg.xmrwallet_compat:
if cfg.wallet_dir:
die(1, '--wallet-dir can not be specified in xmrwallet compatibility mode')
from ..tw.ctl import TwCtl
from ..cfg import Config
twctl_cls = cfg._proto.base_proto_subclass(TwCtl, 'tw.ctl')
cfg = Config({
'_clone': cfg,
'compat': True,
'wallet_dir': twctl_cls.get_tw_dir(cfg, cfg._proto)})
return op_cls(op)(cfg, uargs(infile, wallets, spec))

View file

@ -28,6 +28,8 @@ class OpCreate(OpWallet):
if self.cfg.restore_height != 'current':
if int(self.cfg.restore_height or 0) < 0:
die(1, f'{self.cfg.restore_height}: invalid value for --restore-height (less than zero)')
if self.cfg.compat:
self.cfg.wallet_dir.mkdir(parents=True, exist_ok=True)
async def process_wallet(self, d, fn, last):
msg_r('') # for pexpect

View file

@ -104,6 +104,7 @@ packages =
mmgen.proto.vm.tx
mmgen.proto.xchain
mmgen.proto.xmr
mmgen.proto.xmr.tw
mmgen.proto.zec
mmgen.rpc
mmgen.rpc.backends