wizard integration
This commit is contained in:
parent
58c6518b30
commit
744eee6858
@ -33,6 +33,7 @@ class InstallWizard(QDialog):
|
||||
self.network = network
|
||||
self.storage = storage
|
||||
self.setMinimumSize(575, 400)
|
||||
self.setMaximumSize(575, 400)
|
||||
self.setWindowTitle('Electrum')
|
||||
self.connect(self, QtCore.SIGNAL('accept'), self.accept)
|
||||
|
||||
@ -313,16 +314,19 @@ class InstallWizard(QDialog):
|
||||
return None
|
||||
|
||||
|
||||
def question(self, msg, icon=None):
|
||||
def question(self, msg, yes_label=_('OK'), no_label=_('Cancel'), icon=None):
|
||||
vbox = QVBoxLayout()
|
||||
self.set_layout(vbox)
|
||||
if icon:
|
||||
logo = QLabel()
|
||||
logo.setPixmap(icon)
|
||||
vbox.addWidget(logo)
|
||||
vbox.addWidget(QLabel(msg))
|
||||
|
||||
label = QLabel(msg)
|
||||
label.setWordWrap(True)
|
||||
vbox.addWidget(label)
|
||||
vbox.addStretch(1)
|
||||
vbox.addLayout(ok_cancel_buttons(self, _('OK')))
|
||||
vbox.addLayout(ok_cancel_buttons(self, yes_label, no_label))
|
||||
if not self.exec_():
|
||||
return None
|
||||
return True
|
||||
@ -343,29 +347,6 @@ class InstallWizard(QDialog):
|
||||
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
|
||||
self.waiting_dialog(wallet.synchronize)
|
||||
|
||||
elif action == 'create_cold_seed':
|
||||
self.create_cold_seed(wallet)
|
||||
return
|
||||
|
||||
else:
|
||||
r = run_hook('install_wizard_action', self, wallet, action)
|
||||
if not r:
|
||||
raise BaseException('unknown wizard action', action)
|
||||
f = run_hook('get_wizard_action', self, wallet, action)
|
||||
if not f:
|
||||
raise BaseException('unknown wizard action', action)
|
||||
r = f(wallet, self)
|
||||
if not r:
|
||||
return
|
||||
|
||||
# next action
|
||||
action = wallet.get_action()
|
||||
|
||||
@ -94,10 +94,10 @@ def close_button(dialog, label=_("Close") ):
|
||||
b.setDefault(True)
|
||||
return hbox
|
||||
|
||||
def ok_cancel_buttons2(dialog, ok_label=_("OK") ):
|
||||
def ok_cancel_buttons2(dialog, ok_label=_("OK"), cancel_label=_('Cancel')):
|
||||
hbox = QHBoxLayout()
|
||||
hbox.addStretch(1)
|
||||
b = QPushButton(_("Cancel"))
|
||||
b = QPushButton(cancel_label)
|
||||
hbox.addWidget(b)
|
||||
b.clicked.connect(dialog.reject)
|
||||
b = QPushButton(ok_label)
|
||||
@ -106,8 +106,8 @@ def ok_cancel_buttons2(dialog, ok_label=_("OK") ):
|
||||
b.setDefault(True)
|
||||
return hbox, b
|
||||
|
||||
def ok_cancel_buttons(dialog, ok_label=_("OK") ):
|
||||
hbox, b = ok_cancel_buttons2(dialog, ok_label)
|
||||
def ok_cancel_buttons(dialog, ok_label=_("OK"), cancel_label=_('Cancel')):
|
||||
hbox, b = ok_cancel_buttons2(dialog, ok_label, cancel_label)
|
||||
return hbox
|
||||
|
||||
def line_dialog(parent, title, label, ok_label, default=None):
|
||||
|
||||
@ -1464,6 +1464,12 @@ class Wallet_2of2(BIP39_Wallet):
|
||||
self.add_master_public_key(name, xpub)
|
||||
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):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user