1
0

add portuguese wordlist, and adapt wordlist parsing

This commit is contained in:
ThomasV
2014-08-28 17:30:44 +02:00
parent 4dcdcbc068
commit 4d71707be8
4 changed files with 1673 additions and 9 deletions

View File

@@ -32,9 +32,19 @@ class Mnemonic(object):
# Seed derivation follows BIP39
# Mnemonic phrase uses a hash based checksum, instead of a wordlist-dependent checksum
def __init__(self, lang='english'):
def __init__(self, lang=None):
if lang is None:
lang = 'english'
path = os.path.join(os.path.dirname(__file__), 'wordlist', lang + '.txt')
self.wordlist = open(path,'r').read().strip().split('\n')
lines = open(path,'r').read().strip().split('\n')
self.wordlist = []
for line in lines:
line = line.split('#')[0]
line = line.strip(' \r')
assert ' ' not in line
if line:
self.wordlist.append(line)
print_error("wordlist has %d words"%len(self.wordlist))
@classmethod
def mnemonic_to_seed(self, mnemonic, passphrase):