seed v6
[electrum-nvc.git] / gui / qt / seed_dialog.py
1 #!/usr/bin/env python
2 #
3 # Electrum - lightweight Bitcoin client
4 # Copyright (C) 2013 ecdsa@github
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 from PyQt4.QtGui import *
20 from PyQt4.QtCore import *
21 import PyQt4.QtCore as QtCore
22 from electrum.i18n import _
23 from electrum import mnemonic
24 from qrcodewidget import QRCodeWidget
25 from util import close_button
26
27 class SeedDialog(QDialog):
28     def __init__(self, parent, seed, imported_keys):
29         QDialog.__init__(self, parent)
30         self.setModal(1)
31         self.setWindowTitle('Electrum' + ' - ' + _('Seed'))
32         self.parent = parent
33
34         vbox = make_seed_dialog(seed, imported_keys)
35         vbox.addLayout(close_button(self))
36         self.setLayout(vbox)
37
38
39
40 class PrivateKeysDialog(QDialog):
41     def __init__(self, parent, private_keys):
42         QDialog.__init__(self, parent)
43         self.setModal(1)
44         self.setWindowTitle('Electrum' + ' - ' + _('Master Private Keys'))
45         self.parent = parent
46         vbox = QVBoxLayout(self)
47         vbox.addWidget(QLabel(_("The seed has been removed from the wallet. It contains the following master private keys")+ ":"))
48         for k,v in sorted(private_keys.items()):
49             vbox.addWidget(QLabel(k))
50             vbox.addWidget(QLineEdit(v))
51
52         vbox.addLayout(close_button(self))
53
54
55
56
57
58 def make_seed_dialog(seed, imported_keys):
59
60         words = seed.split()
61
62         label1 = QLabel(_("Your wallet generation seed is")+ ":")
63
64         seed_text = QTextEdit(seed)
65         seed_text.setReadOnly(True)
66         seed_text.setMaximumHeight(130)
67         
68         msg2 =  _("Please write down or memorize these %d words (order is important).")%len(words) + " " \
69               + _("This seed will allow you to recover your wallet in case of computer failure.") + " " \
70               + _("Your seed is also displayed as QR code, in case you want to transfer it to a mobile phone.") + "<p>" \
71               + "<b>"+_("WARNING")+":</b> " + _("Never disclose your seed. Never type it on a website.") + "</b><p>"
72         if imported_keys:
73             msg2 += "<b>"+_("WARNING")+":</b> " + _("Your wallet contains imported keys. These keys cannot be recovered from seed.") + "</b><p>"
74         label2 = QLabel(msg2)
75         label2.setWordWrap(True)
76
77         logo = QLabel()
78         logo.setPixmap(QPixmap(":icons/seed.png").scaledToWidth(56))
79         logo.setMaximumWidth(60)
80
81         qrw = QRCodeWidget(seed)
82
83         grid = QGridLayout()
84
85         grid.addWidget(logo, 0, 0)
86         grid.addWidget(label1, 0, 1)
87
88         grid.addWidget(seed_text, 1, 0, 1, 2)
89
90         grid.addWidget(qrw, 0, 2, 2, 1)
91
92         vbox = QVBoxLayout()
93         vbox.addLayout(grid)
94         vbox.addWidget(label2)
95
96         return vbox