tx.new_swap: add initializer, swap_proto_mod attribute
This commit is contained in:
parent
809856c07d
commit
81e11f3405
4 changed files with 13 additions and 12 deletions
|
|
@ -41,10 +41,6 @@ class NewSwap(New, TxNewSwap):
|
|||
|
||||
async def process_swap_cmdline_args(self, cmd_args, addrfiles):
|
||||
|
||||
from ....protocol import init_proto
|
||||
import importlib
|
||||
sp = importlib.import_module(f'mmgen.swap.proto.{self.swap_proto}')
|
||||
|
||||
class CmdlineArgs: # listed in command-line order
|
||||
# send_coin # required: uppercase coin symbol
|
||||
send_amt = None # optional: Omit to skip change addr and send value of all inputs minus fees to vault
|
||||
|
|
@ -102,6 +98,8 @@ class NewSwap(New, TxNewSwap):
|
|||
if args_in: # done parsing, all args consumed
|
||||
self.cfg._usage()
|
||||
|
||||
from ....protocol import init_proto
|
||||
sp = self.swap_proto_mod
|
||||
args_in = list(cmd_args)
|
||||
args = CmdlineArgs()
|
||||
parse()
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@ class Bump(Completed, NewSwap):
|
|||
setattr(self, attr, getattr(Base, attr))
|
||||
self.outputs = self.OutputList(self)
|
||||
self.cfg = kwargs['cfg'] # must use current cfg opts, not those from orig_tx
|
||||
elif self.is_swap:
|
||||
import importlib
|
||||
self.swap_proto_mod = importlib.import_module(f'mmgen.swap.proto.{self.swap_proto}')
|
||||
|
||||
if not self.is_replaceable():
|
||||
die(1, f'Transaction {self.txid} is not replaceable')
|
||||
|
|
|
|||
|
|
@ -82,12 +82,6 @@ class New(Base):
|
|||
chg_autoselected = False
|
||||
_funds_available = namedtuple('funds_available', ['is_positive', 'amt'])
|
||||
|
||||
def __init__(self, *args, target=None, **kwargs):
|
||||
if target == 'swaptx':
|
||||
self.is_swap = True
|
||||
self.swap_proto = kwargs['cfg'].swap_proto
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def warn_insufficient_funds(self, amt, coin):
|
||||
msg(self.msg_insufficient_funds.format(amt.hl(), coin))
|
||||
|
||||
|
|
|
|||
|
|
@ -17,9 +17,15 @@ from .new import New
|
|||
class NewSwap(New):
|
||||
desc = 'swap transaction'
|
||||
|
||||
def update_vault_output(self, amt):
|
||||
def __init__(self, *args, **kwargs):
|
||||
import importlib
|
||||
sp = importlib.import_module(f'mmgen.swap.proto.{self.swap_proto}')
|
||||
self.is_swap = True
|
||||
self.swap_proto = kwargs['cfg'].swap_proto
|
||||
self.swap_proto_mod = importlib.import_module(f'mmgen.swap.proto.{self.swap_proto}')
|
||||
New.__init__(self, *args, **kwargs)
|
||||
|
||||
def update_vault_output(self, amt):
|
||||
sp = self.swap_proto_mod
|
||||
c = sp.rpc_client(self, amt)
|
||||
|
||||
from ..util import msg
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue