From 646b8b0e6516f3d92b59146d0872f8ea20736f03 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 15 Apr 2024 09:55:24 +0200 Subject: [PATCH] show discover button when adding accounts on a bitcoin core connection, but warn user account discovery is not generally supported if no accounts are found --- .../sparrow/control/AddAccountDialog.java | 3 +-- .../sparrow/wallet/SettingsController.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/control/AddAccountDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/AddAccountDialog.java index 82349787..94b622eb 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/AddAccountDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/AddAccountDialog.java @@ -69,8 +69,7 @@ public class AddAccountDialog extends Dialog> { } final ButtonType discoverButtonType = new javafx.scene.control.ButtonType("Discover", ButtonBar.ButtonData.LEFT); - if(!availableAccounts.isEmpty() && Config.get().getServerType() != ServerType.BITCOIN_CORE && - (masterWallet.getKeystores().stream().allMatch(ks -> ks.getSource() == KeystoreSource.SW_SEED) + if(!availableAccounts.isEmpty() && (masterWallet.getKeystores().stream().allMatch(ks -> ks.getSource() == KeystoreSource.SW_SEED) || (masterWallet.getKeystores().size() == 1 && masterWallet.getKeystores().stream().allMatch(ks -> ks.getSource() == KeystoreSource.HW_USB)))) { dialogPane.getButtonTypes().add(discoverButtonType); Button discoverButton = (Button)dialogPane.lookupButton(discoverButtonType); diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsController.java index 25ab404c..b8064997 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsController.java @@ -15,9 +15,11 @@ import com.sparrowwallet.sparrow.AppServices; import com.sparrowwallet.sparrow.EventManager; import com.sparrowwallet.sparrow.control.*; import com.sparrowwallet.sparrow.event.*; +import com.sparrowwallet.sparrow.io.Config; import com.sparrowwallet.sparrow.io.Storage; import com.sparrowwallet.sparrow.io.StorageException; import com.sparrowwallet.sparrow.net.ElectrumServer; +import com.sparrowwallet.sparrow.net.ServerType; import com.sparrowwallet.sparrow.whirlpool.WhirlpoolServices; import javafx.application.Platform; import javafx.beans.property.SimpleIntegerProperty; @@ -629,7 +631,9 @@ public class SettingsController extends WalletFormController implements Initiali accountDiscoveryService.setOnSucceeded(event -> { addAndEncryptAccounts(masterWallet, accountDiscoveryService.getValue(), key); if(accountDiscoveryService.getValue().isEmpty()) { - AppServices.showAlertDialog("No Accounts Found", "No new accounts with existing transactions were found. Note only the first 10 accounts are scanned.", Alert.AlertType.INFORMATION, ButtonType.OK); + AppServices.showAlertDialog("No Accounts Found", "No new accounts with existing transactions were found. " + + (Config.get().getServerType() == ServerType.BITCOIN_CORE ? "Note the configured server type is Bitcoin Core, which does not support account discovery." : "Note only the next 10 accounts are scanned."), + Alert.AlertType.INFORMATION, ButtonType.OK); } }); accountDiscoveryService.setOnFailed(event -> { @@ -667,7 +671,9 @@ public class SettingsController extends WalletFormController implements Initiali accountDiscoveryService.setOnSucceeded(event -> { addAndSaveAccounts(masterWallet, accountDiscoveryService.getValue(), null); if(accountDiscoveryService.getValue().isEmpty()) { - AppServices.showAlertDialog("No Accounts Found", "No new accounts with existing transactions were found. Note only the first 10 accounts are scanned.", Alert.AlertType.INFORMATION, ButtonType.OK); + AppServices.showAlertDialog("No Accounts Found", "No new accounts with existing transactions were found. " + + (Config.get().getServerType() == ServerType.BITCOIN_CORE ? "Note the configured server type is Bitcoin Core, which does not support account discovery." : "Note only the next 10 accounts are scanned."), + Alert.AlertType.INFORMATION, ButtonType.OK); } }); accountDiscoveryService.setOnFailed(event -> {