Browse Source

add portuguese wordlist, and adapt wordlist parsing

283
ThomasV 10 years ago
parent
commit
4d71707be8
  1. 2
      electrum
  2. 12
      lib/commands.py
  3. 14
      lib/mnemonic.py
  4. 1654
      lib/wordlist/portuguese.txt

2
electrum

@ -388,7 +388,7 @@ if __name__ == '__main__':
args = [cmd, options.show_all, options.show_labels]
elif cmd.name == 'make_seed':
args = [cmd, int(options.nbits), long(options.entropy)]
args = [cmd, int(options.nbits), long(options.entropy), options.language]
elif cmd.name in ['payto', 'mktx']:
domain = [options.from_addr] if options.from_addr else None

12
lib/commands.py

@ -108,8 +108,8 @@ register_command('decrypt', 2,-1, False, True, True, 'decrypt a m
register_command('getproof', 1, 1, True, False, False, 'get merkle proof', 'getproof <address>')
register_command('getutxoaddress', 2, 2, True, False, False, 'get the address of an unspent transaction output','getutxoaddress <txid> <pos>')
register_command('sweep', 2, 3, True, False, False, 'Sweep a private key.', 'sweep privkey addr [fee]')
register_command('make_seed', 2, 2, False, False, False, 'Create a seed.','options: --nbits --entropy')
register_command('check_seed', 1,-1, False, False, False, 'Check that a seed was generated with external entropy. Option: --entropy')
register_command('make_seed', 3, 3, False, False, False, 'Create a seed.','options: --nbits --entropy --lang')
register_command('check_seed', 1,-1, False, False, False, 'Check that a seed was generated with external entropy. Option: --entropy --lang')
class Commands:
@ -131,14 +131,14 @@ class Commands:
apply(self._callback, ())
return result
def make_seed(self, nbits, custom_entropy):
def make_seed(self, nbits, custom_entropy, language):
from mnemonic import Mnemonic
s = Mnemonic('english').make_seed(nbits, custom_entropy)
s = Mnemonic(language).make_seed(nbits, custom_entropy)
return s
def check_seed(self, seed, custom_entropy):
def check_seed(self, seed, custom_entropy, language):
from mnemonic import Mnemonic
return Mnemonic('english').check_seed(seed, custom_entropy)
return Mnemonic(language).check_seed(seed, custom_entropy)
def getaddresshistory(self, addr):
return self.network.synchronous_get([ ('blockchain.address.get_history',[addr]) ])[0]

14
lib/mnemonic.py

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

1654
lib/wordlist/portuguese.txt

File diff suppressed because it is too large
Loading…
Cancel
Save