Browse Source

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

The MMGen Project 6 days ago
parent
commit
49a11a750b

+ 11 - 0
mmgen/proto/xmr/tx/completed.py

@@ -13,6 +13,7 @@ proto.xmr.tx.completed: Monero completed transaction class
 """
 """
 
 
 from ....cfg import Config
 from ....cfg import Config
+from ....util import cached_property, make_timestamp
 
 
 from .base import Base
 from .base import Base
 
 
@@ -25,3 +26,13 @@ class Completed(Base):
 			'network': proto.network})
 			'network': proto.network})
 		self.proto = proto
 		self.proto = proto
 		self.filename = filename
 		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)

+ 12 - 0
test/cmdtest_d/automount.py

@@ -49,6 +49,7 @@ class CmdTestAutosignAutomount(CmdTestAutosignThreaded, CmdTestRegtest):
 		('generate',                         'mining a block'),
 		('generate',                         'mining a block'),
 		('alice_bal1',                       'checking Alice’s balance'),
 		('alice_bal1',                       'checking Alice’s balance'),
 		('alice_txcreate1',                  'creating a transaction'),
 		('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_txcreate_bad_have_unsigned', 'creating the transaction again (error)'),
 		('alice_run_autosign_setup',         'running ‘autosign setup’ (with default wallet)'),
 		('alice_run_autosign_setup',         'running ‘autosign setup’ (with default wallet)'),
 		('wait_loop_start',                  'starting autosign wait loop'),
 		('wait_loop_start',                  'starting autosign wait loop'),
@@ -119,6 +120,17 @@ class CmdTestAutosignAutomount(CmdTestAutosignThreaded, CmdTestRegtest):
 	def alice_bal1(self):
 	def alice_bal1(self):
 		return self._user_bal_cli('alice', chk=self.bal1_chk[self.coin])
 		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):
 	def alice_txcreate1(self):
 		return self._user_txcreate(
 		return self._user_txcreate(
 			'alice',
 			'alice',

+ 4 - 3
test/cmdtest_d/autosign.py

@@ -611,9 +611,10 @@ class CmdTestAutosignThreaded(CmdTestAutosignBase):
 			[await CompletedTX(cfg=self.cfg, filename=path, quiet_open=True) for path in sorted(src.iterdir())],
 			[await CompletedTX(cfg=self.cfg, filename=path, quiet_open=True) for path in sorted(src.iterdir())],
 			key = lambda x: x.timestamp)
 			key = lambda x: x.timestamp)
 		for tx in txs:
 		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.do_umount()
 		self.remove_device()
 		self.remove_device()
 		return 'ok'
 		return 'ok'

File diff suppressed because it is too large
+ 18 - 0
test/ref/monero/16E53D-E41192-XMR[0.012345].asubtx


Some files were not shown because too many files changed in this diff