diff --git a/mmgen/base_proto/ethereum/pyethereum/utils.py b/mmgen/base_proto/ethereum/pyethereum/utils.py index 7262f997..3dca7ad8 100644 --- a/mmgen/base_proto/ethereum/pyethereum/utils.py +++ b/mmgen/base_proto/ethereum/pyethereum/utils.py @@ -6,15 +6,11 @@ from py_ecc.secp256k1 import privtopub,ecdsa_raw_sign,ecdsa_raw_recover from .. import rlp from ..rlp.sedes import Binary -from mmgen.globalvars import g -try: - assert not g.use_internal_keccak_module - import sha3 as _sha3 - def sha3_256(x): return _sha3.keccak_256(x).digest() -except: - from mmgen.keccak import keccak_256 - def sha3_256(x): - return keccak_256(x).digest() +from ....util import get_keccak +keccak_256 = get_keccak() + +def sha3_256(bstr): + return keccak_256(bstr).digest() import struct ALL_BYTES = tuple( struct.pack('B', i) for i in range(256) ) diff --git a/mmgen/daemon.py b/mmgen/daemon.py index bb4472d3..add5c87c 100755 --- a/mmgen/daemon.py +++ b/mmgen/daemon.py @@ -25,7 +25,7 @@ from subprocess import run,PIPE,CompletedProcess from collections import namedtuple from .globalvars import g -from .util import msg,die +from .util import msg,Msg_r,die from .flags import * _dd = namedtuple('daemon_data',['coind_name','coind_version','coind_version_str']) # latest tested version diff --git a/mmgen/main_autosign.py b/mmgen/main_autosign.py index 6100e264..e8cf0144 100755 --- a/mmgen/main_autosign.py +++ b/mmgen/main_autosign.py @@ -168,6 +168,7 @@ async def check_daemons_running(): proto = init_proto(coin,testnet=g.testnet,need_amt=True) if proto.sign_mode == 'daemon': vmsg(f'Checking {coin} daemon') + from .exception import SocketError try: await rpc_init(proto) except SocketError as e: diff --git a/mmgen/msg.py b/mmgen/msg.py index 7867d7e4..546c32e7 100755 --- a/mmgen/msg.py +++ b/mmgen/msg.py @@ -15,7 +15,7 @@ msg: base message signing classes import os,importlib,json from .globalvars import g from .objmethods import MMGenObject,Hilite,InitErrors -from .util import msg,vmsg,die,suf,make_chksum_6,fmt_list,remove_dups +from .util import msg,die,suf,make_chksum_6,fmt_list,remove_dups from .color import red,orange,grnbg from .protocol import init_proto from .fileutil import get_data_from_file,write_data_to_file diff --git a/mmgen/opts.py b/mmgen/opts.py index 116b6fc7..56f50b0a 100755 --- a/mmgen/opts.py +++ b/mmgen/opts.py @@ -57,8 +57,6 @@ def print_help(po,opts_data,opt_filter): opts_data['code']['long_options'] = common_opts_data['code'] def remove_unneeded_long_opts(): d = opts_data['text']['long_options'] - if g.prog_name != 'mmgen-tool': - d = '\n'.join(''+i for i in d.split('\n') if not '--monero-wallet' in i) if proto.base_proto != 'Ethereum': d = '\n'.join(''+i for i in d.split('\n') if not '--token' in i) opts_data['text']['long_options'] = d diff --git a/mmgen/tool/util.py b/mmgen/tool/util.py index 5f4f563e..2198d1ee 100755 --- a/mmgen/tool/util.py +++ b/mmgen/tool/util.py @@ -69,7 +69,7 @@ class tool_cmd(tool_cmd_base): "decode hexdump from file (use '-' for stdin) (warning: outputs binary data)" from ..globalvars import g if g.platform == 'win': - import msvcrt + import sys,os,msvcrt msvcrt.setmode( sys.stdout.fileno(), os.O_BINARY ) from ..fileutil import get_data_from_file from ..util import decode_pretty_hexdump diff --git a/mmgen/tx/info.py b/mmgen/tx/info.py index cf03556f..30fd309c 100755 --- a/mmgen/tx/info.py +++ b/mmgen/tx/info.py @@ -15,7 +15,7 @@ tx.info: transaction info class from ..globalvars import * from ..color import red,green,orange from ..opts import opt -from ..util import msg,msg_r +from ..util import msg,msg_r,do_pager import importlib diff --git a/setup.cfg b/setup.cfg index b6bd5176..c4c93400 100644 --- a/setup.cfg +++ b/setup.cfg @@ -23,7 +23,7 @@ python_requires = >=3.7 include_package_data = True # pysha3 is used by XMR and ETH for the keccak hash function only. If the -# module is not available, the native Python implementation in mmgen.keccak +# module is unavailable, the native Python implementation in contrib.keccak # will be used instead. install_requires = importlib-resources; python_version < "3.9" @@ -34,7 +34,7 @@ install_requires = requests pysocks # xmrwallet.py pexpect - scrypt; platform_system != "Windows" # requires user intervention to install on MSYS2 + scrypt; platform_system != "Windows" # must be installed by hand on MSYS2 semantic-version; platform_system != "Windows" # scripts/create-token.py aiohttp; platform_system != "Windows" pysha3; platform_system != "Windows" diff --git a/test/ref/713E94[BTC].rawmsg.json b/test/ref/997F55[BTC].rawmsg.json similarity index 90% rename from test/ref/713E94[BTC].rawmsg.json rename to test/ref/997F55[BTC].rawmsg.json index 95a21535..ec1ac40d 100644 --- a/test/ref/713E94[BTC].rawmsg.json +++ b/test/ref/997F55[BTC].rawmsg.json @@ -6,6 +6,7 @@ "99E0FC61:S:102" ], "message": "24/3/2022 Russia announces it will sell gas for bitcoin", + "msghash_type": "raw", "network": "btc_mainnet" }, "signatures": {} diff --git a/test/ref/9DA060[BTC].rawmsg.json b/test/ref/ED405C[BTC].rawmsg.json similarity index 90% rename from test/ref/9DA060[BTC].rawmsg.json rename to test/ref/ED405C[BTC].rawmsg.json index 407e9ad0..66302415 100644 --- a/test/ref/9DA060[BTC].rawmsg.json +++ b/test/ref/ED405C[BTC].rawmsg.json @@ -6,6 +6,7 @@ "DEADBEEF:C:1" ], "message": "08/Jun/2021 Bitcoin Law Enacted by El Salvador Legislative Assembly", + "msghash_type": "raw", "network": "btc_mainnet" }, "signatures": {} diff --git a/test/ref/litecoin/685D23[LTC].rawmsg.json b/test/ref/litecoin/6C01C6[LTC].rawmsg.json similarity index 89% rename from test/ref/litecoin/685D23[LTC].rawmsg.json rename to test/ref/litecoin/6C01C6[LTC].rawmsg.json index cc8bd82a..9dd6eeee 100644 --- a/test/ref/litecoin/685D23[LTC].rawmsg.json +++ b/test/ref/litecoin/6C01C6[LTC].rawmsg.json @@ -5,6 +5,7 @@ "98831F3A:B:1" ], "message": "24/3/2022 Russia announces it will sell gas for bitcoin", + "msghash_type": "raw", "network": "ltc_mainnet" }, "signatures": {} diff --git a/test/test-release.sh b/test/test-release.sh index 9010cd3b..41ba5cd8 100755 --- a/test/test-release.sh +++ b/test/test-release.sh @@ -134,10 +134,10 @@ do N) test_py+=" --no-timings" ;; O) test_py+=" --pexpect-spawn" ;; p) PAUSE=1 ;; - s) SKIP_LIST="$OPTARG" ;; + s) SKIP_LIST+=" $OPTARG" ;; t) LIST_CMDS=1 ;; v) EXACT_OUTPUT=1 test_py+=" --exact-output" ;& - V) VERBOSE=1 + V) VERBOSE='--verbose' [ "$EXACT_OUTPUT" ] || test_py+=" --verbose" unit_tests_py="${unit_tests_py/--quiet/--verbose}" altcoin_mod_opts="${altcoin_mod_opts/--quiet/--verbose}" diff --git a/test/test_py_d/ts_autosign.py b/test/test_py_d/ts_autosign.py index f28ad960..f5cb297e 100755 --- a/test/test_py_d/ts_autosign.py +++ b/test/test_py_d/ts_autosign.py @@ -264,7 +264,7 @@ class TestSuiteAutosignBase(TestSuiteBase): else: for fn in self.ref_msgfiles: if op == 'copy': - if os.path.basename(fn) == '9DA060[BTC].rawmsg.json': # contains bad Seed ID + if os.path.basename(fn) == 'ED405C[BTC].rawmsg.json': # contains bad Seed ID self.bad_msg_count += 1 else: self.good_msg_count += 1 diff --git a/test/test_py_d/ts_ethdev.py b/test/test_py_d/ts_ethdev.py index 5802d169..691a6623 100755 --- a/test/test_py_d/ts_ethdev.py +++ b/test/test_py_d/ts_ethdev.py @@ -383,11 +383,12 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared): for d in ('mm1','mm2'): copytree(os.path.join(srcdir,d),os.path.join(self.tmpdir,d)) + if g.daemon_id == 'geth' and not (opt.resume or opt.resume_after or opt.skip_deps): + self.geth_setup() + set_vt100() + # await geth_devnet_init_bug_workaround() # uncomment to enable testing with v1.10.17 + if not opt.no_daemon_autostart: - if g.daemon_id == 'geth': - self.geth_setup() - set_vt100() - # await geth_devnet_init_bug_workaround() # uncomment to enable testing with v1.10.17 if not start_test_daemons( self.proto.coin+'_rt', remove_datadir = not g.daemon_id in ('geth','erigon') ): @@ -438,7 +439,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared): def init_genesis(fn): cmd = f'geth init --datadir {d.datadir} {fn}' - cp = run(cmd.split(),stdout=PIPE,stderr=PIPE) + cp = run( cmd.split(), stdout=PIPE, stderr=PIPE ) if cp.returncode: die(1,cp.stderr.decode())