From af23f063f29c88fabddf2f5482229178a8f12805 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 4 Nov 2021 14:44:38 +0200 Subject: [PATCH] show info dialog when no new accounts are discovered --- .../sparrow/wallet/SettingsController.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsController.java index 94f3b442..27748fb3 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/SettingsController.java @@ -484,6 +484,9 @@ public class SettingsController extends WalletFormController implements Initiali ElectrumServer.WalletDiscoveryService walletDiscoveryService = new ElectrumServer.WalletDiscoveryService(masterWallet, standardAccounts); walletDiscoveryService.setOnSucceeded(event -> { addAndEncryptAccounts(masterWallet, walletDiscoveryService.getValue(), key); + if(walletDiscoveryService.getValue().isEmpty()) { + AppServices.showAlertDialog("No Accounts Found", "No new accounts with existing transactions were found.", Alert.AlertType.INFORMATION, ButtonType.OK); + } }); walletDiscoveryService.setOnFailed(event -> { log.error("Failed to discover accounts", event.getSource().getException()); @@ -514,6 +517,9 @@ public class SettingsController extends WalletFormController implements Initiali ElectrumServer.WalletDiscoveryService walletDiscoveryService = new ElectrumServer.WalletDiscoveryService(masterWallet, standardAccounts); walletDiscoveryService.setOnSucceeded(event -> { addAndSaveAccounts(masterWallet, walletDiscoveryService.getValue()); + if(walletDiscoveryService.getValue().isEmpty()) { + AppServices.showAlertDialog("No Accounts Found", "No new accounts with existing transactions were found.", Alert.AlertType.INFORMATION, ButtonType.OK); + } }); walletDiscoveryService.setOnFailed(event -> { log.error("Failed to discover accounts", event.getSource().getException()); @@ -531,13 +537,17 @@ public class SettingsController extends WalletFormController implements Initiali Optional> optDiscoveredKeystores = deviceKeystoreDiscoverDialog.showAndWait(); if(optDiscoveredKeystores.isPresent()) { Map discoveredKeystores = optDiscoveredKeystores.get(); - for(Map.Entry entry : discoveredKeystores.entrySet()) { - Wallet childWallet = masterWallet.addChildWallet(entry.getKey()); - childWallet.getKeystores().clear(); - childWallet.getKeystores().add(entry.getValue()); - EventManager.get().post(new ChildWalletAddedEvent(getWalletForm().getStorage(), masterWallet, childWallet)); + if(discoveredKeystores.isEmpty()) { + AppServices.showAlertDialog("No Accounts Found", "No new accounts with existing transactions were found.", Alert.AlertType.INFORMATION, ButtonType.OK); + } else { + for(Map.Entry entry : discoveredKeystores.entrySet()) { + Wallet childWallet = masterWallet.addChildWallet(entry.getKey()); + childWallet.getKeystores().clear(); + childWallet.getKeystores().add(entry.getValue()); + EventManager.get().post(new ChildWalletAddedEvent(getWalletForm().getStorage(), masterWallet, childWallet)); + } + saveChildWallets(masterWallet); } - saveChildWallets(masterWallet); } } else { for(StandardAccount standardAccount : standardAccounts) {