treat whitespace-only labels as blank on label import and export
What changed, and why it matters
This commit tightens how Sparrow Wallet treats labels made only of spaces or tabs during wallet label import and export. Previously, a label consisting solely of whitespace was considered a real label; now it is treated as blank and skipped. The change also renames an unrelated UI field from 'useDustLimitField' to 'ignoreDustField' for clarity. There is no direct security vulnerability here, but the fix prevents minor data-quality issues and avoids surprising behavior where whitespace-only labels are exported or imported as meaningful labels.
No urgent action needed. Treat as a routine quality fix. Reviewers may verify that downstream consumers of WalletLabels do not rely on whitespace-only labels being preserved.
Security signals we found
Behavioral hardening: whitespace-only strings now treated as absent labels
No input validation bypass, memory safety, or cryptographic changes observed
Potential minor UI/data-integrity issue mitigated, not a vulnerability
Evidence from the diff
The patch replaces String.isEmpty() checks with String.isBlank() in WalletLabels.java for keystore labels, output labels, and transaction input/output labels during both export and import. isBlank() returns true for null-safe non-empty strings that contain only whitespace, so whitespace-only labels are now ignored. A separate cosmetic change in PrivateKeySweepDialog.java renames a field variable to match its ‘Ignore dust’ label. No cryptographic, network, or access-control changes are present.
Changed components
src/main/java/com/sparrowwallet/sparrow/io/WalletLabels.javasrc/main/java/com/sparrowwallet/sparrow/control/PrivateKeySweepDialog.javaInspect captured patch +10 / −9
diff --git a/src/main/java/com/sparrowwallet/sparrow/control/PrivateKeySweepDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/PrivateKeySweepDialog.java
index 43f30d6..0c20515 100644
--- a/src/main/java/com/sparrowwallet/sparrow/control/PrivateKeySweepDialog.java
+++ b/src/main/java/com/sparrowwallet/sparrow/control/PrivateKeySweepDialog.java
@@ -171,12 +171,12 @@ public class PrivateKeySweepDialog extends Dialog<Transaction> {
feeRange.setFeeRate(AppServices.getDefaultFeeRate());
updateFeeRate();
- Field useDustLimitField = new Field();
- useDustLimitField.setText("Ignore dust:");
+ Field ignoreDustField = new Field();
+ ignoreDustField.setText("Ignore dust:");
ignoreDust = new UnlabeledToggleSwitch();
- useDustLimitField.getInputs().add(ignoreDust);
+ ignoreDustField.getInputs().add(ignoreDust);
- fieldset.getChildren().addAll(keyField, keyScriptTypeField, addressField, toAddressField, feeRangeField, feeRateField, useDustLimitField);
+ fieldset.getChildren().addAll(keyField, keyScriptTypeField, addressField, toAddressField, feeRangeField, feeRateField, ignoreDustField);
form.getChildren().add(fieldset);
dialogPane.setContent(form);
@@ -397,6 +397,7 @@ public class PrivateKeySweepDialog extends Dialog<Transaction> {
return;
}
}
+
createTransaction(privateKey.getKey(), scriptType, utxos, payment);
});
addressUtxosService.setOnFailed(failedEvent -> {
diff --git a/src/main/java/com/sparrowwallet/sparrow/io/WalletLabels.java b/src/main/java/com/sparrowwallet/sparrow/io/WalletLabels.java
index f22fa85..7ae56c0 100644
--- a/src/main/java/com/sparrowwallet/sparrow/io/WalletLabels.java
+++ b/src/main/java/com/sparrowwallet/sparrow/io/WalletLabels.java
@@ -68,7 +68,7 @@ public class WalletLabels implements WalletImport, WalletExport {
String origin = outputDescriptor.toString(true, false, false);
for(Keystore keystore : exportWallet.getKeystores()) {
- if(keystore.getLabel() != null && !keystore.getLabel().isEmpty()) {
+ if(keystore.getLabel() != null && !keystore.getLabel().isBlank()) {
if(exportWallet.getPolicyType() == PolicyType.SINGLE_SP && keystore.getSilentPaymentScanAddress() != null) {
labels.add(new Label(Type.spscan, keystore.getSilentPaymentScanAddress().toKeyString(), keystore.getLabel(), null, null));
} else if(keystore.getExtendedPublicKey() != null) {
@@ -186,10 +186,10 @@ public class WalletLabels implements WalletImport, WalletExport {
}
if(label.type == Type.output) {
- if((label.label == null || label.label.isEmpty()) && label.spendable == null) {
+ if((label.label == null || label.label.isBlank()) && label.spendable == null) {
continue;
}
- } else if(label.label == null || label.label.isEmpty()) {
+ } else if(label.label == null || label.label.isBlank()) {
continue;
}
@@ -276,7 +276,7 @@ public class WalletLabels implements WalletImport, WalletExport {
BlockTransactionHashIndex reference = txioEntry.getHashIndex();
if((label.type == Type.output && txioEntry.getType() == HashIndexEntry.Type.OUTPUT && reference.toString().equals(label.ref))
|| (label.type == Type.input && txioEntry.getType() == HashIndexEntry.Type.INPUT && reference.toString().equals(label.ref))) {
- if(label.label != null && !label.label.isEmpty()) {
+ if(label.label != null && !label.label.isBlank()) {
reference.setLabel(label.label);
txioEntry.labelProperty().set(label.label);
addChangedEntry(changedWalletEntries, txioEntry);
@@ -332,7 +332,7 @@ public class WalletLabels implements WalletImport, WalletExport {
BlockTransactionHashIndex reference = hashIndexEntry.getHashIndex();
if((label.type == Type.output && hashIndexEntry.getType() == HashIndexEntry.Type.OUTPUT && reference.toString().equals(label.ref))
|| (label.type == Type.input && hashIndexEntry.getType() == HashIndexEntry.Type.INPUT && reference.toString().equals(label.ref))) {
- if(label.label != null && !label.label.isEmpty()) {
+ if(label.label != null && !label.label.isBlank()) {
hashIndexEntry.labelProperty().set(label.label);
}
}
Why this scored 18/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.