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

This commit is contained in:
Craig Raw 2024-04-15 09:55:24 +02:00
parent c9b40b1973
commit 646b8b0e65
2 changed files with 9 additions and 4 deletions

View file

@ -69,8 +69,7 @@ public class AddAccountDialog extends Dialog<List<StandardAccount>> {
}
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);

View file

@ -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 -> {