Browse Source

NewTX, BumpTX: remove unnecessary async call

The MMGen Project 6 months ago
parent
commit
131787afb8

+ 1 - 1
mmgen/main_txbump.py

@@ -188,7 +188,7 @@ async def main():
 		msg(orig_tx.info.format(terse=True))
 
 	from .tw.ctl import TwCtl
-	tx = await BumpTX(
+	tx = BumpTX(
 		cfg  = cfg,
 		data = orig_tx.__dict__,
 		automount = cfg.autosign,

+ 1 - 1
mmgen/main_txcreate.py

@@ -135,7 +135,7 @@ async def main():
 		proto = cfg._proto
 
 	from .tx import NewTX
-	tx1 = await NewTX(cfg=cfg, proto=proto, target=target)
+	tx1 = NewTX(cfg=cfg, proto=proto, target=target)
 
 	tx2 = await tx1.create(
 		cmd_args = cfg._args,

+ 1 - 1
mmgen/main_txdo.py

@@ -170,7 +170,7 @@ async def main():
 	else:
 		proto = cfg._proto
 
-	tx1 = await NewTX(cfg=cfg, proto=proto, target=target)
+	tx1 = NewTX(cfg=cfg, proto=proto, target=target)
 
 	tx2 = await tx1.create(
 		cmd_args = cfg._args,

+ 1 - 1
mmgen/proto/btc/tx/unsigned.py

@@ -67,7 +67,7 @@ class Unsigned(Completed, TxBase.Unsigned):
 		try:
 			self.update_serialized(ret['hex'])
 			from ....tx import SignedTX
-			new = await SignedTX(cfg=self.cfg, data=self.__dict__, automount=self.automount)
+			new = SignedTX(cfg=self.cfg, data=self.__dict__, automount=self.automount)
 			tx_decoded = await self.rpc.call('decoderawtransaction', ret['hex'])
 			new.compare_size_and_estimated_size(tx_decoded)
 			new.coin_txid = CoinTxID(self.deserialized.txid)

+ 1 - 1
mmgen/proto/eth/tx/new.py

@@ -246,7 +246,7 @@ class TokenNew(TokenBase, New):
 
 		data = t.create_transfer_data(
 			to_addr = to_addr or self.outputs[0].addr,
-			amt = self.outputs[0].amt or await self.twuo.twctl.get_balance(self.inputs[0].addr),
+			amt = self.outputs[0].amt or await self.twctl.get_balance(self.inputs[0].addr),
 			op = self.token_op)
 
 		try:

+ 1 - 1
mmgen/proto/eth/tx/unsigned.py

@@ -95,7 +95,7 @@ class Unsigned(Completed, TxBase.Unsigned):
 			await self.do_sign(o, keys[0].sec.wif)
 			msg('OK')
 			from ....tx import SignedTX
-			tx = await SignedTX(cfg=self.cfg, data=self.__dict__, automount=self.automount)
+			tx = SignedTX(cfg=self.cfg, data=self.__dict__, automount=self.automount)
 			tx.check_serialized_integrity()
 			return tx
 		except Exception as e:

+ 4 - 6
mmgen/tx/__init__.py

@@ -77,8 +77,6 @@ async def _get_obj_async(_clsname, _modname, **kwargs):
 	# No twctl required for the Unsigned and Signed(data=unsigned.__dict__) classes used during
 	# signing.
 	if proto and proto.tokensym and clsname in (
-			'New',
-			'NewSwap',
 			'OnlineSigned',
 			'AutomountOnlineSigned',
 			'Sent',
@@ -95,12 +93,12 @@ def _get_async(clsname, modname):
 	return lambda **kwargs: _get_obj_async(clsname, modname, **kwargs)
 
 BaseTX         = _get('Base',     'base')
+NewTX          = _get('New',      'new')
+NewSwapTX      = _get('NewSwap',  'new_swap')
+BumpTX         = _get('Bump',     'bump')
 UnsignedTX     = _get('Unsigned', 'unsigned')
+SignedTX       = _get('Signed',   'signed')
 
-NewTX          = _get_async('New',          'new')
-NewSwapTX      = _get_async('NewSwap',      'new_swap')
 CompletedTX    = _get_async('Completed',    'completed')
-SignedTX       = _get_async('Signed',       'signed')
 OnlineSignedTX = _get_async('OnlineSigned', 'online')
 SentTX         = _get_async('Sent',         'online')
-BumpTX         = _get_async('Bump',         'bump')

+ 2 - 0
mmgen/tx/new.py

@@ -469,6 +469,7 @@ class New(Base):
 				minconf = self.cfg.minconf,
 				addrs = await self.get_input_addrs_from_inputs_opt())
 			await self.twuo.get_data()
+			self.twctl = self.twuo.twctl
 
 		from ..ui import do_license_msg
 		do_license_msg(self.cfg)
@@ -480,6 +481,7 @@ class New(Base):
 			self.twuo.display_total()
 
 		if do_info:
+			del self.twctl
 			del self.twuo.twctl
 			import sys
 			sys.exit(0)

+ 1 - 1
test/daemontest_d/tx.py

@@ -114,7 +114,7 @@ class unit_tests:
 		d.start()
 
 		proto = init_proto(cfg, 'btc', need_amt=True)
-		await NewTX(cfg=cfg, proto=proto, target='tx')
+		NewTX(cfg=cfg, proto=proto, target='tx')
 
 		d.stop()
 		d.remove_datadir()