freeze and unfreeze the row whose menu was opened from the keyboard when it is not in the selection, and leave spent outputs in a selection unchanged
What changed, and why it matters
This commit fixes a small user-interface bug in the Sparrow bitcoin wallet. When a user opened the right-click menu for a UTXO row using the keyboard (for example, to freeze or spend it), the wallet could apply the action to the wrong set of rows if the focused row was not part of the current selection. It also makes sure already-spent outputs are left alone when freezing or unfreezing a group selection. The change is a usability fix rather than a cryptographic or network security flaw.
Treat as a routine bug-fix / usability improvement. No urgent security response is indicated from the diff alone. If triaging, verify that no other menu actions in the wallet suffer from the same selection-vs-focus mismatch.
Security signals we found
UI action target mismatch fixed
Spent outputs excluded from freeze/unfreeze operations
Context-menu keyboard focus handled explicitly
Evidence from the diff
EntryCell.java is refactored to introduce getMenuUtxoEntries(), which returns the selected HashIndexEntry outputs when the row that triggered the context menu is inside the selection, and otherwise returns only that single row. This is because a context menu opened from the keyboard belongs to the focused row even if that row is not selected. The helper is used by sendSelectedUtxos(), freezeUtxo(), and unfreezeUtxo(). Additionally, freezeUtxo() and unfreezeUtxo() now filter out spent outputs (e -> !e.getHashIndex().isSpent()), so spent outputs in a selection are not modified. sendSelectedUtxos() keeps its existing spendable-only filter. The patch is small and localised.
Changed components
src/main/java/com/sparrowwallet/sparrow/control/EntryCell.javaUTXO context-menu actions (send, freeze, unfreeze)Inspect captured patch +15 / −13
### src/main/java/com/sparrowwallet/sparrow/control/EntryCell.java
@@ -35,6 +35,7 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
+import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -471,28 +472,31 @@ private static boolean containsWalletOutputs(TransactionEntry transactionEntry)
.anyMatch(e -> e.getType().equals(HashIndexEntry.Type.OUTPUT));
}
- private static void sendSelectedUtxos(TreeTableView<Entry> treeTableView, HashIndexEntry hashIndexEntry) {
+ /**
+ * The outputs a row's menu action applies to: the selected outputs where the selection includes that row, and otherwise the row alone, since a
+ * menu opened from the keyboard is for the focused row whether or not it is selected.
+ */
+ private static List<HashIndexEntry> getMenuUtxoEntries(TreeTableView<Entry> treeTableView, HashIndexEntry hashIndexEntry, Predicate<HashIndexEntry> filter) {
List<HashIndexEntry> utxoEntries = treeTableView.getSelectionModel().getSelectedCells().stream()
.map(tp -> tp.getTreeItem().getValue())
.filter(e -> e instanceof HashIndexEntry)
.map(e -> (HashIndexEntry)e)
- .filter(e -> e.getType().equals(HashIndexEntry.Type.OUTPUT) && e.isSpendable())
+ .filter(e -> e.getType().equals(HashIndexEntry.Type.OUTPUT) && filter.test(e))
.collect(Collectors.toList());
- if(!utxoEntries.contains(hashIndexEntry)) {
- utxoEntries = List.of(hashIndexEntry);
- }
+ return utxoEntries.contains(hashIndexEntry) ? utxoEntries : List.of(hashIndexEntry);
+ }
+ private static void sendSelectedUtxos(TreeTableView<Entry> treeTableView, HashIndexEntry hashIndexEntry) {
+ List<HashIndexEntry> utxoEntries = getMenuUtxoEntries(treeTableView, hashIndexEntry, HashIndexEntry::isSpendable);
final List<BlockTransactionHashIndex> spendingUtxos = utxoEntries.stream().map(HashIndexEntry::getHashIndex).collect(Collectors.toList());
EventManager.get().post(new SendActionEvent(hashIndexEntry.getWallet(), spendingUtxos));
Platform.runLater(() -> EventManager.get().post(new SpendUtxoEvent(hashIndexEntry.getWallet(), spendingUtxos)));
}
private static void freezeUtxo(TreeTableView<Entry> treeTableView, HashIndexEntry hashIndexEntry) {
- List<BlockTransactionHashIndex> utxos = treeTableView.getSelectionModel().getSelectedCells().stream()
- .map(tp -> tp.getTreeItem().getValue())
- .filter(e -> e instanceof HashIndexEntry && ((HashIndexEntry)e).getType().equals(HashIndexEntry.Type.OUTPUT))
- .map(e -> ((HashIndexEntry)e).getHashIndex())
+ List<BlockTransactionHashIndex> utxos = getMenuUtxoEntries(treeTableView, hashIndexEntry, e -> !e.getHashIndex().isSpent()).stream()
+ .map(HashIndexEntry::getHashIndex)
.filter(ref -> ref.getStatus() != Status.FROZEN)
.collect(Collectors.toList());
@@ -501,10 +505,8 @@ private static void freezeUtxo(TreeTableView<Entry> treeTableView, HashIndexEntr
}
private static void unfreezeUtxo(TreeTableView<Entry> treeTableView, HashIndexEntry hashIndexEntry) {
- List<BlockTransactionHashIndex> utxos = treeTableView.getSelectionModel().getSelectedCells().stream()
- .map(tp -> tp.getTreeItem().getValue())
- .filter(e -> e instanceof HashIndexEntry && ((HashIndexEntry)e).getType().equals(HashIndexEntry.Type.OUTPUT))
- .map(e -> ((HashIndexEntry)e).getHashIndex())
+ List<BlockTransactionHashIndex> utxos = getMenuUtxoEntries(treeTableView, hashIndexEntry, e -> !e.getHashIndex().isSpent()).stream()
+ .map(HashIndexEntry::getHashIndex)
.filter(ref -> ref.getStatus() == Status.FROZEN)
.collect(Collectors.toList());
Why this scored 24/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.