From ff380698433aaafba409735db26c67f6becde272 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Mon, 26 Jan 2026 10:56:21 +0000 Subject: [PATCH] tw, tx: minor fixes and cleanups --- mmgen/main_txcreate.py | 5 +++-- mmgen/proto/xmr/tw/unspent.py | 17 +++++++++-------- mmgen/proto/xmr/tx/new.py | 14 ++++++++++---- mmgen/tw/view.py | 15 +++++++++------ mmgen/tx/new.py | 2 ++ 5 files changed, 33 insertions(+), 20 deletions(-) diff --git a/mmgen/main_txcreate.py b/mmgen/main_txcreate.py index 0c55e962..c837ad2c 100755 --- a/mmgen/main_txcreate.py +++ b/mmgen/main_txcreate.py @@ -130,8 +130,9 @@ if cfg.list_assets: Msg('AVAILABLE SWAP ASSETS:\n' + sp.SwapAsset('BTC', 'send').fmt_assets_data(indent=' ')) sys.exit(0) -if not (cfg.info or cfg.contract_data) and len(cfg._args) < {'tx': 1, 'swaptx': 2}[target]: - cfg._usage() +if not (cfg.info or cfg.contract_data): + if len(cfg._args) < {'tx': 1, 'swaptx': 2}[target]: + cfg._usage() async def main(): diff --git a/mmgen/proto/xmr/tw/unspent.py b/mmgen/proto/xmr/tw/unspent.py index 0ad03c93..a44a1da2 100755 --- a/mmgen/proto/xmr/tw/unspent.py +++ b/mmgen/proto/xmr/tw/unspent.py @@ -22,11 +22,12 @@ class MoneroTwUnspentOutputs(MoneroTwView, TwUnspentOutputs): desc = 'spendable accounts' include_empty = False - prompt_fs_in = [ - 'Sort options: [a]mount, [A]ge, a[d]dr, [M]mgen addr, [r]everse', - 'Display options: r[e]draw screen', - 'View/Print: pager [v]iew, [w]ide pager view, [p]rint to file{s}', - 'Actions: [q]uit menu, add [l]abel, [R]efresh balances:'] - extra_key_mappings = { - 'R': 'a_sync_wallets', - 'A': 's_age'} + async def __init__(self, cfg, proto, *, minconf=1, addrs=[], tx=None): + self.prompt_fs_in = [ + 'Sort options: [a]mount, [A]ge, a[d]dr, [M]mgen addr, [r]everse', + 'View/Print: pager [v]iew, [w]ide pager view, [p]rint to file{s}', + 'Actions: [q]uit menu, add [l]abel, r[e]draw, [R]efresh balances:'] + self.extra_key_mappings = { + 'R': 'a_sync_wallets', + 'A': 's_age'} + await super().__init__(cfg, proto, minconf=minconf, addrs=addrs, tx=tx) diff --git a/mmgen/proto/xmr/tx/new.py b/mmgen/proto/xmr/tx/new.py index 0dfed000..6879fe08 100755 --- a/mmgen/proto/xmr/tx/new.py +++ b/mmgen/proto/xmr/tx/new.py @@ -41,15 +41,21 @@ class New(Base, TxNew): msg(f'Account number must be an integer between 1 and {len(accts_data)} inclusive') async def compat_create(self): + + if True: + op = 'transfer' + i = self.inputs[0] + o = self.outputs[0] + spec = f'{i.idx}:{i.acct_idx}:{o.addr},{o.amt}' + from ....xmrwallet import op as xmrwallet_op - i = self.inputs[0] - o = self.outputs[0] op = xmrwallet_op( - 'transfer', + op, self.cfg, None, None, - spec = f'{i.idx}:{i.acct_idx}:{o.addr},{o.amt}', + spec = spec, compat_call = True) + await op.restart_wallet_daemon() return await op.main() diff --git a/mmgen/tw/view.py b/mmgen/tw/view.py index 6e381bbf..c330c7da 100755 --- a/mmgen/tw/view.py +++ b/mmgen/tw/view.py @@ -588,6 +588,12 @@ class TwView(MMGenObject, metaclass=AsyncInit): self.key_mappings.update(self.scroll_keys[sys.platform]) return self.key_mappings + def cleanup(add_nl=False): + if add_nl: + msg('') + if self.scroll: + self.term.set('echo') + scroll = self.scroll = self.cfg.scroll key_mappings = make_key_mappings(scroll) @@ -635,10 +641,7 @@ class TwView(MMGenObject, metaclass=AsyncInit): arg = action_methods[ch] await func(self, arg) if isAsync(func) else func(self, arg) case 'q': - msg('') - if self.scroll: - self.term.set('echo') - return + return cleanup(add_nl=True) case _: if not scroll: msg_r('\ninvalid keypress ') @@ -704,7 +707,7 @@ class TwView(MMGenObject, metaclass=AsyncInit): @enable_echo async def run(self, parent, action_method): - await parent.post_action_cleanup(await action_method(parent)) + return await parent.post_action_cleanup(await action_method(parent)) async def a_print_detail(self, parent): return await self._print(parent, output_type='detail') @@ -780,7 +783,7 @@ class TwView(MMGenObject, metaclass=AsyncInit): break await asyncio.sleep(0.5) - await parent.post_action_cleanup(ret) + return await parent.post_action_cleanup(ret) async def i_balance_refresh(self, parent, idx, acct_addr_idx=None): if not parent.keypress_confirm( diff --git a/mmgen/tx/new.py b/mmgen/tx/new.py index d6613d89..4ba550c4 100755 --- a/mmgen/tx/new.py +++ b/mmgen/tx/new.py @@ -530,6 +530,8 @@ class New(Base): await self.update_vault_output(self.vault_output.amt) if self.is_compat: + del self.twctl + del self.twuo.twctl return await self.compat_create() await self.create_serialized(locktime=locktime) # creates self.txid too