From 10c805b3e7766ee4fdd268e0a2c55f0d9d904321 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Thu, 29 Aug 2013 16:07:55 +0200 Subject: [PATCH] restore bip32 accounts --- gui/gui_classic.py | 43 ------------------------------------- gui/installwizard.py | 28 ++++++++++++++++++------- gui/qt_util.py | 50 ++++++++++++++++++++++++++++++++++++++++++++ lib/wallet.py | 2 +- 4 files changed, 72 insertions(+), 51 deletions(-) diff --git a/gui/gui_classic.py b/gui/gui_classic.py index 0fc516721..78d5690eb 100644 --- a/gui/gui_classic.py +++ b/gui/gui_classic.py @@ -147,29 +147,6 @@ class UpdateLabel(QLabel): -class Timer(QtCore.QThread): - def run(self): - while True: - self.emit(QtCore.SIGNAL('timersignal')) - time.sleep(0.5) - -class HelpButton(QPushButton): - def __init__(self, text): - QPushButton.__init__(self, '?') - self.setFocusPolicy(Qt.NoFocus) - self.setFixedWidth(20) - self.clicked.connect(lambda: QMessageBox.information(self, 'Help', text, 'OK') ) - - -class EnterButton(QPushButton): - def __init__(self, text, func): - QPushButton.__init__(self, text) - self.func = func - self.clicked.connect(func) - - def keyPressEvent(self, e): - if e.key() == QtCore.Qt.Key_Return: - apply(self.func,()) class MyTreeWidget(QTreeWidget): def __init__(self, parent): @@ -208,26 +185,6 @@ class StatusBarButton(QPushButton): -def waiting_dialog(f): - - s = Timer() - s.start() - w = QDialog() - w.resize(200, 70) - w.setWindowTitle('Electrum') - l = QLabel('') - vbox = QVBoxLayout() - vbox.addWidget(l) - w.setLayout(vbox) - w.show() - def ff(): - s = f() - if s: l.setText(s) - else: w.close() - w.connect(s, QtCore.SIGNAL('timersignal'), ff) - w.exec_() - w.destroy() - diff --git a/gui/installwizard.py b/gui/installwizard.py index 430ae934e..dddd01523 100644 --- a/gui/installwizard.py +++ b/gui/installwizard.py @@ -3,10 +3,14 @@ from PyQt4.QtCore import * import PyQt4.QtCore as QtCore from i18n import _ -from electrum import Wallet, mnemonic +from electrum import Wallet, mnemonic, WalletVerifier, WalletSynchronizer + from seed_dialog import SeedDialog from network_dialog import NetworkDialog from qt_util import * +from amountedit import AmountEdit + +import sys class InstallWizard(QDialog): @@ -107,8 +111,8 @@ class InstallWizard(QDialog): d.run() - def restore_wallet(self): - wallet = self.wallet + def restore_wallet(self, wallet): + # wait until we are connected, because the user might have selected another server if not wallet.interface.is_connected: waiting = lambda: False if wallet.interface.is_connected else "%s \n" % (_("Connecting...")) @@ -121,9 +125,9 @@ class InstallWizard(QDialog): wallet.interface.poke('synchronizer') waiting_dialog(waiting) if wallet.is_found(): - print_error( "Recovery successful" ) + QMessageBox.information(None, _('Information'), _("Recovery successful"), _('OK')) else: - QMessageBox.information(None, _('Error'), _("No transactions found for this seed"), _('OK')) + QMessageBox.information(None, _('Information'), _("No transactions found for this seed"), _('OK')) return True @@ -145,7 +149,7 @@ class InstallWizard(QDialog): exit() else: # ask for seed and gap. - sg = gui.seed_dialog() + sg = self.seed_dialog() if not sg: exit() seed, gap = sg if not seed: exit() @@ -163,6 +167,16 @@ class InstallWizard(QDialog): self.config.set_key("server", None, True) self.config.set_key('auto_cycle', False, True) + self.interface.start(wait = False) + + # start wallet threads + verifier = WalletVerifier(self.interface, self.config) + verifier.start() + wallet.set_verifier(verifier) + synchronizer = WalletSynchronizer(wallet, self.config) + synchronizer.start() + + # generate the first addresses, in case we are offline if s is None or a == 'create': wallet.synchronize() @@ -170,7 +184,7 @@ class InstallWizard(QDialog): if a == 'restore' and s is not None: try: - keep_it = gui.restore_wallet() + keep_it = self.restore_wallet(wallet) wallet.fill_addressbook() except: import traceback diff --git a/gui/qt_util.py b/gui/qt_util.py index 56d4845d9..3c82c7bef 100644 --- a/gui/qt_util.py +++ b/gui/qt_util.py @@ -2,6 +2,56 @@ from i18n import _ from PyQt4.QtGui import * from PyQt4.QtCore import * import os.path +import time + + +class Timer(QThread): + def run(self): + while True: + self.emit(SIGNAL('timersignal')) + time.sleep(0.5) + + +class EnterButton(QPushButton): + def __init__(self, text, func): + QPushButton.__init__(self, text) + self.func = func + self.clicked.connect(func) + + def keyPressEvent(self, e): + if e.key() == Qt.Key_Return: + apply(self.func,()) + + +def waiting_dialog(f): + + s = Timer() + s.start() + w = QDialog() + w.resize(200, 70) + w.setWindowTitle('Electrum') + l = QLabel('') + vbox = QVBoxLayout() + vbox.addWidget(l) + w.setLayout(vbox) + w.show() + def ff(): + s = f() + if s: l.setText(s) + else: w.close() + w.connect(s, SIGNAL('timersignal'), ff) + w.exec_() + w.destroy() + + +class HelpButton(QPushButton): + def __init__(self, text): + QPushButton.__init__(self, '?') + self.setFocusPolicy(Qt.NoFocus) + self.setFixedWidth(20) + self.clicked.connect(lambda: QMessageBox.information(self, 'Help', text, 'OK') ) + + def backup_wallet(path): import shutil diff --git a/lib/wallet.py b/lib/wallet.py index f536eaf52..b5d25a0f4 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -323,6 +323,7 @@ class Wallet: o = self.get_account_addresses(-1, include_change) for a in self.accounts.keys(): o += self.get_account_addresses(a, include_change) + o += self.first_addresses.values() return o @@ -600,7 +601,6 @@ class Wallet: def create_pending_accounts(self): - for account_type in ['1','2of2','2of3']: a = self.new_account_address(account_type) if self.address_is_old(a):