qml: disable 'Create Wallet' before first unlock
If the user has not unlocked any wallet yet and tries to create a new wallet in the overview a dialog will prompt them to first unlock an existing wallet in order to be able to create a new wallet. This ensures they remember at least one password so they can complete the wizard. The wizard will ask them for an existing password later and it would be annoying for the user to go through all steps (writing down the seed etc.) only to find out they need a password they don't remember. This way they can reinstall the app right before going through the wizard.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 ?
|
||||
|
||||
Reference in New Issue
Block a user