delete backups made before a password was added or changed from the terminal settings
What changed, and why it matters
This commit changes how Sparrow Wallet's terminal (command-line) version handles wallet backups when a password is added, changed, or removed. Previously, old unencrypted or differently-encrypted backups might have been kept on disk. After this change, the terminal version behaves like the desktop version: when a password is set or changed, backups made under the old password (or no password) are deleted. This reduces the risk that an attacker or another user could find an old, less-protected copy of the wallet and access its data.
Users of the terminal version should upgrade to a release containing this commit. Developers should verify that the Storage.setEncryptionPubKey overload correctly deletes only pre-change backups and does not remove current backups or other wallet data. Review whether the no-password path (UPDATE_SET/UPDATE_EMPTY) is handled consistently across desktop and terminal code.
Security signals we found
Deletion of stale wallet backups when password changes
Alignment of terminal wallet behavior with desktop wallet security behavior
Prevention of recovery of wallet data from older, differently encrypted or unencrypted backups
Evidence from the diff
The patch modifies SettingsDialog.java in the terminal wallet module. It updates two calls to Storage.setEncryptionPubKey so they pass a boolean flag indicating whether the password is being changed. The second call also deletes backups created before the new password was applied when changePassword is true or when an empty password is being updated to a real one. The comment explicitly states this mirrors desktop behavior. The first change handles the no-password case and passes changePassword as well, likely for consistency in the storage layer’s backup cleanup logic.
Changed components
Sparrow Wallet terminal wallet settings dialogWallet storage encryption key handlingWallet backup retention policyInspect captured patch +3 / −2
### src/main/java/com/sparrowwallet/sparrow/terminal/wallet/SettingsDialog.java
@@ -202,7 +202,7 @@ private boolean saveWallet(boolean changePassword, boolean suggestChangePassword
Platform.runLater(() -> {
if(password.length() == 0 && requirement != PasswordRequirement.UPDATE_SET) {
try {
- walletForm.getStorage().setEncryptionPubKey(Storage.NO_PASSWORD_KEY);
+ walletForm.getStorage().setEncryptionPubKey(Storage.NO_PASSWORD_KEY, changePassword);
walletForm.saveAndRefresh();
EventManager.get().post(new RequestOpenWalletsEvent());
} catch (IOException | StorageException e) {
@@ -264,7 +264,8 @@ private boolean saveWallet(boolean changePassword, boolean suggestChangePassword
childWallet.encrypt(key);
}
}
- walletForm.getStorage().setEncryptionPubKey(encryptionPubKey);
+ //Backups made without this password are deleted once the wallet is saved with it, as on the desktop by default
+ walletForm.getStorage().setEncryptionPubKey(encryptionPubKey, changePassword || requirement == PasswordRequirement.UPDATE_EMPTY);
walletForm.saveAndRefresh();
EventManager.get().post(new RequestOpenWalletsEvent());
} catch (Exception e) {Why this scored 42/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.