diff --git a/electrum/gui/qml/components/PasswordDialog.qml b/electrum/gui/qml/components/PasswordDialog.qml index 276f1a4a3..743333e48 100644 --- a/electrum/gui/qml/components/PasswordDialog.qml +++ b/electrum/gui/qml/components/PasswordDialog.qml @@ -74,7 +74,7 @@ ElDialog { Layout.fillWidth: true text: qsTr("Ok") icon.source: '../../icons/confirmed.png' - enabled: confirmPassword ? pw_1.text == pw_2.text : true + enabled: confirmPassword ? pw_1.text.length > 4 && pw_1.text == pw_2.text : true onClicked: { password = pw_1.text passworddialog.accept() diff --git a/electrum/gui/qml/components/WalletDetails.qml b/electrum/gui/qml/components/WalletDetails.qml index 7ab98b254..9bcf2b342 100644 --- a/electrum/gui/qml/components/WalletDetails.qml +++ b/electrum/gui/qml/components/WalletDetails.qml @@ -508,18 +508,23 @@ Pane { app.stack.pop() } function onRequestNewPassword() { // new unified password (all wallets) - var dialog = app.passwordDialog.createObject(app, - { - 'confirmPassword': true, - 'title': qsTr('Enter new password'), - 'infotext': qsTr('If you forget your password, you\'ll need to\ - restore from seed. Please make sure you have your seed stored safely') - } ) + var dialog = app.passwordDialog.createObject(app, { + confirmPassword: true, + title: qsTr('Enter new password'), + infotext: qsTr('If you forget your password, you\'ll need to restore from seed. Please make sure you have your seed stored safely') + }) dialog.accepted.connect(function() { Daemon.setPassword(dialog.password) }) dialog.open() } + function onPasswordChangeFailed() { + var dialog = app.messageDialog.createObject(app, { + title: qsTr('Error'), + text: qsTr('Password change failed') + }) + dialog.open() + } function onWalletDeleteError(code, message) { if (code == 'unpaid_requests') { var dialog = app.messageDialog.createObject(app, {text: message, yesno: true }) @@ -544,9 +549,9 @@ Pane { target: Daemon.currentWallet function onRequestNewPassword() { // new wallet password var dialog = app.passwordDialog.createObject(app, { - 'confirmPassword': true, - 'title': qsTr('Enter new password'), - 'infotext': qsTr('If you forget your password, you\'ll need to restore from seed. Please make sure you have your seed stored safely') + confirmPassword: true, + title: qsTr('Enter new password'), + infotext: qsTr('If you forget your password, you\'ll need to restore from seed. Please make sure you have your seed stored safely') }) dialog.accepted.connect(function() { Daemon.currentWallet.set_password(dialog.password) diff --git a/electrum/gui/qml/qedaemon.py b/electrum/gui/qml/qedaemon.py index 6c8fb0801..16e97bcea 100644 --- a/electrum/gui/qml/qedaemon.py +++ b/electrum/gui/qml/qedaemon.py @@ -127,6 +127,7 @@ class QEDaemon(AuthMixin, QObject): newWalletWizardChanged = pyqtSignal() serverConnectWizardChanged = pyqtSignal() loadingChanged = pyqtSignal() + passwordChangeFailed = pyqtSignal() walletLoaded = pyqtSignal([str,str], arguments=['name','path']) walletRequiresPassword = pyqtSignal([str,str], arguments=['name','path']) @@ -316,11 +317,10 @@ class QEDaemon(AuthMixin, QObject): @pyqtSlot(str) def setPassword(self, password): assert self._use_single_password - # map empty string password to None - if password == '': - password = None - self._logger.debug('about to set password for ALL wallets') - self.daemon.update_password_for_directory(old_password=self._password, new_password=password) + assert password + if not self.daemon.update_password_for_directory(old_password=self._password, new_password=password): + self.passwordChangeFailed.emit() + return self._password = password @pyqtProperty(QENewWalletWizard, notify=newWalletWizardChanged)