Browse Source

mmgen-tool twexport: add `force` keyword arg

The MMGen Project 1 year ago
parent
commit
a67f991b03
2 changed files with 9 additions and 4 deletions
  1. 5 2
      mmgen/tool/rpc.py
  2. 4 2
      mmgen/tw/json.py

+ 5 - 2
mmgen/tool/rpc.py

@@ -205,7 +205,7 @@ class tool_cmd(tool_cmd_base):
 		ret = await (await TwCtl(self.cfg,self.proto,mode='w')).rescan_blockchain(start_block,stop_block)
 		return True
 
-	async def twexport(self,include_amts=True,pretty=False,prune=False,warn_used=False):
+	async def twexport(self,include_amts=True,pretty=False,prune=False,warn_used=False,force=False):
 		"""
 		export a tracking wallet to JSON format
 
@@ -224,6 +224,8 @@ class tool_cmd(tool_cmd_base):
 
 		  If ‘warn_used’ is true, the user will be prompted before pruning used
 		  addresses.
+
+		  If ‘force’ is true, any existing dump will be overwritten without prompting.
 		"""
 		from ..tw.json import TwJSON
 		await TwJSON.Export(
@@ -232,7 +234,8 @@ class tool_cmd(tool_cmd_base):
 			include_amts    = include_amts,
 			pretty          = pretty,
 			prune           = prune,
-			warn_used       = warn_used )
+			warn_used       = warn_used,
+			force_overwrite = force )
 		return True
 
 	async def twimport(self,filename:str,ignore_checksum=False,batch=False):

+ 4 - 2
mmgen/tw/json.py

@@ -167,7 +167,8 @@ class TwJSON:
 				include_amts    = True,
 				pretty          = False,
 				prune           = False,
-				warn_used       = False ):
+				warn_used       = False,
+				force_overwrite = False ):
 
 			if prune and not self.can_prune:
 				die(1,f'Pruning not supported for {proto.name} protocol')
@@ -213,4 +214,5 @@ class TwJSON:
 						'data': data
 					},
 					pretty = pretty ),
-				desc    = f'tracking wallet JSON data' )
+				desc    = f'tracking wallet JSON data',
+				ask_overwrite = not force_overwrite )