Browse Source

minor fixes and cleanups

The MMGen Project 5 months ago
parent
commit
9be29a0521

+ 1 - 0
mmgen/proto/btc/tx/info.py

@@ -18,6 +18,7 @@ from ....color import red, green, blue, pink
 from ....addr import MMGenID
 
 class TxInfo(TxInfo):
+
 	sort_orders = ('addr', 'raw')
 	txinfo_hdr_fs = '{hdr}\n  ID={i} ({a} {c}) RBF={r} Sig={s} Locktime={l}\n'
 	txinfo_hdr_fs_short = 'TX {i} ({a} {c}) RBF={r} Sig={s} Locktime={l}\n'

+ 1 - 3
mmgen/proto/btc/tx/online.py

@@ -13,7 +13,7 @@ proto.btc.tx.online: Bitcoin online signed transaction class
 """
 
 from ....tx import online as TxBase
-from ....util import msg, ymsg, die
+from ....util import msg, die
 from ....color import orange
 from .signed import Signed
 
@@ -47,10 +47,8 @@ class OnlineSigned(Signed, TxBase.OnlineSigned):
 		if ret['allowed']:
 			from ....obj import CoinTxID
 			msg('TxID: {}'.format(CoinTxID(ret['txid']).hl()))
-			msg('Transaction can be sent')
 			return True
 		else:
-			ymsg('Transaction cannot be sent')
 			msg(ret['reject-reason'])
 			return False
 

+ 9 - 19
mmgen/proto/eth/tx/info.py

@@ -12,27 +12,21 @@
 proto.eth.tx.info: Ethereum transaction info class
 """
 
-from ....tx.info import TxInfo
-from ....util import fmt, pp_fmt
+from ....tx.info import TxInfo, mmid_disp
+from ....util import pp_fmt
 from ....color import red, yellow, blue, cyan, pink
-from ....addr import MMGenID
 from ....obj import Int
 
 class TxInfo(TxInfo):
-	txinfo_hdr_fs = '{hdr}\n  ID={i} ({a} {c}) Sig={s} Locktime={l}\n'
-	txinfo_hdr_fs_short = 'TX {i} ({a} {c}) Sig={s} Locktime={l}\n'
-	txinfo_ftr_fs = fmt("""
-		Total in account:  {i} {d}
-		Total to spend:    {o} {d}
-		Remaining balance: {C} {d}
-		TX fee:            {a} {c}{r}
-	""")
+
 	to_addr_key = 'to'
 
 	def format_body(self, blockcount, nonmm_str, max_mmwid, enl, *, terse, sort):
 		tx = self.tx
-		def mmid_disp(io):
-			return ' ' + (io.mmid.hl() if io.mmid else MMGenID.hlc(nonmm_str))
+		t = tx.txobj
+		td = t['data']
+		to_addr = t[self.to_addr_key]
+		tokenswap = tx.is_swap and tx.is_token
 		fs = """
 			From:      {f}{f_mmid}
 			{toaddr}   {t}{t_mmid}{tvault}
@@ -42,10 +36,6 @@ class TxInfo(TxInfo):
 			Nonce:     {n}
 			Data:      {d}
 		""".strip().replace('\t', '') + ('\nMemo:      {m}' if tx.is_swap else '')
-		t = tx.txobj
-		td = t['data']
-		to_addr = t[self.to_addr_key]
-		tokenswap = tx.is_swap and tx.is_token
 		return fs.format(
 			f      = t['from'].hl(0),
 			t      = to_addr.hl(0) if to_addr else blue('None'),
@@ -59,8 +49,8 @@ class TxInfo(TxInfo):
 			g      = yellow(tx.pretty_fmt_fee(t['gasPrice'].to_unit('Gwei'))),
 			G      = Int(tx.total_gas).hl(),
 			G_dec  = red(f" ({t['startGas']} + {t['router_gas']})") if tokenswap else '',
-			f_mmid = mmid_disp(tx.inputs[0]),
-			t_mmid = mmid_disp(tx.outputs[0]) if tx.outputs and not tx.is_swap else '') + '\n\n'
+			f_mmid = mmid_disp(tx.inputs[0], nonmm_str),
+			t_mmid = mmid_disp(tx.outputs[0], nonmm_str) if tx.outputs and not tx.is_swap else '') + '\n\n'
 
 	def format_abs_fee(self, iwidth, /, *, color=None):
 		return self.tx.fee.fmt(iwidth, color=color) + (' (max)' if self.tx.txobj['data'] else '')

+ 1 - 1
mmgen/protocol.py

@@ -46,7 +46,7 @@ class CoinProtocol(MMGenObject):
 		'eth': proto_info('Ethereum',        4),
 		'etc': proto_info('EthereumClassic', 4),
 		'zec': proto_info('Zcash',           2),
-		'xmr': proto_info('Monero',          4),
+		'xmr': proto_info('Monero',          5),
 		'rune': proto_info('THORChain',      2)
 	}
 

+ 14 - 1
mmgen/tx/info.py

@@ -16,11 +16,24 @@ import importlib
 
 from ..cfg import gc
 from ..color import red, green, cyan, orange, blue, yellow, magenta
-from ..util import msg, msg_r, decode_timestamp, make_timestr
+from ..util import msg, msg_r, fmt, decode_timestamp, make_timestr
 from ..util2 import format_elapsed_hr
+from ..addr import MMGenID
+
+def mmid_disp(io, nonmm_str):
+	return ' ' + (io.mmid.hl() if io.mmid else MMGenID.hlc(nonmm_str))
 
 class TxInfo:
 
+	txinfo_hdr_fs = '{hdr}\n  ID={i} ({a} {c}) Sig={s}\n'
+	txinfo_hdr_fs_short = 'TX {i} ({a} {c}) Sig={s}\n'
+	txinfo_ftr_fs = fmt("""
+		Total in account:  {i} {d}
+		Total to spend:    {o} {d}
+		Remaining balance: {C} {d}
+		TX fee:            {a} {c}{r}
+	""")
+
 	def __init__(self, cfg, tx):
 		self.cfg = cfg
 		self.tx = tx

+ 9 - 5
mmgen/tx/online.py

@@ -14,7 +14,7 @@ tx.online: online signed transaction class
 
 import sys, time, asyncio
 
-from ..util import msg, Msg, ymsg, make_timestr, die
+from ..util import msg, Msg, gmsg, ymsg, make_timestr, die
 from ..color import pink, yellow
 
 from .signed import Signed, AutomountSigned
@@ -113,16 +113,20 @@ class OnlineSigned(Signed):
 					if cfg.test:
 						break
 				elif cfg.test:
-					await self.test_sendable(txhex)
+					if await self.test_sendable(txhex):
+						gmsg('Transaction can be sent')
+					else:
+						ymsg('Transaction cannot be sent')
 				else: # node send
 					msg(f'Sending TX: {coin_txid.hl()}')
-					if not cfg.bogus_send:
+					if cfg.bogus_send:
+						msg(f'BOGUS transaction NOT sent: {coin_txid.hl()}')
+					else:
 						if idx != '':
 							await asyncio.sleep(1)
 						ret = await self.send_with_node(txhex)
 						assert ret == coin_txid, f'txid mismatch (after sending) ({ret} != {coin_txid})'
-					desc = 'BOGUS transaction NOT' if cfg.bogus_send else 'Transaction'
-					msg(desc + ' sent: ' + coin_txid.hl())
+						msg(f'Transaction sent: {coin_txid.hl()}')
 					sent_status = 'no_confirm_post_send'
 
 				if cfg.wait and sent_status:

+ 5 - 5
test/cmdtest_d/rune.py

@@ -28,8 +28,9 @@ class CmdTestRune(CmdTestEthdevMethods, CmdTestBase, CmdTestShared):
 	menu_prompt = 'efresh balance:\b'
 
 	cmd_group_in = (
-		('subgroup.init',     []),
-		('subgroup.main',     ['init']),
+		('subgroup.init',        []),
+		('subgroup.main',        ['init']),
+		('thornode_server_stop', 'stopping Thornode server'),
 	)
 	cmd_subgroups = {
 		'init': (
@@ -39,9 +40,8 @@ class CmdTestRune(CmdTestEthdevMethods, CmdTestBase, CmdTestShared):
 		),
 		'main': (
 			'tracking wallet and transaction operations',
-			('twview',        'viewing unspent outputs in tracking wallet'),
-			('bal_refresh',   'refreshing address balance in tracking wallet'),
-			('thornode_server_stop', 'stopping Thornode server'),
+			('twview',               'viewing unspent outputs in tracking wallet'),
+			('bal_refresh',          'refreshing address balance in tracking wallet'),
 		),
 	}