1
0

qml: enforce single password on password change

If a qml user with non-uniform wallet passwords tries to change their wallet
password this will force them to change it to a password that is used by
at least one other wallet. This will guide them towards a single wallet
password and prevents the number of different passwords from increasing.
This commit is contained in:
f321x
2025-12-18 11:12:16 +01:00
parent 378a9e6112
commit 02abc0e6cd

View File

@@ -525,18 +525,33 @@ Pane {
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')
+ (Daemon.availableWallets.rowCount() > 1 && Config.walletShouldUseSinglePassword
? "\n\n" + qsTr('The new password needs to match the password of any other existing wallet.')
: "")
})
dialog.accepted.connect(function() {
var success = Daemon.currentWallet.setPassword(dialog.password)
if (success && Config.walletShouldUseSinglePassword) {
Daemon.singlePassword = dialog.password
if (Config.walletShouldUseSinglePassword // android
&& Daemon.availableWallets.rowCount() > 1 // has more than one wallet
&& Daemon.numWalletsWithPassword(dialog.password) < 1 // no other wallet uses this new password
) {
var success = false
var error_msg = [
qsTr('You need to use the password of any other existing wallet.'),
qsTr('Using different wallet passwords is not supported.'),
].join("\n")
} else {
var success = Daemon.currentWallet.setPassword(dialog.password)
if (success && Config.walletShouldUseSinglePassword) {
Daemon.singlePassword = dialog.password
}
var error_msg = qsTr('Password change failed')
}
var done_dialog = app.messageDialog.createObject(app, {
title: success ? qsTr('Success') : qsTr('Error'),
iconSource: success
? Qt.resolvedUrl('../../icons/info.png')
: Qt.resolvedUrl('../../icons/warning.png'),
text: success ? qsTr('Password changed') : qsTr('Password change failed')
text: success ? qsTr('Password changed') : error_msg
})
done_dialog.open()
})