Browse Source

better seed dialog + fix bug with restore

283
thomasv 12 years ago
parent
commit
f32f85fb78
  1. 4
      electrum
  2. 51
      gui/gui_classic.py

4
electrum

@ -136,10 +136,7 @@ if __name__ == '__main__':
if a =='create': if a =='create':
wallet.init_seed(None) wallet.init_seed(None)
# display seed
gui.show_seed() gui.show_seed()
# retype seed
if not gui.verify_seed(): if not gui.verify_seed():
exit() exit()
@ -155,6 +152,7 @@ if __name__ == '__main__':
wallet.init_sequence(str(seed)) wallet.init_sequence(str(seed))
else: else:
wallet.init_seed(str(seed)) wallet.init_seed(str(seed))
wallet.save_seed()
# select a server. # select a server.
s = gui.network_dialog() s = gui.network_dialog()

51
gui/gui_classic.py

@ -2209,7 +2209,6 @@ class ElectrumWindow(QMainWindow):
else: else:
server_protocol.model().setData(j, QtCore.QVariant(33), QtCore.Qt.UserRole-1) server_protocol.model().setData(j, QtCore.QVariant(33), QtCore.Qt.UserRole-1)
if server: if server:
host, port, protocol = server.split(':') host, port, protocol = server.split(':')
change_server(host,protocol) change_server(host,protocol)
@ -2223,7 +2222,7 @@ class ElectrumWindow(QMainWindow):
# auto cycle # auto cycle
autocycle_cb = QCheckBox(_('Try random servers if disconnected')) autocycle_cb = QCheckBox(_('Try random servers if disconnected'))
autocycle_cb.setChecked(wallet.config.get('auto_cycle', False)) autocycle_cb.setChecked(wallet.config.get('auto_cycle', True))
grid.addWidget(autocycle_cb, 3, 1, 3, 2) grid.addWidget(autocycle_cb, 3, 1, 3, 2)
if not wallet.config.is_modifiable('auto_cycle'): autocycle_cb.setEnabled(False) if not wallet.config.is_modifiable('auto_cycle'): autocycle_cb.setEnabled(False)
@ -2304,8 +2303,7 @@ class ElectrumGui:
def verify_seed(self): def verify_seed(self):
r = self.seed_dialog(False) r = self.seed_dialog(False)
if not r: return False if r != self.wallet.seed:
if r[0] != self.wallet.seed:
QMessageBox.warning(None, _('Error'), 'incorrect seed', 'OK') QMessageBox.warning(None, _('Error'), 'incorrect seed', 'OK')
return False return False
else: else:
@ -2320,48 +2318,39 @@ class ElectrumGui:
vbox = QVBoxLayout() vbox = QVBoxLayout()
if is_restore: if is_restore:
msg = _("Please enter your wallet seed (or your master public key if you want to create a watching-only wallet)." + '\n') msg = _("Please enter your wallet seed (or your master public key if you want to create a watching-only wallet)." + ' ')
else: else:
msg = _("Please type your seed." + '\n') msg = _("Your seed is important! To make sure that you have properly saved your seed, please type it here." + ' ')
vbox.addWidget(QLabel(msg)) msg += _("Your seed can be entered as a sequence of words, or as a hexadecimal string."+ '\n')
grid = QGridLayout() label=QLabel(msg)
grid.setSpacing(8) label.setWordWrap(True)
vbox.addWidget(label)
seed_e = QLineEdit() seed_e = QTextEdit()
seed_e.setMinimumWidth(400) seed_e.setMaximumHeight(100)
grid.addWidget(QLabel(_('Seed or master public key') if is_restore else _('Seed')), 1, 0) vbox.addWidget(seed_e)
grid.addWidget(seed_e, 1, 1)
grid.addWidget(HelpButton(_("Your seed can be entered as a mnemonic (sequence of words), or as a hexadecimal string.")), 1, 3)
if is_restore: if is_restore:
grid = QGridLayout()
grid.setSpacing(8)
gap_e = AmountEdit(None, True) gap_e = AmountEdit(None, True)
gap_e.setText("5") gap_e.setText("5")
grid.addWidget(QLabel(_('Gap limit')), 2, 0) grid.addWidget(QLabel(_('Gap limit')), 2, 0)
grid.addWidget(gap_e, 2, 1) grid.addWidget(gap_e, 2, 1)
grid.addWidget(HelpButton(_('Keep the default value unless you modified this parameter in your wallet.')), 2, 3) grid.addWidget(HelpButton(_('Keep the default value unless you modified this parameter in your wallet.')), 2, 3)
vbox.addLayout(grid)
vbox.addLayout(grid)
vbox.addLayout(ok_cancel_buttons(d)) vbox.addLayout(ok_cancel_buttons(d))
d.setLayout(vbox) d.setLayout(vbox)
if not d.exec_(): return if not d.exec_(): return
if is_restore:
try:
gap = int(unicode(gap_e.text()))
except:
QMessageBox.warning(None, _('Error'), 'error', 'OK')
return
else:
gap = None
try: try:
seed = str(seed_e.text()) seed = str(seed_e.toPlainText())
seed.decode('hex') seed.decode('hex')
except: except:
print_error("Warning: Not hex, trying decode")
try: try:
seed = mnemonic.mn_decode( seed.split(' ') ) seed = mnemonic.mn_decode( seed.split(' ') )
except: except:
@ -2372,7 +2361,15 @@ class ElectrumGui:
QMessageBox.warning(None, _('Error'), _('No seed'), _('OK')) QMessageBox.warning(None, _('Error'), _('No seed'), _('OK'))
return return
return seed, gap if not is_restore:
return seed
else:
try:
gap = int(unicode(gap_e.text()))
except:
QMessageBox.warning(None, _('Error'), 'error', 'OK')
return
return seed, gap
def network_dialog(self): def network_dialog(self):

Loading…
Cancel
Save