a few minor cleanups and fixes

This commit is contained in:
The MMGen Project 2019-10-30 09:23:54 +00:00
commit 56a39244f7
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 8 additions and 6 deletions

View file

@ -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])

View file

@ -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'

View file

@ -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

View file

@ -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'] ),
],
},