Browse Source

wizard integration

master
ThomasV 11 years ago
parent
commit
744eee6858
  1. 46
      gui/qt/installwizard.py
  2. 8
      gui/qt/util.py
  3. 6
      lib/wallet.py

46
gui/qt/installwizard.py

@ -33,6 +33,7 @@ class InstallWizard(QDialog):
self.network = network self.network = network
self.storage = storage self.storage = storage
self.setMinimumSize(575, 400) self.setMinimumSize(575, 400)
self.setMaximumSize(575, 400)
self.setWindowTitle('Electrum') self.setWindowTitle('Electrum')
self.connect(self, QtCore.SIGNAL('accept'), self.accept) self.connect(self, QtCore.SIGNAL('accept'), self.accept)
@ -313,16 +314,19 @@ class InstallWizard(QDialog):
return None return None
def question(self, msg, icon=None): def question(self, msg, yes_label=_('OK'), no_label=_('Cancel'), icon=None):
vbox = QVBoxLayout() vbox = QVBoxLayout()
self.set_layout(vbox) self.set_layout(vbox)
if icon: if icon:
logo = QLabel() logo = QLabel()
logo.setPixmap(icon) logo.setPixmap(icon)
vbox.addWidget(logo) vbox.addWidget(logo)
vbox.addWidget(QLabel(msg))
label = QLabel(msg)
label.setWordWrap(True)
vbox.addWidget(label)
vbox.addStretch(1) vbox.addStretch(1)
vbox.addLayout(ok_cancel_buttons(self, _('OK'))) vbox.addLayout(ok_cancel_buttons(self, yes_label, no_label))
if not self.exec_(): if not self.exec_():
return None return None
return True return True
@ -343,29 +347,6 @@ class InstallWizard(QDialog):
return run_password_dialog(self, None, self)[2] return run_password_dialog(self, None, self)[2]
def create_cold_seed(self, wallet):
from electrum.bitcoin import mnemonic_to_seed, bip32_root
msg = _('You are about to generate the cold storage seed of your wallet.') + '\n' \
+ _('For safety, you should do this on an offline computer.')
icon = QPixmap( ':icons/cold_seed.png').scaledToWidth(56)
if not self.question(msg, icon):
return
cold_seed = wallet.make_seed()
if not self.show_seed(cold_seed, 'cold'):
return
if not self.verify_seed(cold_seed, 'cold'):
return
hex_seed = mnemonic_to_seed(cold_seed,'').encode('hex')
xpriv, xpub = bip32_root(hex_seed)
wallet.add_master_public_key('cold/', xpub)
msg = _('Your master public key was saved in your wallet file.') + '\n'\
+ _('Your cold seed must be stored on paper; it is not in the wallet file.')+ '\n\n' \
+ _('This program is about to close itself.') + '\n'\
+ _('You will need to reopen your wallet on an online computer, in order to complete the creation of your wallet')
self.show_message(msg)
@ -429,14 +410,13 @@ class InstallWizard(QDialog):
return return
self.waiting_dialog(wallet.synchronize) self.waiting_dialog(wallet.synchronize)
elif action == 'create_cold_seed':
self.create_cold_seed(wallet)
return
else: else:
r = run_hook('install_wizard_action', self, wallet, action) f = run_hook('get_wizard_action', self, wallet, action)
if not r: if not f:
raise BaseException('unknown wizard action', action) raise BaseException('unknown wizard action', action)
r = f(wallet, self)
if not r:
return
# next action # next action
action = wallet.get_action() action = wallet.get_action()

8
gui/qt/util.py

@ -94,10 +94,10 @@ def close_button(dialog, label=_("Close") ):
b.setDefault(True) b.setDefault(True)
return hbox return hbox
def ok_cancel_buttons2(dialog, ok_label=_("OK") ): def ok_cancel_buttons2(dialog, ok_label=_("OK"), cancel_label=_('Cancel')):
hbox = QHBoxLayout() hbox = QHBoxLayout()
hbox.addStretch(1) hbox.addStretch(1)
b = QPushButton(_("Cancel")) b = QPushButton(cancel_label)
hbox.addWidget(b) hbox.addWidget(b)
b.clicked.connect(dialog.reject) b.clicked.connect(dialog.reject)
b = QPushButton(ok_label) b = QPushButton(ok_label)
@ -106,8 +106,8 @@ def ok_cancel_buttons2(dialog, ok_label=_("OK") ):
b.setDefault(True) b.setDefault(True)
return hbox, b return hbox, b
def ok_cancel_buttons(dialog, ok_label=_("OK") ): def ok_cancel_buttons(dialog, ok_label=_("OK"), cancel_label=_('Cancel')):
hbox, b = ok_cancel_buttons2(dialog, ok_label) hbox, b = ok_cancel_buttons2(dialog, ok_label, cancel_label)
return hbox return hbox
def line_dialog(parent, title, label, ok_label, default=None): def line_dialog(parent, title, label, ok_label, default=None):

6
lib/wallet.py

@ -1464,6 +1464,12 @@ class Wallet_2of2(BIP39_Wallet):
self.add_master_public_key(name, xpub) self.add_master_public_key(name, xpub)
self.add_master_private_key(name, xprv, password) self.add_master_private_key(name, xprv, password)
def add_cosigner_xpub(self, seed, name):
# store only master xpub
xprv, xpub = bip32_root(mnemonic_to_seed(seed,''))
xprv, xpub = bip32_private_derivation(xprv, "m/", self.root_derivation)
self.add_master_public_key(name, xpub)
class Wallet_2of3(Wallet_2of2): class Wallet_2of3(Wallet_2of2):

Loading…
Cancel
Save