From 565b8788b87dfa2fb58e8d1bab4c67c04fd88ee5 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Tue, 25 Mar 2025 09:46:01 +0000 Subject: [PATCH] tx.new_swap: add ETH fee warning --- mmgen/data/version | 2 +- mmgen/tx/new_swap.py | 19 ++++++++++++++++++- test/cmdtest_d/ct_ethswap.py | 11 ++++++----- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/mmgen/data/version b/mmgen/data/version index ee47b5d4..5c9553a3 100644 --- a/mmgen/data/version +++ b/mmgen/data/version @@ -1 +1 @@ -15.1.dev23 +15.1.dev24 diff --git a/mmgen/tx/new_swap.py b/mmgen/tx/new_swap.py index e10e6d18..df42100b 100755 --- a/mmgen/tx/new_swap.py +++ b/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' diff --git a/test/cmdtest_d/ct_ethswap.py b/test/cmdtest_d/ct_ethswap.py index 2b23995c..efb49361 100755 --- a/test/cmdtest_d/ct_ethswap.py +++ b/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()