add_cold_seed
This commit is contained in:
parent
e552930d34
commit
0c100c1480
|
@ -331,14 +331,19 @@ class InstallWizard(QDialog):
|
||||||
wallet = Wallet_2of3(self.storage)
|
wallet = Wallet_2of3(self.storage)
|
||||||
|
|
||||||
if Wallet.is_seed(text1):
|
if Wallet.is_seed(text1):
|
||||||
wallet.add_root("m/", text1, password)
|
wallet.add_seed(text1, password)
|
||||||
elif Wallet.is_mpk(text1):
|
if Wallet.is_seed(text2):
|
||||||
wallet.add_master_public_key("m/", text1)
|
wallet.add_cold_seed(text2, password)
|
||||||
|
else:
|
||||||
|
wallet.add_master_public_key("cold/", text2)
|
||||||
|
|
||||||
if Wallet.is_seed(text2):
|
elif Wallet.is_mpk(text1):
|
||||||
wallet.add_root("cold/", text2, password)
|
if Wallet.is_seed(text2):
|
||||||
elif Wallet.is_mpk(text2):
|
wallet.add_seed(text2, password)
|
||||||
wallet.add_master_public_key("cold/", text2)
|
wallet.add_master_public_key("cold/", text1)
|
||||||
|
else:
|
||||||
|
wallet.add_master_public_key("m/", text1)
|
||||||
|
wallet.add_master_public_key("cold/", text2)
|
||||||
|
|
||||||
run_hook('restore_third_key', wallet, self)
|
run_hook('restore_third_key', wallet, self)
|
||||||
|
|
||||||
|
|
|
@ -302,7 +302,8 @@ class NewWallet:
|
||||||
return NEW_SEED_VERSION, unicodedata.normalize('NFC', unicode(seed.strip()))
|
return NEW_SEED_VERSION, unicodedata.normalize('NFC', unicode(seed.strip()))
|
||||||
|
|
||||||
|
|
||||||
def save_seed(self, seed, password):
|
|
||||||
|
def add_seed(self, seed, password):
|
||||||
if self.seed:
|
if self.seed:
|
||||||
raise Exception("a seed exists")
|
raise Exception("a seed exists")
|
||||||
|
|
||||||
|
@ -355,14 +356,6 @@ class NewWallet:
|
||||||
return xpub
|
return xpub
|
||||||
|
|
||||||
|
|
||||||
def add_root(self, name, mnemonic, password, add_private = True):
|
|
||||||
seed = mnemonic_to_seed(mnemonic,'').encode('hex')
|
|
||||||
xpriv, xpub = bip32_root(seed)
|
|
||||||
self.add_master_public_key(name, xpub)
|
|
||||||
if add_private:
|
|
||||||
self.add_master_private_key(name, xpriv, password)
|
|
||||||
|
|
||||||
|
|
||||||
def create_master_keys(self, password):
|
def create_master_keys(self, password):
|
||||||
xpriv, xpub = bip32_root(self.get_seed(password))
|
xpriv, xpub = bip32_root(self.get_seed(password))
|
||||||
self.add_master_public_key("m/", xpub)
|
self.add_master_public_key("m/", xpub)
|
||||||
|
@ -1506,6 +1499,20 @@ class Wallet_2of2(NewWallet):
|
||||||
xpub2 = self.master_public_keys.get("cold/")
|
xpub2 = self.master_public_keys.get("cold/")
|
||||||
return {'hot':xpub1, 'cold':xpub2}
|
return {'hot':xpub1, 'cold':xpub2}
|
||||||
|
|
||||||
|
|
||||||
|
def add_cold_seed(self, cold_seed, password):
|
||||||
|
seed_version, cold_seed = self.prepare_seed(cold_seed)
|
||||||
|
hex_seed = mnemonic_to_seed(cold_seed,'').encode('hex')
|
||||||
|
xpriv, xpub = bip32_root(hex_seed)
|
||||||
|
|
||||||
|
if password:
|
||||||
|
cold_seed = pw_encode( cold_seed, password)
|
||||||
|
self.storage.put('cold_seed', cold_seed, True)
|
||||||
|
|
||||||
|
self.add_master_public_key('cold/', xpub)
|
||||||
|
self.add_master_private_key('cold/', xpriv, password)
|
||||||
|
|
||||||
|
|
||||||
class Wallet_2of3(Wallet_2of2):
|
class Wallet_2of3(Wallet_2of2):
|
||||||
|
|
||||||
def __init__(self, storage):
|
def __init__(self, storage):
|
||||||
|
|
Loading…
Reference in New Issue