minor fixes and cleanups

This commit is contained in:
The MMGen Project 2026-10-20 17:38:48 +00:00
commit a5e3a1807c
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
7 changed files with 31 additions and 20 deletions

View file

@ -36,9 +36,9 @@ class File:
self.atime = None
try:
st = os.stat(fn)
st = os.stat(str(fn))
except:
die('FileNotFound', f'{fn!r}: file not found')
die('FileNotFound', f'{fn!s}: file not found')
import stat
if stat.S_ISBLK(st.st_mode):

View file

@ -10,14 +10,19 @@
proto.xmr.tw.ctl: Monero tracking wallet control class
"""
from ....tw.ctl import write_mode
from ....tw.store import TwCtlWithStore
from ....tw.ctl import TwCtl, write_mode
class MoneroTwCtl(TwCtlWithStore):
class MoneroTwCtl(TwCtl):
tw_subdir = 'tracking-wallets'
use_cached_balances = True
async def __init__(self, cfg, proto, *, mode='r', **kwargs):
await super().__init__(cfg, proto, mode=mode, no_rpc=True)
@classmethod
def get_tw_dir(cls, proto):
return proto.network_datadir / 'tracking-wallets'
@write_mode
async def set_comment(
self,

View file

@ -24,7 +24,7 @@ class New(Base, TxNew):
async def get_input_addrs_from_inputs_opt(self):
return [] # TODO
async def set_gas(self):
async def set_gas(self, *, to_addr=None, force=False):
pass
async def get_funds_remaining(self, fee, outputs_sum, start_fee_desc):

View file

@ -12,7 +12,6 @@ tw.store: Tracking wallet control class with store
import json
from ..base_obj import AsyncInit
from ..obj import TwComment
from ..util import msg, die, cached_property
from ..addr import is_coin_addr, is_mmgen_id, CoinAddr
@ -20,10 +19,9 @@ from ..addr import is_coin_addr, is_mmgen_id, CoinAddr
from .shared import TwMMGenID, TwLabel
from .ctl import TwCtl, write_mode, label_addr_pair
class TwCtlWithStore(TwCtl, metaclass=AsyncInit):
class TwCtlWithStore(TwCtl):
caps = ('batch',)
tw_subdir = None
tw_fn = 'tracking-wallet.json'
aggressive_sync = False
@ -79,7 +77,7 @@ class TwCtlWithStore(TwCtl, metaclass=AsyncInit):
@classmethod
def get_tw_dir(cls, proto):
return proto.network_datadir / (cls.tw_subdir or '')
return proto.network_datadir
def upgrade_wallet_maybe(self):
pass

View file

@ -529,6 +529,7 @@ class CmdTestAutosignThreaded(CmdTestAutosignBase):
tweaks = [],
expect_str = None,
data_arg = None,
ui_handler_args = None,
need_rbf = False):
if output_args:
@ -563,10 +564,11 @@ class CmdTestAutosignThreaded(CmdTestAutosignBase):
t = (ui_handler or self.txcreate_ui_common)(
t,
inputs = inputs,
interactive_fee = '32s',
tweaks = tweaks,
file_desc = 'Unsigned automount transaction')
**(ui_handler_args if ui_handler_args else {
'inputs': inputs,
'interactive_fee': '32s',
'tweaks': tweaks,
'file_desc': 'Unsigned automount transaction'}))
return do_return()
@ -575,9 +577,11 @@ class CmdTestAutosignThreaded(CmdTestAutosignBase):
user,
*,
comment = None,
add_opts = [],
no_wait = False,
need_rbf = False,
dump_hex = False,
expect_pat = None,
mark_sent = False):
if need_rbf and not self.proto.cap('rbf'):
@ -593,12 +597,15 @@ class CmdTestAutosignThreaded(CmdTestAutosignBase):
self.insert_device_online()
t = self.spawn('mmgen-txsend',
[f'--{user}', '--quiet', '--autosign'] + extra_opt, no_passthru_opts=['coin'])
[f'--{user}', '--quiet', '--autosign'] + extra_opt + add_opts, no_passthru_opts=['coin'])
if mark_sent:
if '--status' in add_opts:
if expect_pat:
t.expect(expect_pat, regex=True)
elif mark_sent:
t.written_to_file('Sent automount transaction')
else:
t.view_tx('t')
t.view_tx('t', expect_pat=expect_pat)
t.do_comment(comment)
if dump_hex:
t.written_to_file('Serialized transaction hex data')

View file

@ -85,7 +85,7 @@ class CmdTestPexpect:
if not have_yes_opt:
self.expect('Check key-to-address validity? (y/N): ', ('n', 'y')[check])
def view_tx(self, view):
def view_tx(self, view, *, expect_pat=None):
self.expect(r'View.* transaction.*\? .*: ', view, regex=True)
match view:
case 'v' if cfg.pexpect_spawn:
@ -93,6 +93,8 @@ class CmdTestPexpect:
case 'v' | 'n' | '\n':
pass
case _:
if expect_pat:
self.expect(expect_pat, regex=True)
self.expect('to continue: ', '\n')
def do_comment(self, add_comment, has_label=False):

View file

@ -26,7 +26,6 @@ class overlay_fake_Daemon:
@property
def port_shift(self):
udata = {
'': 0,
'miner': 1,