tx: improve handling of keyword args
This commit is contained in:
parent
5a1a36bf79
commit
b6a9c10098
4 changed files with 11 additions and 19 deletions
10
mmgen/obj.py
10
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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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') +
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue