default sp wallet birthdate to creation time to avoid full rescans
What changed, and why it matters
This commit changes Sparrow Wallet so that newly created or renamed single-signature (SINGLE_SP) wallets get a default 'birth date' set to the current time. The birth date tells the wallet how far back in the blockchain it needs to scan for transactions. Without it, the wallet would perform a full rescan of the entire blockchain, which is slow and resource-intensive. The change is a performance/usability improvement, not a security fix.
No security action required. Treat as a normal performance/usability improvement. If reviewing for completeness, verify that multi-signature and other policy types still behave as intended and that the birth date is persisted correctly.
Security signals we found
No security-relevant signals detected in the diff or commit message.
Change is framed as a performance/usability improvement to avoid full rescans.
No input validation, cryptographic, authorization, or secret-handling changes observed.
Evidence from the diff
The patch adds wallet.setBirthDate(new Date()) for PolicyType.SINGLE_SP wallets in three flows: AppController rename, terminal BIP39 wallet creation, and SettingsController apply. It also updates WalletNameDialog to request a birth date for SINGLE_SP wallets even when not connected to Bitcoin Core. The intent is to avoid full blockchain rescans by anchoring the wallet’s scan range to creation time.
Changed components
src/main/java/com/sparrowwallet/sparrow/AppController.javasrc/main/java/com/sparrowwallet/sparrow/control/WalletNameDialog.javasrc/main/java/com/sparrowwallet/sparrow/terminal/wallet/Bip39Dialog.javasrc/main/java/com/sparrowwallet/sparrow/wallet/SettingsController.javaInspect captured patch +17 / −2
diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java
index 053418c..68ec821 100644
--- a/src/main/java/com/sparrowwallet/sparrow/AppController.java
+++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java
@@ -1328,13 +1328,16 @@ public class AppController implements Initializable {
return;
}
- WalletNameDialog nameDlg = new WalletNameDialog(wallet.getName(), true, wallet.getBirthDate());
+ WalletNameDialog nameDlg = new WalletNameDialog(wallet.getName(), true, wallet.getPolicyType(), wallet.getBirthDate(), false);
nameDlg.initOwner(rootStack.getScene().getWindow());
Optional<WalletNameDialog.NameAndBirthDate> optNameAndBirthDate = nameDlg.showAndWait();
if(optNameAndBirthDate.isPresent()) {
WalletNameDialog.NameAndBirthDate nameAndBirthDate = optNameAndBirthDate.get();
wallet.setName(nameAndBirthDate.getName());
wallet.setBirthDate(nameAndBirthDate.getBirthDate());
+ if(wallet.getPolicyType() == PolicyType.SINGLE_SP && wallet.getBirthDate() == null) {
+ wallet.setBirthDate(new Date());
+ }
} else {
return;
}
diff --git a/src/main/java/com/sparrowwallet/sparrow/control/WalletNameDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/WalletNameDialog.java
index 7956714..9b76a4a 100644
--- a/src/main/java/com/sparrowwallet/sparrow/control/WalletNameDialog.java
+++ b/src/main/java/com/sparrowwallet/sparrow/control/WalletNameDialog.java
@@ -1,5 +1,6 @@
package com.sparrowwallet.sparrow.control;
+import com.sparrowwallet.drongo.policy.PolicyType;
import com.sparrowwallet.sparrow.AppServices;
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5;
import com.sparrowwallet.sparrow.io.Config;
@@ -48,9 +49,13 @@ public class WalletNameDialog extends Dialog<WalletNameDialog.NameAndBirthDate>
}
public WalletNameDialog(String initialName, boolean hasExistingTransactions, Date startDate, boolean rename) {
+ this(initialName, hasExistingTransactions, null, startDate, rename);
+ }
+
+ public WalletNameDialog(String initialName, boolean hasExistingTransactions, PolicyType walletPolicyType, Date startDate, boolean rename) {
final DialogPane dialogPane = getDialogPane();
AppServices.setStageIcon(dialogPane.getScene().getWindow());
- boolean requestBirthDate = !rename && (Config.get().getServerType() == null || Config.get().getServerType() == ServerType.BITCOIN_CORE);
+ boolean requestBirthDate = !rename && (walletPolicyType == PolicyType.SINGLE_SP || Config.get().getServerType() == null || Config.get().getServerType() == ServerType.BITCOIN_CORE);
setTitle("Wallet Name");
dialogPane.setHeaderText("Enter a name for this wallet:");
diff --git a/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/Bip39Dialog.java b/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/Bip39Dialog.java
index 610bd1a..92c2248 100644
--- a/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/Bip39Dialog.java
+++ b/src/main/java/com/sparrowwallet/sparrow/terminal/wallet/Bip39Dialog.java
@@ -20,6 +20,7 @@ import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Date;
import java.util.List;
public class Bip39Dialog extends NewWalletDialog {
@@ -160,6 +161,9 @@ public class Bip39Dialog extends NewWalletDialog {
Keystore keystore = importer.getKeystore(type.policyType(), wallet.getScriptType().getDefaultDerivation(), getWords(), passphrase.getText());
wallet.getKeystores().add(keystore);
wallet.setDefaultPolicy(Policy.getPolicy(type.policyType(), wallet.getScriptType(), wallet.getKeystores(), 1));
+ if(type.policyType() == PolicyType.SINGLE_SP) {
+ wallet.setBirthDate(new Date());
+ }
return List.of(wallet);
}
diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsController.java
index b5de85b..659aced 100644
--- a/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsController.java
+++ b/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsController.java
@@ -259,6 +259,9 @@ public class SettingsController extends WalletFormController implements Initiali
revert.setDisable(true);
apply.setDisable(true);
boolean addressChange = ((SettingsWalletForm)walletForm).isAddressChange();
+ if(walletForm.getWallet().getPolicyType() == PolicyType.SINGLE_SP && walletForm.getWallet().getBirthDate() == null && walletForm.getStorage().getEncryptionPubKey() == null) {
+ walletForm.getWallet().setBirthDate(new Date());
+ }
saveWallet(false, false);
Wallet wallet = walletForm.getWallet();
Why this scored 19/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.