electrum-bitcoinprivate/gui/qt/seed_dialog.py

95 lines
3.2 KiB
Python
Raw Normal View History

#!/usr/bin/env python
#
# Electrum - lightweight Bitcoin client
# Copyright (C) 2013 ecdsa@github
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from PyQt4.QtGui import *
from PyQt4.QtCore import *
import PyQt4.QtCore as QtCore
2013-09-11 04:55:49 -07:00
from electrum.i18n import _
from util import *
from qrtextedit import ShowQRTextEdit, ScanQRTextEdit
class SeedDialog(WindowModalDialog):
2013-10-03 00:19:09 -07:00
def __init__(self, parent, seed, imported_keys):
WindowModalDialog.__init__(self, parent, ('Electrum - ' + _('Seed')))
2014-07-07 11:58:37 -07:00
self.setMinimumWidth(400)
vbox = show_seed_box_msg(seed)
2014-04-06 12:38:53 -07:00
if imported_keys:
vbox.addWidget(QLabel("<b>"+_("WARNING")+":</b> " + _("Your wallet contains imported keys. These keys cannot be recovered from seed.") + "</b><p>"))
2015-03-14 04:28:19 -07:00
vbox.addLayout(Buttons(CloseButton(self)))
2013-10-03 00:19:09 -07:00
self.setLayout(vbox)
2014-04-19 11:23:27 -07:00
def icon_filename(sid):
if sid == 'cold':
return ":icons/cold_seed.png"
2014-04-19 11:23:27 -07:00
elif sid == 'hot':
return ":icons/hot_seed.png"
2014-04-19 11:23:27 -07:00
else:
return ":icons/seed.png"
class SeedLayout(object):
def __init__(self, seed, sid=None):
if seed:
self.vbox = self.seed_and_warning_layout(seed, sid)
else:
self.vbox = self.seed_layout(seed, sid)
2014-04-19 11:23:27 -07:00
def layout(self):
return self.vbox
2014-04-19 11:23:27 -07:00
def seed_edit(self):
return self.seed_e
2014-04-19 11:23:27 -07:00
def seed_and_warning_layout(self, seed, sid=None):
vbox = QVBoxLayout()
vbox.addLayout(self.seed_layout(seed, sid))
msg = ''.join([
"<p>",
_("Please save these %d words on paper (order is important). "),
_("This seed will allow you to recover your wallet in case "
"of computer failure.") + "<br/>",
"</p>",
"<b>" + _("WARNING") + ":</b> ",
"<ul>",
"<li>" + _("Never disclose your seed.") + "</li>",
"<li>" + _("Never type it on a website.") + "</li>",
"<li>" + _("Do not send your seed to a printer.") + "</li>",
"</ul>"
]) % len(seed.split())
label2 = QLabel(msg)
label2.setWordWrap(True)
vbox.addWidget(label2)
return vbox
def seed_layout(self, seed, sid=None):
logo = QLabel()
logo.setPixmap(QPixmap(icon_filename(sid)).scaledToWidth(56))
logo.setMaximumWidth(60)
if not seed:
seed_e = ScanQRTextEdit()
seed_e.setTabChangesFocus(True)
else:
seed_e = ShowQRTextEdit(text=seed)
seed_e.setMaximumHeight(100)
self.seed_e = seed_e
hbox = QHBoxLayout()
hbox.addWidget(logo)
hbox.addWidget(seed_e)
return hbox