Browse Source

master privae keys dialog

283
ThomasV 11 years ago
parent
commit
5136e59e14
  1. 36
      gui/qt/main_window.py
  2. 29
      gui/qt/seed_dialog.py
  3. 4
      lib/wallet.py

36
gui/qt/main_window.py

@ -259,7 +259,7 @@ class ElectrumWindow(QMainWindow):
self.wallet = wallet
title = 'Electrum ' + self.wallet.electrum_version + ' - ' + self.wallet.storage.path
if not self.wallet.seed: title += ' [%s]' % (_('seedless'))
if self.wallet.is_watching_only(): title += ' [%s]' % (_('watching only'))
self.setWindowTitle( title )
self.update_wallet()
# Once GUI has been initialized check if we want to announce something since the callback has been called before the GUI was initialized
@ -376,7 +376,6 @@ class ElectrumWindow(QMainWindow):
wallet_menu.addSeparator()
#if self.wallet.seed:
show_seed = wallet_menu.addAction(_("&Seed"))
show_seed.triggered.connect(self.show_seed_dialog)
@ -1347,7 +1346,7 @@ class ElectrumWindow(QMainWindow):
def update_buttons_on_seed(self):
if self.wallet.seed:
if not self.wallet.is_watching_only():
self.seed_button.show()
self.password_button.show()
self.send_button.setText(_("Send"))
@ -1487,18 +1486,29 @@ class ElectrumWindow(QMainWindow):
@protected
def show_seed_dialog(self, password):
if not self.wallet.seed:
QMessageBox.information(self, _('Message'), _('No seed'), _('OK'))
return
try:
seed = self.wallet.decode_seed(password)
except:
QMessageBox.warning(self, _('Error'), _('Incorrect Password'), _('OK'))
if self.wallet.is_watching_only():
QMessageBox.information(self, _('Message'), _('This is a watching-only wallet'), _('OK'))
return
from seed_dialog import SeedDialog
d = SeedDialog(self)
d.show_seed(seed, self.wallet.imported_keys)
if self.wallet.seed:
try:
seed = self.wallet.decode_seed(password)
except:
QMessageBox.warning(self, _('Error'), _('Incorrect Password'), _('OK'))
return
from seed_dialog import SeedDialog
d = SeedDialog(self)
d.show_seed(seed, self.wallet.imported_keys)
else:
l = {}
for k in self.wallet.master_private_keys.keys():
pk = self.wallet.get_master_private_key(k, password)
l[k] = pk
from seed_dialog import PrivateKeysDialog
d = PrivateKeysDialog(self,l)
d.exec_()

29
gui/qt/seed_dialog.py

@ -22,6 +22,7 @@ import PyQt4.QtCore as QtCore
from electrum.i18n import _
from electrum import mnemonic
from qrcodewidget import QRCodeWidget
from util import close_button
class SeedDialog(QDialog):
def __init__(self, parent):
@ -35,6 +36,24 @@ class SeedDialog(QDialog):
self.exec_()
class PrivateKeysDialog(QDialog):
def __init__(self, parent, private_keys):
QDialog.__init__(self, parent)
self.setModal(1)
self.setWindowTitle('Electrum' + ' - ' + _('Master Private Keys'))
self.parent = parent
vbox = QVBoxLayout(self)
vbox.addWidget(QLabel(_("The seed has been removed from the wallet. It contains the following master private keys")+ ":"))
for k,v in sorted(private_keys.items()):
vbox.addWidget(QLabel(k))
vbox.addWidget(QLineEdit(v))
vbox.addLayout(close_button(self))
def make_seed_dialog(self, seed, imported_keys):
brainwallet = ' '.join(mnemonic.mn_encode(seed))
@ -60,12 +79,7 @@ def make_seed_dialog(self, seed, imported_keys):
qrw = QRCodeWidget(seed)
ok_button = QPushButton(_("OK"))
ok_button.setDefault(True)
ok_button.clicked.connect(self.accept)
grid = QGridLayout()
#main_layout.addWidget(logo, 0, 0)
grid.addWidget(logo, 0, 0)
grid.addWidget(label1, 0, 1)
@ -78,9 +92,6 @@ def make_seed_dialog(self, seed, imported_keys):
vbox.addLayout(grid)
vbox.addWidget(label2)
hbox = QHBoxLayout()
hbox.addStretch(1)
hbox.addWidget(ok_button)
vbox.addLayout(hbox)
vbox.addLayout(close_button(self))
self.setLayout(vbox)

4
lib/wallet.py

@ -333,6 +333,10 @@ class Wallet:
self.master_private_keys.pop(k)
self.storage.put('master_private_keys', self.master_private_keys, True)
def is_watching_only(self):
return (self.seed == '') and (self.master_private_keys == {})
def account_id(self, account_type, i):
if account_type == '1':

Loading…
Cancel
Save