From 106da663511f2e4c93dd63205035d0010589ca45 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 11 Sep 2026 14:10:55 +0000 Subject: [PATCH] improve setting of `is_signing`, `is_sending`; cmdtest.py ref_tx: add test --- mmgen/cfg.py | 5 ----- mmgen/main_autosign.py | 1 + mmgen/main_txsend.py | 6 +++++- mmgen/main_txsign.py | 2 +- test/cmdtest_d/ref.py | 1 + test/cmdtest_d/shared.py | 3 +++ 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/mmgen/cfg.py b/mmgen/cfg.py index b4d9b12b..0ca63aae 100755 --- a/mmgen/cfg.py +++ b/mmgen/cfg.py @@ -628,11 +628,6 @@ class Config(Lockable): if hasattr(self, 'bch_cashaddr') and not hasattr(self, 'cashaddr'): self.cashaddr = self.bch_cashaddr - if 'sign' in gc.prog_name: - self.is_signing = True - elif 'send' in gc.prog_name and not (hasattr(self, 'status') or hasattr(self, 'receipt')): - self.is_sending = True - self._lock() if need_proto: diff --git a/mmgen/main_autosign.py b/mmgen/main_autosign.py index eabbb52d..641870b9 100755 --- a/mmgen/main_autosign.py +++ b/mmgen/main_autosign.py @@ -101,6 +101,7 @@ from .autosign import Autosign cfg = Config( opts_data = opts_data, init_opts = { + 'is_signing': True, 'out_fmt': 'wallet', 'usr_randchars': 0, 'hash_preset': '1', diff --git a/mmgen/main_txsend.py b/mmgen/main_txsend.py index 4e954e7c..7e96bb45 100755 --- a/mmgen/main_txsend.py +++ b/mmgen/main_txsend.py @@ -30,6 +30,10 @@ opts_data = { ('yes', True, 'quiet', True), ('abort', True, 'autosign', True), ], + 'overrides': [ + ('status', True, 'is_sending', False), + ('receipt', True, 'is_sending', False), + ], 'text': { 'desc': f'Send a signed {gc.proj_name} cryptocoin transaction', 'usage2': [ @@ -87,7 +91,7 @@ recent. } } -cfg = Config(opts_data=opts_data) +cfg = Config(opts_data=opts_data, init_opts={'is_sending': True}) if cfg.autosign and cfg.outdir: die(1, '--outdir cannot be used in combination with --autosign') diff --git a/mmgen/main_txsign.py b/mmgen/main_txsign.py index 800b40d0..080e501f 100755 --- a/mmgen/main_txsign.py +++ b/mmgen/main_txsign.py @@ -94,7 +94,7 @@ column below:{n_fc}""" } } -cfg = Config(opts_data=opts_data) +cfg = Config(opts_data=opts_data, init_opts={'is_signing': True}) if not cfg._args: cfg._usage() diff --git a/test/cmdtest_d/ref.py b/test/cmdtest_d/ref.py index 3f8e5fc3..077b6ebb 100755 --- a/test/cmdtest_d/ref.py +++ b/test/cmdtest_d/ref.py @@ -348,6 +348,7 @@ class CmdTestRefTX(CmdTestRef): self._get_txfile(0), save = False, has_label = True, + expect_str = 'legacy-format', view = 'y') def _ref_txfile_chk(self, cfgfile_lines=[], *, idx, ver=None, allowed=False): diff --git a/test/cmdtest_d/shared.py b/test/cmdtest_d/shared.py index 93fd067d..0b96ad65 100755 --- a/test/cmdtest_d/shared.py +++ b/test/cmdtest_d/shared.py @@ -231,6 +231,7 @@ class CmdTestShared: has_label = False, extra_opts = [], extra_desc = '', + expect_str = None, view = 'n', dfl_wallet = False): opts = extra_opts + ['-d', self.tmpdir, txfile] + ([wf] if wf else []) @@ -242,6 +243,8 @@ class CmdTestShared: no_passthru_opts = ['coin'], exit_val = None if save or (wcls.enc and wcls.type != 'brain') else 1) t.license() + if expect_str: + t.expect(expect_str) t.view_tx(view) if wcls.enc and wcls.type != 'brain': t.passphrase(wcls.desc, self.wpasswd)