Skip to content

Commit

Permalink
mmgen-xmrwallet: ignore already imported wallet outputs files
Browse files Browse the repository at this point in the history
  • Loading branch information
mmgen committed Apr 5, 2024
1 parent f8dd81e commit 80f6f9a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
18 changes: 13 additions & 5 deletions mmgen/autosign.py
Expand Up @@ -270,6 +270,17 @@ class xmr_wallet_outputs_file(xmr_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)
Expand All @@ -281,11 +292,8 @@ async def sign(self,f):
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):
Expand Down
2 changes: 1 addition & 1 deletion mmgen/data/release_date
@@ -1 +1 @@
March 2024
April 2024
2 changes: 1 addition & 1 deletion mmgen/data/version
@@ -1 +1 @@
14.1.dev25
14.1.dev26
3 changes: 3 additions & 0 deletions mmgen/xmrwallet.py
Expand Up @@ -500,6 +500,7 @@ class Base(MoneroMMGenFile):
'outputs_data_hex',
'signed_key_images',
'sign',
'imported',
])

def __init__(self,cfg):
Expand Down Expand Up @@ -1964,6 +1965,8 @@ async def main(self,fn,wallet_idx,restart_daemon=True):
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):
Expand Down

0 comments on commit 80f6f9a

Please sign in to comment.