From 5c83192bfd7f27e8d4d398beaa1484eec4a3a5fc Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 13 Jun 2025 10:23:50 +0000 Subject: [PATCH] minor cleanups --- mmgen/proto/cosmos/tx/protobuf.py | 1 - mmgen/proto/eth/tx/info.py | 6 +++--- mmgen/proto/rune/rpc/remote.py | 6 +++--- mmgen/proto/rune/tx/online.py | 4 ++-- mmgen/proto/vm/tx/new.py | 2 +- mmgen/tw/view.py | 1 + nix/user-packages.nix | 1 + scripts/create-bip-hd-chain-params.py | 1 - test/modtest_d/rune.py | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/mmgen/proto/cosmos/tx/protobuf.py b/mmgen/proto/cosmos/tx/protobuf.py index e043f747..e72fee1f 100755 --- a/mmgen/proto/cosmos/tx/protobuf.py +++ b/mmgen/proto/cosmos/tx/protobuf.py @@ -169,5 +169,4 @@ def make_sig(*, sign_doc, sec_bytes): from py_ecc.secp256k1.secp256k1 import ecdsa_raw_sign msghash = sha256(bytes(sign_doc)).digest() _, r, s = ecdsa_raw_sign(msghash, sec_bytes) - # pmsg('v:', _) # DEBUG return r.to_bytes(length=32) + s.to_bytes(length=32) diff --git a/mmgen/proto/eth/tx/info.py b/mmgen/proto/eth/tx/info.py index a7dd1672..a8b730ea 100755 --- a/mmgen/proto/eth/tx/info.py +++ b/mmgen/proto/eth/tx/info.py @@ -13,9 +13,8 @@ proto.eth.tx.info: Ethereum transaction info class """ from ....tx.info import TxInfo, mmid_disp -from ....util import pp_fmt from ....color import red, yellow, blue, cyan, pink -from ....obj import Int +from ....obj import NonNegativeInt class TxInfo(TxInfo): @@ -47,7 +46,7 @@ class TxInfo(TxInfo): m = pink(tx.swap_memo) if tx.is_swap else None, c = tx.proto.dcoin if len(tx.outputs) else '', g = yellow(tx.pretty_fmt_fee(t['gasPrice'].to_unit('Gwei'))), - G = Int(tx.total_gas).hl(), + G = NonNegativeInt(tx.total_gas).hl(), G_dec = red(f" ({t['startGas']} + {t['router_gas']})") if tokenswap else '', 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' @@ -62,6 +61,7 @@ class TxInfo(TxInfo): def format_verbose_footer(self): if self.tx.txobj['data'] and not self.tx.is_swap: + from ....util import pp_fmt from ..contract import parse_abi return '\nParsed contract data: ' + pp_fmt(parse_abi(self.tx.txobj['data'])) else: diff --git a/mmgen/proto/rune/rpc/remote.py b/mmgen/proto/rune/rpc/remote.py index 2eefd009..fd384580 100755 --- a/mmgen/proto/rune/rpc/remote.py +++ b/mmgen/proto/rune/rpc/remote.py @@ -77,11 +77,11 @@ class THORChainRemoteRPCClient(RemoteRPCClient): data = {'hash': '0x' + txhash}), errmsg = f'get info for transaction {txhash} failed') - def tx_op(self, txbytes, op=None): - assert isinstance(txbytes, bytes) + def tx_op(self, txhex, op=None): + assert isinstance(txhex, str) assert op in ('check_tx', 'broadcast_tx_sync', 'broadcast_tx_async') return process_response( self.rpc_api.post( path = '/' + op, - data = {'tx': '0x' + txbytes.hex()}), + data = {'tx': '0x' + txhex}), errmsg = f'transaction operation ‘{op}’ failed') diff --git a/mmgen/proto/rune/tx/online.py b/mmgen/proto/rune/tx/online.py index 1843f26b..74b4c929 100755 --- a/mmgen/proto/rune/tx/online.py +++ b/mmgen/proto/rune/tx/online.py @@ -20,7 +20,7 @@ from .signed import Signed class OnlineSigned(Signed, TxBase.OnlineSigned): async def test_sendable(self, txhex): - res = self.rpc.tx_op(bytes.fromhex(txhex), op='check_tx') + res = self.rpc.tx_op(txhex, op='check_tx') if res['code'] == 0: return True else: @@ -31,7 +31,7 @@ class OnlineSigned(Signed, TxBase.OnlineSigned): pass async def send_with_node(self, txhex): - res = self.rpc.tx_op(bytes.fromhex(txhex), op='broadcast_tx_sync') # broadcast_tx_async + res = self.rpc.tx_op(txhex, op='broadcast_tx_sync') # broadcast_tx_async if res['code'] == 0: return res['hash'].lower() else: diff --git a/mmgen/proto/vm/tx/new.py b/mmgen/proto/vm/tx/new.py index 198a8eef..071084fe 100755 --- a/mmgen/proto/vm/tx/new.py +++ b/mmgen/proto/vm/tx/new.py @@ -9,7 +9,7 @@ # https://gitlab.com/mmgen/mmgen-wallet """ -proto.vm.tx.new: new transaction class methods for VM chains +proto.vm.tx.new: new transaction methods for VM chains """ from ....obj import MMGenTxID diff --git a/mmgen/tw/view.py b/mmgen/tw/view.py index a207f606..47caa5a6 100755 --- a/mmgen/tw/view.py +++ b/mmgen/tw/view.py @@ -734,6 +734,7 @@ class TwView(MMGenObject, metaclass=AsyncInit): if not parent.keypress_confirm( f'Refreshing tracking wallet {parent.item_desc} #{idx}. OK?'): return 'redo' + msg_r('Refreshing balance...') res = await parent.twctl.get_balance(parent.disp_data[idx-1].addr, force_rpc=True) if res is None: parent.oneshot_msg = red( diff --git a/nix/user-packages.nix b/nix/user-packages.nix index 04a92f81..3943bcf2 100644 --- a/nix/user-packages.nix +++ b/nix/user-packages.nix @@ -44,5 +44,6 @@ rec { # pysocks = pysocks; # XMR # monero = monero; # XMR (test suite) # eth-keys = eth-keys; # ETH, ETC (test suite) + # pure-protobuf = pure-protobuf; # THORChain }; } diff --git a/scripts/create-bip-hd-chain-params.py b/scripts/create-bip-hd-chain-params.py index 843d4c57..29ef5178 100755 --- a/scripts/create-bip-hd-chain-params.py +++ b/scripts/create-bip-hd-chain-params.py @@ -46,7 +46,6 @@ dfl_dfl_path = "0'/0/0" def get_bip_utils_data(bipnum, n): name, v = bip_utils_data[bipnum][n] - #pexit(v.__dict__) vb_prv = v.m_key_net_ver.m_priv_net_ver.hex() vb_pub = v.m_key_net_ver.m_pub_net_ver.hex() ap = v.m_addr_params diff --git a/test/modtest_d/rune.py b/test/modtest_d/rune.py index 62b41b15..7d1e2304 100755 --- a/test/modtest_d/rune.py +++ b/test/modtest_d/rune.py @@ -221,7 +221,7 @@ class unit_tests: res = rpc.get_tx_info(txhash) assert res['hash'] == txhash.upper() - res = rpc.tx_op(txbytes, op='check_tx') + res = rpc.tx_op(txbytes.hex(), op='check_tx') assert res['code'] == 0 asyncio.run(main())