From 96fcc4958c521fe6f61d5e3884ca261310caf2d6 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 23 Oct 2026 17:01:32 +0000 Subject: [PATCH] CoinProtocol.Base: new `tx_amt_arg_required` attr --- mmgen/proto/xmr/params.py | 1 + mmgen/protocol.py | 1 + mmgen/tx/new.py | 3 +++ mmgen/tx/new_swap.py | 2 ++ test/cmdtest_d/xmr_autosign.py | 4 ++++ test/cmdtest_d/xmrswap.py | 8 ++++++++ 6 files changed, 19 insertions(+) diff --git a/mmgen/proto/xmr/params.py b/mmgen/proto/xmr/params.py index ceb3c50c..afcb45c3 100644 --- a/mmgen/proto/xmr/params.py +++ b/mmgen/proto/xmr/params.py @@ -41,6 +41,7 @@ class mainnet(CoinProtocol.RPC, CoinProtocol.DummyWIF, CoinProtocol.Base): sign_mode = 'standalone' has_usr_fee = False address_reuse_ok = False + tx_amt_arg_required = True coin_cfg_opts = ( 'ignore_daemon_version', diff --git a/mmgen/protocol.py b/mmgen/protocol.py index 2bf77970..9b486f1b 100644 --- a/mmgen/protocol.py +++ b/mmgen/protocol.py @@ -57,6 +57,7 @@ class CoinProtocol(MMGenObject): is_vm = False is_evm = False has_chg = False + tx_amt_arg_required = False has_usr_fee = True coin_amt = None max_tx_fee = None diff --git a/mmgen/tx/new.py b/mmgen/tx/new.py index 0ac7dc5c..dd1170ae 100644 --- a/mmgen/tx/new.py +++ b/mmgen/tx/new.py @@ -262,6 +262,9 @@ class New(Base): is_chg = not a.amt, is_vault = a.is_vault) + if self.proto.tx_amt_arg_required and not self.sum_outputs(): + die(1, f'send amount is required for protocol {self.proto.name}') + self.check_dup_addrs('outputs') if self.is_compat: diff --git a/mmgen/tx/new_swap.py b/mmgen/tx/new_swap.py index dd3e10af..92c706a6 100644 --- a/mmgen/tx/new_swap.py +++ b/mmgen/tx/new_swap.py @@ -107,6 +107,8 @@ class NewSwap(BaseSwapMethods, New): UniAmt(arg) # throw exception on decimal overflow args.send_amt = self.proto.coin_amt(arg) arg = get_arg() + elif self.proto.tx_amt_arg_required: # not optional in this case + die(1, f'send amount is required for protocol {self.proto.name}') # arg 3: optional chg_spec (change address spec, requires amt) if self.proto.has_chg and args.send_amt and not arg in sa.recv: # is change arg diff --git a/test/cmdtest_d/xmr_autosign.py b/test/cmdtest_d/xmr_autosign.py index 6b817d62..203e1318 100644 --- a/test/cmdtest_d/xmr_autosign.py +++ b/test/cmdtest_d/xmr_autosign.py @@ -543,6 +543,7 @@ class CmdTestXMRCompat(CmdTestXMRAutosign): ('user_twview_chk1', 'viewing user’s tracking wallets (check balances)'), ('user_listaddresses_sort', 'listing user’s addresses (sort options)'), ('wait_loop_start_compat', 'starting autosign wait loop in XMR compat mode [--coins=xmr]'), + ('user_txcreate1_bad', 'creating a transaction (bad, no amount)'), ('user_txcreate1', 'creating a transaction'), ('user_txabort1', 'aborting the transaction'), ('user_txcreate2', 'recreating the transaction'), @@ -816,6 +817,9 @@ class CmdTestXMRCompat(CmdTestXMRAutosign): def wait_loop_start_ltc(self): return self.wait_loop_start(opts=['--xmrwallet-compat', '--coins=ltc,xmr']) + def user_txcreate1_bad(self): + return self._user_txops('txcreate', [self.burn_addr], acct_num=1, exit_val=1, expect_str='amount is required') + def user_txcreate1(self): return self._user_txops('txcreate', [f'{self.burn_addr},0.012345'], acct_num=1) diff --git a/test/cmdtest_d/xmrswap.py b/test/cmdtest_d/xmrswap.py index ad6f88d3..9551ccf9 100644 --- a/test/cmdtest_d/xmrswap.py +++ b/test/cmdtest_d/xmrswap.py @@ -210,8 +210,10 @@ class CmdTestXMRSwap(CmdTestXMRSwapMethods, CmdTestSwap): 'xmr_swap': ( 'swap operations (XMR -> LTC)', ('remote_get_refnum_xmr', 'getting the reference number'), + ('swaptxcreate_refreq7_bad', 'creating an XMR->LTC registration transaction (bad, no amount)'), ('swaptxcreate_refreq7', 'creating an XMR->LTC registration transaction (auto chg, auto dest)'), ('swaptxsend_refreq7', 'sending the transaction'), + ('swaptxcreate_refnum7_bad', 'creating an XMR->LTC swap transaction (bad, no amount)'), ('swaptxcreate_refnum7', 'creating an XMR->LTC swap transaction (auto chg, auto dest)'), ('swaptxsend_refnum7', 'sending the transaction'), ('xmr_mine_blocks_10', ''), @@ -309,6 +311,9 @@ class CmdTestXMRSwap(CmdTestXMRSwapMethods, CmdTestSwap): def remote_get_refnum_xmr(self): return self._remote_get_refnum(self.refreq_txid_xmr) + def swaptxcreate_refreq7_bad(self): + return self._swaptxcreate_refreq_xmr(['XMR', 'LTC'], exit_val=1) + def swaptxcreate_refreq7(self): return self._swaptxcreate_refreq_xmr(['XMR', '0.2345', 'LTC']) @@ -323,6 +328,9 @@ class CmdTestXMRSwap(CmdTestXMRSwapMethods, CmdTestSwap): def swaptxsend_refreq7(self): return self._user_txsend('bob', need_rbf=True) + def swaptxcreate_refnum7_bad(self): + return self._swaptxcreate_refnum_xmr(['XMR', 'LTC'], exit_val=1) + def swaptxcreate_refnum7(self): return self._swaptxcreate_refnum_xmr(['XMR', '0.2345', 'LTC'])