add portuguese wordlist, and adapt wordlist parsing
This commit is contained in:
parent
4dcdcbc068
commit
4d71707be8
2
electrum
2
electrum
|
@ -388,7 +388,7 @@ if __name__ == '__main__':
|
||||||
args = [cmd, options.show_all, options.show_labels]
|
args = [cmd, options.show_all, options.show_labels]
|
||||||
|
|
||||||
elif cmd.name == 'make_seed':
|
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']:
|
elif cmd.name in ['payto', 'mktx']:
|
||||||
domain = [options.from_addr] if options.from_addr else None
|
domain = [options.from_addr] if options.from_addr else None
|
||||||
|
|
|
@ -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('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('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('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('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')
|
register_command('check_seed', 1,-1, False, False, False, 'Check that a seed was generated with external entropy. Option: --entropy --lang')
|
||||||
|
|
||||||
|
|
||||||
class Commands:
|
class Commands:
|
||||||
|
@ -131,14 +131,14 @@ class Commands:
|
||||||
apply(self._callback, ())
|
apply(self._callback, ())
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def make_seed(self, nbits, custom_entropy):
|
def make_seed(self, nbits, custom_entropy, language):
|
||||||
from mnemonic import Mnemonic
|
from mnemonic import Mnemonic
|
||||||
s = Mnemonic('english').make_seed(nbits, custom_entropy)
|
s = Mnemonic(language).make_seed(nbits, custom_entropy)
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def check_seed(self, seed, custom_entropy):
|
def check_seed(self, seed, custom_entropy, language):
|
||||||
from mnemonic import Mnemonic
|
from mnemonic import Mnemonic
|
||||||
return Mnemonic('english').check_seed(seed, custom_entropy)
|
return Mnemonic(language).check_seed(seed, custom_entropy)
|
||||||
|
|
||||||
def getaddresshistory(self, addr):
|
def getaddresshistory(self, addr):
|
||||||
return self.network.synchronous_get([ ('blockchain.address.get_history',[addr]) ])[0]
|
return self.network.synchronous_get([ ('blockchain.address.get_history',[addr]) ])[0]
|
||||||
|
|
|
@ -32,9 +32,19 @@ class Mnemonic(object):
|
||||||
# Seed derivation follows BIP39
|
# Seed derivation follows BIP39
|
||||||
# Mnemonic phrase uses a hash based checksum, instead of a wordlist-dependent checksum
|
# 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')
|
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
|
@classmethod
|
||||||
def mnemonic_to_seed(self, mnemonic, passphrase):
|
def mnemonic_to_seed(self, mnemonic, passphrase):
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue