restore bip32 accounts
This commit is contained in:
@@ -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):
|
class MyTreeWidget(QTreeWidget):
|
||||||
def __init__(self, parent):
|
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()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,14 @@ from PyQt4.QtCore import *
|
|||||||
import PyQt4.QtCore as QtCore
|
import PyQt4.QtCore as QtCore
|
||||||
from i18n import _
|
from i18n import _
|
||||||
|
|
||||||
from electrum import Wallet, mnemonic
|
from electrum import Wallet, mnemonic, WalletVerifier, WalletSynchronizer
|
||||||
|
|
||||||
from seed_dialog import SeedDialog
|
from seed_dialog import SeedDialog
|
||||||
from network_dialog import NetworkDialog
|
from network_dialog import NetworkDialog
|
||||||
from qt_util import *
|
from qt_util import *
|
||||||
|
from amountedit import AmountEdit
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
class InstallWizard(QDialog):
|
class InstallWizard(QDialog):
|
||||||
|
|
||||||
@@ -107,8 +111,8 @@ class InstallWizard(QDialog):
|
|||||||
d.run()
|
d.run()
|
||||||
|
|
||||||
|
|
||||||
def restore_wallet(self):
|
def restore_wallet(self, wallet):
|
||||||
wallet = self.wallet
|
|
||||||
# wait until we are connected, because the user might have selected another server
|
# wait until we are connected, because the user might have selected another server
|
||||||
if not wallet.interface.is_connected:
|
if not wallet.interface.is_connected:
|
||||||
waiting = lambda: False if wallet.interface.is_connected else "%s \n" % (_("Connecting..."))
|
waiting = lambda: False if wallet.interface.is_connected else "%s \n" % (_("Connecting..."))
|
||||||
@@ -121,9 +125,9 @@ class InstallWizard(QDialog):
|
|||||||
wallet.interface.poke('synchronizer')
|
wallet.interface.poke('synchronizer')
|
||||||
waiting_dialog(waiting)
|
waiting_dialog(waiting)
|
||||||
if wallet.is_found():
|
if wallet.is_found():
|
||||||
print_error( "Recovery successful" )
|
QMessageBox.information(None, _('Information'), _("Recovery successful"), _('OK'))
|
||||||
else:
|
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
|
return True
|
||||||
|
|
||||||
@@ -145,7 +149,7 @@ class InstallWizard(QDialog):
|
|||||||
exit()
|
exit()
|
||||||
else:
|
else:
|
||||||
# ask for seed and gap.
|
# ask for seed and gap.
|
||||||
sg = gui.seed_dialog()
|
sg = self.seed_dialog()
|
||||||
if not sg: exit()
|
if not sg: exit()
|
||||||
seed, gap = sg
|
seed, gap = sg
|
||||||
if not seed: exit()
|
if not seed: exit()
|
||||||
@@ -163,6 +167,16 @@ class InstallWizard(QDialog):
|
|||||||
self.config.set_key("server", None, True)
|
self.config.set_key("server", None, True)
|
||||||
self.config.set_key('auto_cycle', False, 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
|
# generate the first addresses, in case we are offline
|
||||||
if s is None or a == 'create':
|
if s is None or a == 'create':
|
||||||
wallet.synchronize()
|
wallet.synchronize()
|
||||||
@@ -170,7 +184,7 @@ class InstallWizard(QDialog):
|
|||||||
|
|
||||||
if a == 'restore' and s is not None:
|
if a == 'restore' and s is not None:
|
||||||
try:
|
try:
|
||||||
keep_it = gui.restore_wallet()
|
keep_it = self.restore_wallet(wallet)
|
||||||
wallet.fill_addressbook()
|
wallet.fill_addressbook()
|
||||||
except:
|
except:
|
||||||
import traceback
|
import traceback
|
||||||
|
|||||||
@@ -2,6 +2,56 @@ from i18n import _
|
|||||||
from PyQt4.QtGui import *
|
from PyQt4.QtGui import *
|
||||||
from PyQt4.QtCore import *
|
from PyQt4.QtCore import *
|
||||||
import os.path
|
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):
|
def backup_wallet(path):
|
||||||
import shutil
|
import shutil
|
||||||
|
|||||||
@@ -323,6 +323,7 @@ class Wallet:
|
|||||||
o = self.get_account_addresses(-1, include_change)
|
o = self.get_account_addresses(-1, include_change)
|
||||||
for a in self.accounts.keys():
|
for a in self.accounts.keys():
|
||||||
o += self.get_account_addresses(a, include_change)
|
o += self.get_account_addresses(a, include_change)
|
||||||
|
o += self.first_addresses.values()
|
||||||
return o
|
return o
|
||||||
|
|
||||||
|
|
||||||
@@ -600,7 +601,6 @@ class Wallet:
|
|||||||
|
|
||||||
|
|
||||||
def create_pending_accounts(self):
|
def create_pending_accounts(self):
|
||||||
|
|
||||||
for account_type in ['1','2of2','2of3']:
|
for account_type in ['1','2of2','2of3']:
|
||||||
a = self.new_account_address(account_type)
|
a = self.new_account_address(account_type)
|
||||||
if self.address_is_old(a):
|
if self.address_is_old(a):
|
||||||
|
|||||||
Reference in New Issue
Block a user