From 7e442eadadd239b3f364d1fd04941520a794706e Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Tue, 27 Oct 2026 13:30:14 +0000 Subject: [PATCH] proto.eth.params: add `multiple_txhex` mmcap --- mmgen/main_txsend.py | 9 +++++++++ mmgen/proto/btc/tx/status.py | 1 - mmgen/proto/eth/params.py | 2 +- mmgen/proto/eth/tx/online.py | 7 ++++++- mmgen/tx/online.py | 12 ++---------- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/mmgen/main_txsend.py b/mmgen/main_txsend.py index 11823634..9aaa1a0f 100644 --- a/mmgen/main_txsend.py +++ b/mmgen/main_txsend.py @@ -159,6 +159,15 @@ async def process_tx(tx): if tx.is_compat and not cfg.autosign: die(1, 'Sending XMR transaction via compatibility layer requires --autosign') + if cfg.txhex_idx: + if not 'multiple_txhex' in tx.proto.mmcaps: + die(1, f'--txhex-idx not supported for {tx.proto.name} protocol') + if getattr(tx, 'coin_txid2', None): + if cfg.txhex_idx not in ('1', '2'): + die(1, f'{cfg.txhex_idx}: invalid parameter for --txhex-idx (must be 1 or 2)') + else: + die(1, '--txhex-idx not supported for transactions with only one part') + txcfg = Config({'_clone': cfg, 'proto': tx.proto, 'coin': tx.proto.coin}) if (not post_send_op) and cfg.tx_proxy: diff --git a/mmgen/proto/btc/tx/status.py b/mmgen/proto/btc/tx/status.py index 18ff5ed7..d503171f 100644 --- a/mmgen/proto/btc/tx/status.py +++ b/mmgen/proto/btc/tx/status.py @@ -25,7 +25,6 @@ class Status(TxBase.Status): msg(message) return exitval - assert idx == '', f'multiple txhex not supported for {self.tx.proto}' tx = self.tx class r: diff --git a/mmgen/proto/eth/params.py b/mmgen/proto/eth/params.py index 9fad696a..b656b3b4 100644 --- a/mmgen/proto/eth/params.py +++ b/mmgen/proto/eth/params.py @@ -29,7 +29,7 @@ class mainnet(CoinProtocol.DummyWIF, CoinProtocol.Secp256k1): chain_names = ['ethereum', 'foundation'] sign_mode = 'standalone' caps = ('token',) - mmcaps = ('rpc', 'rpc_init', 'tw', 'msg') + mmcaps = ('rpc', 'rpc_init', 'tw', 'msg', 'multiple_txhex') base_proto = 'Ethereum' base_proto_coin = 'ETH' base_coin = 'ETH' diff --git a/mmgen/proto/eth/tx/online.py b/mmgen/proto/eth/tx/online.py index d06b0fcc..74fd6275 100644 --- a/mmgen/proto/eth/tx/online.py +++ b/mmgen/proto/eth/tx/online.py @@ -10,7 +10,7 @@ proto.eth.tx.online: Ethereum online signed transaction class """ -from ....util import msg, die +from ....util import msg, ymsg, die from ....color import yellow, green, orange from ....tx import online as TxBase from .. import erigon_sleep @@ -21,6 +21,11 @@ class OnlineSigned(Signed, TxBase.OnlineSigned): async def test_sendable(self, txhex): raise NotImplementedError('transaction testing not implemented for Ethereum') + def confirm_send(self, idxs): + super().confirm_send(idxs) + if len(idxs) > 1 and self.is_swap: + ymsg('Warning: two transactions (approval and router) will be broadcast to the network') + async def send_checks(self): self.check_correct_chain() if not self.disable_fee_check and (self.fee > self.proto.max_tx_fee): diff --git a/mmgen/tx/online.py b/mmgen/tx/online.py index cf3b501f..b3192b82 100644 --- a/mmgen/tx/online.py +++ b/mmgen/tx/online.py @@ -67,8 +67,6 @@ class OnlineSigned(Signed): self.proto.network.upper()), expect = 'YES') msg('Sending transaction') - if len(idxs) > 1 and getattr(self, 'coin_txid2', None) and self.is_swap: - ymsg('Warning: two transactions (approval and router) will be broadcast to the network') async def post_send(self, asi): from . import SentTX @@ -90,14 +88,8 @@ class OnlineSigned(Signed): all_ok = True idxs = ['', '2'] - if cfg.txhex_idx: - if getattr(self, 'coin_txid2', None): - if cfg.txhex_idx in ('1', '2'): - idxs = ['' if cfg.txhex_idx == '1' else cfg.txhex_idx] - else: - die(1, f'{cfg.txhex_idx}: invalid parameter for --txhex-idx (must be 1 or 2)') - else: - die(1, 'Transaction has only one part, so --txhex-idx makes no sense') + if cfg.txhex_idx and getattr(self, 'coin_txid2', None): + idxs = ['' if cfg.txhex_idx == '1' else cfg.txhex_idx] if not (cfg.status or cfg.receipt or cfg.dump_hex or cfg.test): self.confirm_send(idxs)