From 56a39244f7299c6f4581877953c076e1db2a38b4 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Wed, 30 Oct 2019 09:23:54 +0000 Subject: [PATCH] a few minor cleanups and fixes --- mmgen/bip39.py | 4 ++-- mmgen/tool.py | 4 +++- mmgen/util.py | 4 ++-- test/tooltest2.py | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/mmgen/bip39.py b/mmgen/bip39.py index ec973d91..40e27e6b 100755 --- a/mmgen/bip39.py +++ b/mmgen/bip39.py @@ -2114,8 +2114,8 @@ zoo wl = cls.digits[wl_id] - for n in range(len(words)): - if words[n] not in wl: + for n,w in enumerate(words): + if w not in wl: raise MnemonicError('word #{} is not in the BIP39 word list'.format(n+1)) res = ''.join(['{:011b}'.format(wl.index(w)) for w in words]) diff --git a/mmgen/tool.py b/mmgen/tool.py index 25cc078d..da1b974f 100755 --- a/mmgen/tool.py +++ b/mmgen/tool.py @@ -70,13 +70,15 @@ def _usage(cmd=None,exit_val=1): 'EXAMPLES:\n\n' ' Generate a random Bech32 public/private keypair for LTC:\n' ' $ mmgen-tool -r0 --coin=ltc --type=bech32 randpair\n\n' + ' Generate a DASH compressed public key address from the supplied WIF key:\n' + ' $ mmgen-tool --coin=dash --type=compressed wif2addr XJkVRC3eGKurc9Uzx1wfQoio3yqkmaXVqLMTa6y7s3M3jTBnmxfw\n\n' ' Generate a well-known burn address:\n' ' $ mmgen-tool hextob58chk 000000000000000000000000000000000000000000\n\n' ' Generate a random 12-word seed phrase:\n' ' $ mmgen-tool -r0 mn_rand128\n\n' ' Same as above, but get additional entropy from user:\n' ' $ mmgen-tool mn_rand128\n\n' - ' Convert a string to base 58:\n' + ' Encode bytes from a file to base 58:\n' ' $ mmgen-tool bytestob58 /etc/timezone pad=20\n\n' ' Reverse a hex string:\n' ' $ mmgen-tool hexreverse "deadbeefcafe"\n\n' diff --git a/mmgen/util.py b/mmgen/util.py index c974b8f9..bd121319 100755 --- a/mmgen/util.py +++ b/mmgen/util.py @@ -268,13 +268,13 @@ def is_hex_str(s): return set(list(s.lower())) <= set(list(hexdigits.lower()) def is_hex_str_lc(s): return set(list(s)) <= set(list(hexdigits.lower())) def is_hex_str_uc(s): return set(list(s)) <= set(list(hexdigits.upper())) +def is_utf8(s): + return is_ascii(s,enc='utf8') def is_ascii(s,enc='ascii'): try: s.decode(enc) except: return False else: return True -def is_utf8(s): return is_ascii(s,enc='utf8') - def match_ext(addr,ext): return addr.split('.')[-1] == ext diff --git a/test/tooltest2.py b/test/tooltest2.py index 32fef564..fa378522 100755 --- a/test/tooltest2.py +++ b/test/tooltest2.py @@ -276,7 +276,7 @@ tests = { ], 'randb58': [ ( [], {'boolfunc':is_b58_str}, ['-r0'] ), - ( ['nbytes=16'], {'boolfunc':is_b58_str,'len':22}, ['-r0'] ), + ( ['nbytes=16'], {'boolfunc':is_b58_str}, ['-r0'] ), ( ['nbytes=12','pad=0'], is_b58_str, ['-r0'] ), ], },