URI: 
       tfix restore from mpk - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 6696e9643cab296f66f22781b8899155a16dd034
   DIR parent 42a78043938a9b18704b3fe57a8dcf14b130ce0e
  HTML Author: ThomasV <thomasv@gitorious>
       Date:   Tue,  3 Sep 2013 18:35:46 +0200
       
       fix restore from mpk
       
       Diffstat:
         M gui/installwizard.py                |      56 ++++++++++++++++++++++++++++---
         M lib/wallet.py                       |      13 ++++++++++---
       
       2 files changed, 62 insertions(+), 7 deletions(-)
       ---
   DIR diff --git a/gui/installwizard.py b/gui/installwizard.py
       t@@ -140,6 +140,46 @@ class InstallWizard(QDialog):
                    return seed, gap
        
        
       +    def mpk_dialog(self):
       +        d = QDialog()
       +        d.setModal(1)
       +
       +        vbox = QVBoxLayout()
       +        msg = _("Please enter your master public key.")
       +
       +        label=QLabel(msg)
       +        label.setWordWrap(True)
       +        vbox.addWidget(label)
       +
       +        mpk_e = QTextEdit()
       +        mpk_e.setMaximumHeight(100)
       +        vbox.addWidget(mpk_e)
       +
       +        grid = QGridLayout()
       +        grid.setSpacing(8)
       +        gap_e = AmountEdit(None, True)
       +        gap_e.setText("5")
       +        grid.addWidget(QLabel(_('Gap limit')), 2, 0)
       +        grid.addWidget(gap_e, 2, 1)
       +        grid.addWidget(HelpButton(_('Keep the default value unless you modified this parameter in your wallet.')), 2, 3)
       +        vbox.addLayout(grid)
       +
       +        vbox.addLayout(ok_cancel_buttons(d, _('Next')))
       +        d.setLayout(vbox) 
       +
       +        if not d.exec_(): return
       +
       +        mpk = str(mpk_e.toPlainText())
       +
       +        try:
       +            gap = int(unicode(gap_e.text()))
       +        except:
       +            QMessageBox.warning(None, _('Error'), 'error', 'OK')
       +            return
       +
       +        return mpk, gap
       +
       +
            def network_dialog(self):
                
                d = QDialog()
       t@@ -266,15 +306,23 @@ class InstallWizard(QDialog):
        
                elif action == 'watching':
                    # ask for seed and gap.
       -            sg = self.seed_dialog()
       +            sg = self.mpk_dialog()
                    if not sg:
                        return
       -            seed, gap = sg
       -            if not seed:
       +            mpk, gap = sg
       +            if not mpk:
                        return
                    wallet.gap_limit = gap
                    wallet.seed = ''
       -            wallet.init_sequence(str(seed))
       +
       +            print eval(mpk)
       +            try:
       +                c0, K0 = eval(mpk)
       +            except:
       +                QMessageBox.warning(None, _('Error'), _('error'), _('OK'))
       +                return
       +            wallet.create_watching_only_wallet(c0,K0)
       +
        
                else: raise
                        
   DIR diff --git a/lib/wallet.py b/lib/wallet.py
       t@@ -238,6 +238,13 @@ class Wallet:
                self.storage.put('seed', self.seed, True)
                self.storage.put('seed_version', self.seed_version, True)
        
       +    def create_watching_only_wallet(self, c0, K0):
       +        cK0 = ""
       +        self.master_public_keys = {
       +            "m/0'/": (c0, K0, cK0),
       +            }
       +        self.storage.put('master_public_keys', self.master_public_keys, True)
       +        self.create_account('1','Main account')
        
            def create_accounts(self):
        
       t@@ -254,7 +261,6 @@ class Wallet:
                k5, c5, K5, cK5 = bip32_private_derivation(master_k, master_c, "m/", "m/5'/")
        
                self.master_public_keys = {
       -            "m/": (master_c, master_K, master_cK),
                    "m/0'/": (c0, K0, cK0),
                    "m/1'/": (c1, K1, cK1),
                    "m/2'/": (c2, K2, cK2),
       t@@ -423,7 +429,8 @@ class Wallet:
                if self.seed_version == 4:
                    return self.storage.get("master_public_key")
                else:
       -            return self.storage.get("master_public_keys")["m/"]
       +            c, K, cK = self.storage.get("master_public_keys")["m/0'/"]
       +            return repr((c, K))
        
            def get_master_private_key(self, account, password):
                master_k = pw_decode( self.master_private_keys[account], password)
       t@@ -697,7 +704,7 @@ class Wallet:
                for account_type in ['1','2of2','2of3']:
                    a = self.new_account_address(account_type)
                    if self.address_is_old(a):
       -                print "creating account", a
       +                print_error( "creating account", a )
                        self.create_account(account_type)