let the terminal user choose the script type when transactions are found for more than one
What changed, and why it matters
This change improves the Sparrow Wallet terminal (command-line) interface. Previously, if the wallet discovery process found transactions matching more than one Bitcoin script type, it would silently pick the first one. Now it shows a menu so the user can choose which script type to use. This is a usability fix that prevents the wrong wallet type from being selected automatically.
No security action required. Treat as a normal usability/bug-fix patch. Reviewers may want to verify that the dialog cannot be canceled (setCanCancel(false)) and that the fallback path when discovery fails remains unchanged.
Security signals we found
Behavioral fix: prevents silent selection of first discovered wallet script type
User-choice dialog added in terminal wallet creation flow
No cryptographic, network, or input-validation changes observed
Evidence from the diff
In NewWalletDialog.java, the discoverAccounts method previously took the first wallet from the discovered list and saved it. The patch changes this so that when multiple wallets are returned (meaning transactions exist for more than one script type), an ActionListDialogBuilder presents each discovered wallet’s script type description as a selectable action. The user must choose one, and only then is wallet set and saveWallet called. If only one wallet is discovered, behavior is unchanged.
Changed components
src/main/java/com/sparrowwallet/sparrow/terminal/wallet/NewWalletDialog.javaTerminal wallet account discovery flowInspect captured patch +18 / −4
### src/main/java/com/sparrowwallet/sparrow/terminal/wallet/NewWalletDialog.java
@@ -1,6 +1,7 @@
package com.sparrowwallet.sparrow.terminal.wallet;
import com.googlecode.lanterna.gui2.*;
+import com.googlecode.lanterna.gui2.dialogs.ActionListDialogBuilder;
import com.googlecode.lanterna.gui2.dialogs.DialogWindow;
import com.googlecode.lanterna.gui2.dialogs.TextInputDialogBuilder;
import com.sparrowwallet.drongo.SecureString;
@@ -26,7 +27,6 @@
import java.io.IOException;
import java.util.List;
-import java.util.Optional;
import static com.sparrowwallet.sparrow.AppServices.showErrorDialog;
@@ -99,11 +99,25 @@ private void discoverAccounts(List<Wallet> wallets) {
Platform.runLater(() -> {
ElectrumServer.WalletDiscoveryService walletDiscoveryService = new ElectrumServer.WalletDiscoveryService(wallets);
walletDiscoveryService.setOnSucceeded(successEvent -> {
- Optional<List<Wallet>> optWallets = walletDiscoveryService.getValue();
- wallet = optWallets.orElseGet(() -> wallets).getFirst();
+ List<Wallet> discoveredWallets = walletDiscoveryService.getValue().orElseGet(() -> wallets);
SparrowTerminal.get().getGuiThread().invokeLater(() -> {
SparrowTerminal.get().getGui().removeWindow(discoveringDialog);
- saveWallet(wallet);
+ if(discoveredWallets.size() > 1) {
+ ActionListDialogBuilder builder = new ActionListDialogBuilder();
+ builder.setTitle(walletName);
+ builder.setDescription("Transactions were found for more than one script type");
+ builder.setCanCancel(false);
+ for(Wallet discoveredWallet : discoveredWallets) {
+ builder.addAction(discoveredWallet.getScriptType().getDescription(), () -> {
+ wallet = discoveredWallet;
+ saveWallet(wallet);
+ });
+ }
+ builder.build().showDialog(SparrowTerminal.get().getGui());
+ } else {
+ wallet = discoveredWallets.getFirst();
+ saveWallet(wallet);
+ }
});
});
walletDiscoveryService.setOnFailed(failedEvent -> {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.