tx.new_swap: add ETH fee warning

This commit is contained in:
The MMGen Project 2025-03-25 09:46:01 +00:00
commit 565b8788b8
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
3 changed files with 25 additions and 7 deletions

View file

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

View file

@ -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'

View file

@ -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()