From b6a9c100989598bf09e7b60277fb9371fd4d3663 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Tue, 15 Sep 2026 10:51:04 +0000 Subject: [PATCH] tx: improve handling of keyword args --- mmgen/obj.py | 10 +--------- mmgen/tx/base.py | 8 ++++---- mmgen/tx/bump.py | 6 +++--- mmgen/tx/new_swap.py | 6 +++--- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/mmgen/obj.py b/mmgen/obj.py index 3da5c648..84f8c52d 100755 --- a/mmgen/obj.py +++ b/mmgen/obj.py @@ -24,7 +24,7 @@ import unicodedata from .objmethods import MMGenObject, Hilite, HiliteStr, InitErrors -def get_obj(objname, *args, **kwargs): +def get_obj(objname, *args, silent=False, return_bool=False, **kwargs): """ Wrapper for data objects - If the object throws an exception on instantiation, return False, otherwise return the object. @@ -34,14 +34,6 @@ def get_obj(objname, *args, **kwargs): """ assert not args, 'get_obj_chk1' - silent, return_bool = (False, False) - if 'silent' in kwargs: - silent = kwargs['silent'] - del kwargs['silent'] - if 'return_bool' in kwargs: - return_bool = kwargs['return_bool'] - del kwargs['return_bool'] - try: ret = objname(**kwargs) except Exception as e: diff --git a/mmgen/tx/base.py b/mmgen/tx/base.py index 9196ec1e..b605d0c7 100755 --- a/mmgen/tx/base.py +++ b/mmgen/tx/base.py @@ -119,13 +119,13 @@ class Base(MMGenObject): class OutputList(MMGenTxIOList): desc = 'transaction outputs' - def __init__(self, *args, **kwargs): - self.cfg = kwargs['cfg'] + def __init__(self, *, cfg, proto, twctl=None, **kwargs): + self.cfg = cfg self.inputs = self.InputList(self) self.outputs = self.OutputList(self) self.name = type(self).__name__ - self.proto = kwargs['proto'] - self.twctl = kwargs.get('twctl') + self.proto = proto + self.twctl = twctl self.is_token = 'Token' in self.name @property diff --git a/mmgen/tx/bump.py b/mmgen/tx/bump.py index ee11ca19..99924f93 100755 --- a/mmgen/tx/bump.py +++ b/mmgen/tx/bump.py @@ -23,9 +23,9 @@ class Bump(Completed, NewSwap): bump_output_idx = None is_bump = True - def __init__(self, *, check_sent, new_outputs, **kwargs): + def __init__(self, *, cfg, check_sent, new_outputs, **kwargs): - super().__init__(**kwargs) + super().__init__(cfg=cfg, **kwargs) self.new_outputs = new_outputs self.orig_rel_fee = self.get_orig_rel_fee() @@ -36,7 +36,7 @@ class Bump(Completed, NewSwap): for attr in self.swap_attrs: setattr(self, attr, None) self.outputs = self.OutputList(self) - self.cfg = kwargs['cfg'] # must use current cfg opts, not those from orig_tx + self.cfg = cfg # must use current cfg opts, not those from orig_tx elif self.is_swap and self.is_token: die(1, orange('Fee-bumping of token swap transactions currently not supported.\n') + diff --git a/mmgen/tx/new_swap.py b/mmgen/tx/new_swap.py index b7d96831..4685dbba 100755 --- a/mmgen/tx/new_swap.py +++ b/mmgen/tx/new_swap.py @@ -41,10 +41,10 @@ class NewSwap(New): desc = 'swap transaction' swap_quote_refresh_timeout = 30 - def __init__(self, *args, **kwargs): + def __init__(self, *, cfg, **kwargs): self.is_swap = True - self.swap_proto = kwargs['cfg'].swap_proto - New.__init__(self, *args, **kwargs) + self.swap_proto = cfg.swap_proto + New.__init__(self, cfg=cfg, **kwargs) def check_addr_is_wallet_addr(self, output, *, message): if not output.mmid: