tx: allow zero send amount for deposit transactions (bugfix)

Fixes a critical bug whereby the memoless registration transaction spent all the
RUNE in the account.

Note that memoless swaps are enabled in the test suite only, so the bug could
not have led to loss of user funds.

As an added safeguard, the patch also disables zero send amounts for non-deposit
transactions.
This commit is contained in:
The MMGen Project 2026-10-15 09:35:53 +00:00
commit d9e2449429
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 10 additions and 2 deletions

View file

@ -1 +1 @@
16.3.0dev16
16.3.0dev17

View file

@ -189,6 +189,9 @@ class New(Base):
amt = self.proto.coin_amt(amt_in or '0')
if not (amt or amt_in is None or self.is_deposit):
die(2, 'For non-deposit transactions, amount must be nonzero')
coin_addr, mmid, is_vault = (None, None, False)
if (arg == 'vault' and self.is_swap) or (arg == 'deposit' and self.is_deposit):
@ -543,7 +546,8 @@ class New(Base):
if not self.is_compat:
self.check_non_mmgen_inputs(caller=caller)
self.update_change_output(funds_left)
if not self.is_deposit:
self.update_change_output(funds_left)
if self.is_memoless and self.refnum:
self.update_vault_memoless_amt(round_down=len(self.outputs) == 1)
self.check_chg_addr_is_wallet_addr()

View file

@ -40,6 +40,7 @@ class CmdTestRuneMethods:
args = ['98831F3A:X:2,54.321'],
add_opts = [],
append_args = [],
expect_pat = None,
menu_prompt = None):
t = self.spawn('mmgen-txcreate', self.rune_opts + add_opts + args + append_args)
t.expect(menu_prompt or self.menu_prompt, 'q')
@ -47,6 +48,8 @@ class CmdTestRuneMethods:
t.expect('(y/N): ', 'y') # add comment?
t.expect('Comment: ', 'THOR Chad #1\n')
t.expect('view: ', 'y')
if expect_pat:
t.expect(expect_pat, regex=True)
t.expect('to continue: ', 'z')
t.expect('(y/N): ', 'y') # save?
t.written_to_file('Unsigned transaction')

View file

@ -854,6 +854,7 @@ class CmdTestSwap(
return self._rune_txcreate(
args = ['deposit,0', f'data:{memo}'],
add_opts = ['--coin=rune', '--fee=0.2'],
expect_pat = r'to spend:.*\b0\b.*RUNE',
menu_prompt = self.rune_menu_prompt)
def rune_txsign_refreq(self):