electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 0c100c1480a3dc11b116d9f83504a4b2a045853b
parent e552930d349ec1d5fe32113b452ff4bfefccff68
Author: ThomasV <thomasv@gitorious>
Date:   Fri, 25 Apr 2014 17:51:41 +0200

add_cold_seed

Diffstat:
Mgui/qt/installwizard.py | 19++++++++++++-------
Mlib/wallet.py | 25++++++++++++++++---------
2 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/gui/qt/installwizard.py b/gui/qt/installwizard.py @@ -331,14 +331,19 @@ class InstallWizard(QDialog): wallet = Wallet_2of3(self.storage) if Wallet.is_seed(text1): - wallet.add_root("m/", text1, password) + wallet.add_seed(text1, password) + if Wallet.is_seed(text2): + wallet.add_cold_seed(text2, password) + else: + wallet.add_master_public_key("cold/", text2) + elif Wallet.is_mpk(text1): - wallet.add_master_public_key("m/", text1) - - if Wallet.is_seed(text2): - wallet.add_root("cold/", text2, password) - elif Wallet.is_mpk(text2): - wallet.add_master_public_key("cold/", text2) + if Wallet.is_seed(text2): + wallet.add_seed(text2, password) + 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) diff --git a/lib/wallet.py b/lib/wallet.py @@ -302,7 +302,8 @@ class NewWallet: 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: raise Exception("a seed exists") @@ -355,14 +356,6 @@ class NewWallet: 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): xpriv, xpub = bip32_root(self.get_seed(password)) self.add_master_public_key("m/", xpub) @@ -1506,6 +1499,20 @@ class Wallet_2of2(NewWallet): xpub2 = self.master_public_keys.get("cold/") 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): def __init__(self, storage):