Qt: stop support for password-protected wallets without
storage encryption. The password will be needed on startup with anchor channels. Note that it remains possible to use non-encrypted storage and keystore encryption with the command line.
This commit is contained in:
@@ -325,6 +325,7 @@ class ElectrumGui(BaseElectrumGui, Logger):
|
||||
self.build_tray_menu()
|
||||
w.warn_if_testnet()
|
||||
w.warn_if_watching_only()
|
||||
w.require_full_encryption()
|
||||
return w
|
||||
|
||||
def count_wizards_in_progress(func):
|
||||
@@ -394,6 +395,8 @@ class ElectrumGui(BaseElectrumGui, Logger):
|
||||
break
|
||||
else:
|
||||
window = self._create_window_for_wallet(wallet)
|
||||
except UserCancelled:
|
||||
return
|
||||
except Exception as e:
|
||||
self.logger.exception('')
|
||||
err_text = str(e) if isinstance(e, WalletFileException) else repr(e)
|
||||
|
||||
@@ -568,6 +568,24 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
|
||||
])
|
||||
self.show_warning(msg, title=_('Watch-only wallet'))
|
||||
|
||||
def require_full_encryption(self):
|
||||
if self.wallet.has_keystore_encryption() and not self.wallet.has_storage_encryption():
|
||||
msg = ' '.join([
|
||||
_("Your wallet is password-protected, but the wallet file is not encrypted."),
|
||||
_("This is no longer supported."),
|
||||
_("Please enter your password in order to encrypt your wallet file."),
|
||||
])
|
||||
while True:
|
||||
password = self.password_dialog(msg)
|
||||
if not password:
|
||||
self.close()
|
||||
raise UserCancelled()
|
||||
try:
|
||||
self.wallet.update_password(password, password, encrypt_storage=True)
|
||||
break
|
||||
except InvalidPassword as e:
|
||||
self.show_error(str(e))
|
||||
|
||||
def warn_if_testnet(self):
|
||||
if not constants.net.TESTNET:
|
||||
return
|
||||
|
||||
@@ -64,7 +64,7 @@ class PasswordLayout(object):
|
||||
|
||||
titles = [_("Enter Password"), _("Change Password"), _("Enter Passphrase")]
|
||||
|
||||
def __init__(self, msg, kind, OK_button, wallet=None, force_disable_encrypt_cb=False):
|
||||
def __init__(self, msg, kind, OK_button, wallet=None):
|
||||
self.wallet = wallet
|
||||
|
||||
self.pw = PasswordLineEdit()
|
||||
@@ -123,17 +123,9 @@ class PasswordLayout(object):
|
||||
grid.addWidget(self.pw_strength, 3, 0, 1, 2)
|
||||
self.new_pw.textChanged.connect(self.pw_changed)
|
||||
|
||||
self.encrypt_cb = QCheckBox(_('Encrypt wallet file'))
|
||||
self.encrypt_cb.setEnabled(False)
|
||||
grid.addWidget(self.encrypt_cb, 4, 0, 1, 2)
|
||||
if kind == PW_PASSPHRASE:
|
||||
self.encrypt_cb.setVisible(False)
|
||||
|
||||
def enable_OK():
|
||||
ok = self.new_pw.text() == self.conf_pw.text()
|
||||
OK_button.setEnabled(ok)
|
||||
self.encrypt_cb.setEnabled(ok and bool(self.new_pw.text())
|
||||
and not force_disable_encrypt_cb)
|
||||
self.new_pw.textChanged.connect(enable_OK)
|
||||
self.conf_pw.textChanged.connect(enable_OK)
|
||||
enable_OK()
|
||||
@@ -211,9 +203,6 @@ class PasswordLayoutForHW(object):
|
||||
|
||||
vbox.addLayout(grid)
|
||||
|
||||
self.encrypt_cb = QCheckBox(_('Encrypt wallet file'))
|
||||
grid.addWidget(self.encrypt_cb, 1, 0, 1, 2)
|
||||
|
||||
self.vbox = vbox
|
||||
|
||||
def title(self):
|
||||
@@ -237,7 +226,6 @@ class ChangePasswordDialogBase(WindowModalDialog):
|
||||
vbox.addLayout(self.playout.layout())
|
||||
vbox.addStretch(1)
|
||||
vbox.addLayout(Buttons(CancelButton(self), OK_button))
|
||||
self.playout.encrypt_cb.setChecked(is_encrypted)
|
||||
|
||||
def create_password_layout(self, wallet, is_encrypted, OK_button):
|
||||
raise NotImplementedError()
|
||||
@@ -245,11 +233,6 @@ class ChangePasswordDialogBase(WindowModalDialog):
|
||||
|
||||
class ChangePasswordDialogForSW(ChangePasswordDialogBase):
|
||||
|
||||
def __init__(self, parent, wallet):
|
||||
ChangePasswordDialogBase.__init__(self, parent, wallet)
|
||||
if not wallet.has_password():
|
||||
self.playout.encrypt_cb.setChecked(True)
|
||||
|
||||
def create_password_layout(self, wallet, is_encrypted, OK_button):
|
||||
if not wallet.has_password():
|
||||
msg = _('Your wallet is not protected.')
|
||||
@@ -260,17 +243,17 @@ class ChangePasswordDialogForSW(ChangePasswordDialogBase):
|
||||
else:
|
||||
msg = _('Your wallet is password protected and encrypted.')
|
||||
msg += ' ' + _('Use this dialog to change your password.')
|
||||
self.playout = PasswordLayout(msg=msg,
|
||||
kind=PW_CHANGE,
|
||||
OK_button=OK_button,
|
||||
wallet=wallet,
|
||||
force_disable_encrypt_cb=not wallet.can_have_keystore_encryption())
|
||||
self.playout = PasswordLayout(
|
||||
msg=msg,
|
||||
kind=PW_CHANGE,
|
||||
OK_button=OK_button,
|
||||
wallet=wallet)
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
if not self.exec():
|
||||
return False, None, None, None
|
||||
return True, self.playout.old_password(), self.playout.new_password(), self.playout.encrypt_cb.isChecked()
|
||||
return True, self.playout.old_password(), self.playout.new_password(), True
|
||||
finally:
|
||||
self.playout.clear_password_fields()
|
||||
|
||||
@@ -292,7 +275,7 @@ class ChangePasswordDialogForHW(ChangePasswordDialogBase):
|
||||
def run(self):
|
||||
if not self.exec():
|
||||
return False, None
|
||||
return True, self.playout.encrypt_cb.isChecked()
|
||||
return True, True
|
||||
|
||||
|
||||
class PasswordDialog(WindowModalDialog):
|
||||
@@ -301,8 +284,10 @@ class PasswordDialog(WindowModalDialog):
|
||||
msg = msg or _('Please enter your password')
|
||||
WindowModalDialog.__init__(self, parent, _("Enter Password"))
|
||||
self.pw = pw = PasswordLineEdit()
|
||||
label = QLabel(msg)
|
||||
label.setWordWrap(True)
|
||||
vbox = QVBoxLayout()
|
||||
vbox.addWidget(QLabel(msg))
|
||||
vbox.addWidget(label)
|
||||
grid = QGridLayout()
|
||||
grid.setSpacing(8)
|
||||
grid.addWidget(QLabel(_('Password')), 1, 0)
|
||||
|
||||
Reference in New Issue
Block a user