Browse Source

tx.new_swap: add ETH fee warning

The MMGen Project 1 week ago
parent
commit
565b8788b8
3 changed files with 25 additions and 7 deletions
  1. 1 1
      mmgen/data/version
  2. 18 1
      mmgen/tx/new_swap.py
  3. 6 5
      test/cmdtest_d/ct_ethswap.py

+ 1 - 1
mmgen/data/version

@@ -1 +1 @@
-15.1.dev23
+15.1.dev24

+ 18 - 1
mmgen/tx/new_swap.py

@@ -28,12 +28,29 @@ def init_proto_from_coin(cfg, sp, coin, desc):
 	from ..protocol import init_proto
 	return init_proto(cfg, coin, network=cfg._proto.network, need_amt=True)
 
+def do_eth_fee_warning(cfg):
+	from ..ui import keypress_confirm
+	from ..color import yellow
+	warning = """
+  Warning: Fee bumping for Ethereum swap transactions is not currently supported.
+  Make sure to include a sufficient transaction fee!  Continue? (Y/n):
+	"""
+	keypress_confirm(
+		cfg,
+		'  ' + yellow(warning.strip()) + ' ',
+		default_yes = True,
+		complete_prompt = True,
+		do_exit = True)
+
 def get_send_proto(cfg):
 	try:
 		arg = cfg._args.pop(0)
 	except:
 		cfg._usage()
-	return init_proto_from_coin(cfg, get_swap_proto_mod(cfg.swap_proto), arg, 'send')
+	proto = init_proto_from_coin(cfg, get_swap_proto_mod(cfg.swap_proto), arg, 'send')
+	if proto.coin == 'ETH':
+		do_eth_fee_warning(cfg)
+	return proto
 
 class NewSwap(New):
 	desc = 'swap transaction'

+ 6 - 5
test/cmdtest_d/ct_ethswap.py

@@ -192,16 +192,17 @@ class CmdTestEthSwapEth(CmdTestEthdev, CmdTestSwapMethods):
 	def swaptxcreate1(self):
 		self.get_file_with_ext('rawtx', delete_all=True)
 		t = self._swaptxcreate(['ETH', '8.765', 'BTC'])
+		t.expect('Continue? (Y/n):', 'y')
 		t.expect('OK? (Y/n): ', 'y')
 		return self._swaptxcreate_ui_common(t)
 
 	def swaptxcreate2(self):
 		self.get_file_with_ext('rawtx', delete_all=True)
-		return self._swaptxcreate_ui_common(
-			self._swaptxcreate(
-				['ETH', '8.765', 'BTC', f'{dfl_seed_id}:B:3'],
-				add_opts = ['--trade-limit=3%']),
-			expect = ':2019e4/1/0')
+		t = self._swaptxcreate(
+			['ETH', '8.765', 'BTC', f'{dfl_seed_id}:B:3'],
+			add_opts = ['--trade-limit=3%'])
+		t.expect('Continue? (Y/n):', 'y')
+		return self._swaptxcreate_ui_common(t, expect=':2019e4/1/0')
 
 	def swaptxsign1(self):
 		return self._swaptxsign()