mmgen-txsend -s: fix crash with XMR compat tx file in txauto dir

This commit is contained in:
The MMGen Project 2026-01-14 16:27:27 +00:00
commit 49a11a750b
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 53 additions and 3 deletions

View file

@ -13,6 +13,7 @@ proto.xmr.tx.completed: Monero completed transaction class
"""
from ....cfg import Config
from ....util import cached_property, make_timestamp
from .base import Base
@ -25,3 +26,13 @@ class Completed(Base):
'network': proto.network})
self.proto = proto
self.filename = filename
@cached_property
def compat_tx(self):
from pathlib import Path
from ....xmrwallet.file.tx import MoneroMMGenTX
return MoneroMMGenTX.View(self.cfg, Path(self.filename)) # View = Completed with silent open
@cached_property
def timestamp(self):
return make_timestamp(self.compat_tx.data.create_time)

View file

@ -49,6 +49,7 @@ class CmdTestAutosignAutomount(CmdTestAutosignThreaded, CmdTestRegtest):
('generate', 'mining a block'),
('alice_bal1', 'checking Alice’s balance'),
('alice_txcreate1', 'creating a transaction'),
('alice_add_xmr_compat_tx', 'adding XMR compat TX to txauto dir'),
('alice_txcreate_bad_have_unsigned', 'creating the transaction again (error)'),
('alice_run_autosign_setup', 'running ‘autosign setup’ (with default wallet)'),
('wait_loop_start', 'starting autosign wait loop'),
@ -119,6 +120,17 @@ class CmdTestAutosignAutomount(CmdTestAutosignThreaded, CmdTestRegtest):
def alice_bal1(self):
return self._user_bal_cli('alice', chk=self.bal1_chk[self.coin])
def alice_add_xmr_compat_tx(self):
self.spawn(msg_only=True)
self.insert_device()
self.do_mount()
from shutil import copyfile
tx_fn = '16E53D-E41192-XMR[0.012345].asubtx'
copyfile(f'test/ref/monero/{tx_fn}', f'{self.asi.txauto_dir}/{tx_fn}')
self.do_umount()
self.remove_device()
return 'ok'
def alice_txcreate1(self):
return self._user_txcreate(
'alice',

View file

@ -611,9 +611,10 @@ class CmdTestAutosignThreaded(CmdTestAutosignBase):
[await CompletedTX(cfg=self.cfg, filename=path, quiet_open=True) for path in sorted(src.iterdir())],
key = lambda x: x.timestamp)
for tx in txs:
imsg(blue(f'\nViewing ‘{tx.infile.name}’:'))
out = tx.info.format(terse=True)
imsg(indent(out, indent=' '))
if not tx.is_compat:
imsg(blue(f'\nViewing ‘{tx.infile.name}’:'))
out = tx.info.format(terse=True)
imsg(indent(out, indent=' '))
self.do_umount()
self.remove_device()
return 'ok'

File diff suppressed because one or more lines are too long