diff --git a/electrum/gui/qml/components/WalletDetails.qml b/electrum/gui/qml/components/WalletDetails.qml index ea1052063..85da196f5 100644 --- a/electrum/gui/qml/components/WalletDetails.qml +++ b/electrum/gui/qml/components/WalletDetails.qml @@ -528,6 +528,9 @@ Pane { }) dialog.accepted.connect(function() { var success = Daemon.currentWallet.setPassword(dialog.password) + if (success && Config.walletShouldUseSinglePassword) { + Daemon.singlePassword = dialog.password + } var done_dialog = app.messageDialog.createObject(app, { title: success ? qsTr('Success') : qsTr('Error'), iconSource: success diff --git a/electrum/gui/qml/components/Wallets.qml b/electrum/gui/qml/components/Wallets.qml index 52dc31720..f9c9f84e3 100644 --- a/electrum/gui/qml/components/Wallets.qml +++ b/electrum/gui/qml/components/Wallets.qml @@ -121,7 +121,21 @@ Pane { Layout.fillWidth: true text: qsTr('Create Wallet') icon.source: '../../icons/add.png' - onClicked: rootItem.createWallet() + onClicked: { + if (Daemon.availableWallets.rowCount() > 0 && Config.walletShouldUseSinglePassword + && (!Daemon.singlePassword || Daemon.numWalletsWithPassword(Daemon.singlePassword) < 1)) { + // if the user has wallets but hasn't unlocked any wallet yet force them to do so. + // this ensures they know at least one wallets password and can complete the wizard + // where they will need to enter the password of an existing wallet. + var dialog = app.messageDialog.createObject(app, { + title: qsTr('Wallet unlock required'), + text: qsTr("You have to unlock any existing wallet first before creating a new wallet."), + }) + dialog.open() + } else { + rootItem.createWallet() + } + } } } diff --git a/electrum/gui/qml/qedaemon.py b/electrum/gui/qml/qedaemon.py index c31937d51..72e618b0c 100644 --- a/electrum/gui/qml/qedaemon.py +++ b/electrum/gui/qml/qedaemon.py @@ -356,8 +356,21 @@ class QEDaemon(AuthMixin, QObject): @pyqtProperty(str, notify=singlePasswordChanged) def singlePassword(self): + """ + self._password is also set to the last loaded wallet password if we WANT a single password, + but don't actually have a single password yet. So singlePassword being set doesn't strictly + mean all wallets use the same password. + """ return self._password + @singlePassword.setter + def singlePassword(self, password: str): + assert password + assert self.daemon.config.WALLET_SHOULD_USE_SINGLE_PASSWORD + if self._password != password: + self._password = password + self.singlePasswordChanged.emit() + @pyqtSlot(result=str) def suggestWalletName(self): # FIXME why not use util.get_new_wallet_name ?