Browse Source

MoneroWalletOps: preclude use of `cfg.outdir`

The MMGen Project 1 year ago
parent
commit
2c2c07d964
7 changed files with 12 additions and 9 deletions
  1. 4 2
      mmgen/addrfile.py
  2. 0 1
      mmgen/autosign.py
  3. 1 0
      mmgen/cfg.py
  4. 1 1
      mmgen/data/release_date
  5. 1 1
      mmgen/data/version
  6. 3 2
      mmgen/fileutil.py
  7. 2 2
      mmgen/xmrwallet.py

+ 4 - 2
mmgen/addrfile.py

@@ -68,7 +68,8 @@ class AddrFile(MMGenObject):
 			fn            = None,
 			binary        = False,
 			desc          = None,
-			ask_overwrite = True):
+			ask_overwrite = True,
+			outdir        = None):
 		from .fileutil import write_data_to_file
 		write_data_to_file(
 			cfg           = self.cfg,
@@ -77,7 +78,8 @@ class AddrFile(MMGenObject):
 			desc          = desc or self.desc,
 			ask_tty       = self.parent.has_keys and not self.cfg.quiet,
 			binary        = binary,
-			ask_overwrite = ask_overwrite)
+			ask_overwrite = ask_overwrite,
+			outdir        = outdir)
 
 	def make_label(self):
 		p = self.parent

+ 0 - 1
mmgen/autosign.py

@@ -627,7 +627,6 @@ class Autosign:
 				'wallet_dir': str(self.wallet_dir),
 				'autosign': True,
 				'autosign_mountpoint': str(self.mountpoint),
-				'outdir': str(self.xmr_dir), # required by vkal.write()
 				'offline': True,
 				'passwd_file': str(self.keyfile),
 			})

+ 1 - 0
mmgen/cfg.py

@@ -239,6 +239,7 @@ class Config(Lockable):
 		('label','keep_label'),
 		('tx_id','info'),
 		('tx_id','terse_info'),
+		('autosign','outdir'),
 	)
 
 	_cfg_file_opts = (

+ 1 - 1
mmgen/data/release_date

@@ -1 +1 @@
-February 2024
+March 2024

+ 1 - 1
mmgen/data/version

@@ -1 +1 @@
-14.1.dev15
+14.1.dev16

+ 3 - 2
mmgen/fileutil.py

@@ -161,6 +161,7 @@ def write_data_to_file(
 		quiet                 = False,
 		binary                = False,
 		ignore_opt_outdir     = False,
+		outdir                = None,
 		check_data            = False,
 		cmp_data              = None):
 
@@ -218,8 +219,8 @@ def write_data_to_file(
 			os.write(1,data if isinstance(data,bytes) else data.encode())
 
 	def do_file(outfile,ask_write_prompt):
-		if cfg.outdir and not ignore_opt_outdir and not os.path.isabs(outfile):
-			outfile = make_full_path(cfg.outdir,outfile)
+		if (outdir or (cfg.outdir and not ignore_opt_outdir)) and not os.path.isabs(outfile):
+			outfile = make_full_path(outdir or cfg.outdir, outfile)
 
 		if ask_write:
 			if not ask_write_prompt:

+ 2 - 2
mmgen/xmrwallet.py

@@ -1217,13 +1217,13 @@ class MoneroWalletOps:
 			vkf = vkal.file
 
 			# before writing viewkey-address file, shred any old ones in the directory:
-			for f in Path(self.cfg.outdir or '.').iterdir():
+			for f in Path(self.asi.xmr_dir).iterdir():
 				if f.name.endswith(vkf.ext):
 					from .fileutil import shred_file
 					msg(f"\nShredding old viewkey-address file '{f}'")
 					shred_file( f, verbose=self.cfg.verbose )
 
-			vkf.write() # write file to self.cfg.outdir
+			vkf.write(outdir=self.asi.xmr_dir)
 
 	class restore(create):
 		wallet_offline = True