Browse Source

mmgen-xmrwallet: ignore already imported wallet outputs files

The MMGen Project 6 months ago
parent
commit
80f6f9aa5c
4 changed files with 18 additions and 7 deletions
  1. 13 5
      mmgen/autosign.py
  2. 1 1
      mmgen/data/release_date
  3. 1 1
      mmgen/data/version
  4. 3 0
      mmgen/xmrwallet.py

+ 13 - 5
mmgen/autosign.py

@@ -270,6 +270,17 @@ class Signable:
 		clean_all = True
 		summary_footer = '\n'
 
+		@property
+		def unsigned(self):
+			import json
+			unsigned = super().unsigned
+			def gen():
+				for f in unsigned:
+					with open(f) as fh:
+						if not json.load(fh)['MoneroMMGenWalletOutputsFile']['data']['imported']:
+							yield f
+			return tuple(gen())
+
 		async def sign(self,f):
 			from .xmrwallet import MoneroWalletOps,xmrwallet_uargs
 			wallet_idx = MoneroWalletOps.wallet.get_idx_from_fn(f)
@@ -281,11 +292,8 @@ class Signable:
 					spec    = None ),
 			)
 			obj = await m.main(f, wallet_idx, restart_daemon=self.need_daemon_restart(m,wallet_idx))
-			if obj.data.sign:
-				obj.write()
-				self.action_desc = 'imported and signed'
-			else:
-				self.action_desc = 'imported'
+			obj.write()
+			self.action_desc = 'imported and signed' if obj.data.sign else 'imported'
 			return obj
 
 	class message(base):

+ 1 - 1
mmgen/data/release_date

@@ -1 +1 @@
-March 2024
+April 2024

+ 1 - 1
mmgen/data/version

@@ -1 +1 @@
-14.1.dev25
+14.1.dev26

+ 3 - 0
mmgen/xmrwallet.py

@@ -500,6 +500,7 @@ class MoneroWalletOutputsFile:
 			'outputs_data_hex',
 			'signed_key_images',
 			'sign',
+			'imported',
 		])
 
 		def __init__(self,cfg):
@@ -1964,6 +1965,8 @@ class MoneroWalletOps:
 					data      = data)
 				idata = m.data.signed_key_images or []
 				bmsg(f'  {len(idata)} key image{suf(idata)} signed')
+			else:
+				m.data = m.data._replace(imported=True)
 			return m
 
 	class import_key_images(wallet):