handle imported keys as well with deseed and reseed
This commit is contained in:
parent
5d43811a90
commit
a5496a5477
14
electrum
14
electrum
|
@ -279,9 +279,10 @@ if __name__ == '__main__':
|
||||||
print "Warning: you are going to extract the seed from '%s'\nThe seed will be saved in '%s'"%(wallet.path,ns)
|
print "Warning: you are going to extract the seed from '%s'\nThe seed will be saved in '%s'"%(wallet.path,ns)
|
||||||
if raw_input("Are you sure you want to continue? (y/n) ") in ['y','Y','yes']:
|
if raw_input("Are you sure you want to continue? (y/n) ") in ['y','Y','yes']:
|
||||||
f = open(ns,'w')
|
f = open(ns,'w')
|
||||||
f.write(wallet.seed)
|
f.write(repr({'seed':wallet.seed, 'imported_keys':wallet.imported_keys})+"\n")
|
||||||
f.close()
|
f.close()
|
||||||
wallet.seed = ''
|
wallet.seed = ''
|
||||||
|
for k in wallet.imported_keys.keys(): wallet.imported_keys[k] = ''
|
||||||
wallet.save()
|
wallet.save()
|
||||||
print "Done."
|
print "Done."
|
||||||
else:
|
else:
|
||||||
|
@ -294,14 +295,23 @@ if __name__ == '__main__':
|
||||||
ns = wallet.path + '.seed'
|
ns = wallet.path + '.seed'
|
||||||
try:
|
try:
|
||||||
f = open(ns,'r')
|
f = open(ns,'r')
|
||||||
seed = f.read()
|
data = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
except:
|
except:
|
||||||
print "seed file not found"
|
print "seed file not found"
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
try:
|
||||||
|
import ast
|
||||||
|
d = ast.literal_eval( data )
|
||||||
|
seed = d['seed']
|
||||||
|
imported_keys = d.get('imported_keys',{})
|
||||||
|
except:
|
||||||
|
print "error with seed file"
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
mpk = wallet.master_public_key
|
mpk = wallet.master_public_key
|
||||||
wallet.seed = seed
|
wallet.seed = seed
|
||||||
|
wallet.imported_keys = imported_keys
|
||||||
wallet.use_encryption = False
|
wallet.use_encryption = False
|
||||||
wallet.init_mpk(seed)
|
wallet.init_mpk(seed)
|
||||||
if mpk == wallet.master_public_key:
|
if mpk == wallet.master_public_key:
|
||||||
|
|
|
@ -382,6 +382,7 @@ class Wallet:
|
||||||
|
|
||||||
if address in self.imported_keys.keys():
|
if address in self.imported_keys.keys():
|
||||||
b = self.pw_decode( self.imported_keys[address], password )
|
b = self.pw_decode( self.imported_keys[address], password )
|
||||||
|
if not b: return None
|
||||||
b = ASecretToSecret( b )
|
b = ASecretToSecret( b )
|
||||||
secexp = int( b.encode('hex'), 16)
|
secexp = int( b.encode('hex'), 16)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue