trestore from master public key (qt and command line) - electrum - Electrum Bitcoin wallet (HTM) git clone https://git.parazyd.org/electrum (DIR) Log (DIR) Files (DIR) Refs (DIR) Submodules --- (DIR) commit e955ee69a8fc68212076583b877ccba3cbd77159 (DIR) parent 9ddd9c7c65eaada61d20079b83625885c4775d1d (HTM) Author: ThomasV <thomasv@gitorious> Date: Fri, 28 Feb 2014 15:43:06 +0100 restore from master public key (qt and command line) Diffstat: M electrum | 19 +++++++++++++------ M gui/qt/installwizard.py | 12 ++---------- M lib/wallet.py | 21 +++++++++++++++++++-- 3 files changed, 34 insertions(+), 18 deletions(-) --- (DIR) diff --git a/electrum b/electrum t@@ -90,6 +90,7 @@ def arg_parser(): parser.add_option("-W", "--password", dest="password", default=None, help="set password for usage with commands (currently only implemented for create command, do not use it for longrunning gui session since the password is visible in /proc)") parser.add_option("-1", "--oneserver", action="store_true", dest="oneserver", default=False, help="connect to one server only") parser.add_option("--bip32", action="store_true", dest="bip32", default=False, help="bip32") + parser.add_option("--mpk", dest="mpk", default=False, help="master public key") return parser t@@ -265,6 +266,8 @@ if __name__ == '__main__': sys.exit("Error: Remove the existing wallet first!") if options.password is not None: password = options.password + elif cmd.name == 'restore' and options.mpk: + password = None else: password = prompt_password("Password (hit return if you do not wish to encrypt your wallet):") t@@ -282,12 +285,16 @@ if __name__ == '__main__': # wallet.change_gap_limit(int(gap)) if cmd.name == 'restore': - import getpass - seed = getpass.getpass(prompt="seed:", stream=None) if options.concealed else raw_input("seed:") - wallet = Wallet.from_seed(str(seed),storage) - if not wallet: - sys.exit("Error: Invalid seed") - wallet.save_seed(password) + if options.mpk: + wallet = Wallet.from_mpk(options.mpk, storage) + else: + import getpass + seed = getpass.getpass(prompt="seed:", stream=None) if options.concealed else raw_input("seed:") + wallet = Wallet.from_seed(str(seed),storage) + if not wallet: + sys.exit("Error: Invalid seed") + wallet.save_seed(password) + if not options.offline: network = Network(config) network.start() (DIR) diff --git a/gui/qt/installwizard.py b/gui/qt/installwizard.py t@@ -167,12 +167,6 @@ class InstallWizard(QDialog): mpk_e.setMaximumHeight(100) grid.addWidget(mpk_e, 0, 1) - label = QLabel(_("Chain")) - #grid.addWidget(label, 1, 0) - chain_e = QTextEdit() - chain_e.setMaximumHeight(100) - #grid.addWidget(chain_e, 1, 1) - vbox.addLayout(grid) vbox.addStretch(1) t@@ -183,8 +177,7 @@ class InstallWizard(QDialog): return None mpk = str(mpk_e.toPlainText()).strip() - chain = str(chain_e.toPlainText()).strip() - return mpk, chain + return mpk def network_dialog(self): t@@ -289,8 +282,7 @@ class InstallWizard(QDialog): mpk = self.mpk_dialog() if not mpk: return - wallet.seed = '' - wallet.create_watching_only_wallet(mpk) + wallet = Wallet.from_mpk(mpk, self.storage) else: raise (DIR) diff --git a/lib/wallet.py b/lib/wallet.py t@@ -1809,7 +1809,6 @@ class Wallet(object): - @classmethod def from_seed(self, seed, storage): import mnemonic t@@ -1835,8 +1834,26 @@ class Wallet(object): w.init_seed(seed) #hex else: #assert is_seed(seed) - w = Wallet(storage) + w = NewWallet(storage) w.init_seed(seed) + return w + + + @classmethod + def from_mpk(self, s, storage): + try: + mpk, chain = s.split(':') + except: + mpk = s + chain = False + + if chain: + w = NewWallet(storage) + w.create_watching_only_wallet(mpk, chain) + else: + w = OldWallet(storage) + w.seed = '' + w.create_watching_only_wallet(mpk) return w