From c2eb505bd9640e1c78c42ca63fc4273a31891735 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 7 Jul 2022 15:18:19 +0200 Subject: [PATCH] add all whirlpool accounts if any one is discovered on wallet import --- drongo | 2 +- .../java/com/sparrowwallet/sparrow/AppController.java | 4 +++- .../com/sparrowwallet/sparrow/net/ElectrumServer.java | 11 ++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drongo b/drongo index 1a20e038..d05ec39d 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit 1a20e0381c8961d51e5ccef04e3d47d41cec9388 +Subproject commit d05ec39df7d7c8d23f61f39338c467b9507f0aaa diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index 2b825f43..d4f9ca47 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -1014,7 +1014,9 @@ public class AppController implements Initializable { for(Map.Entry entry : walletAndKey.getChildWallets().entrySet()) { openWallet(entry.getValue(), entry.getKey(), walletAppController, true); } - Platform.runLater(() -> selectTab(walletAndKey.getWallet())); + if(walletAndKey.getWallet().isMasterWallet()) { + Platform.runLater(() -> selectTab(walletAndKey.getWallet())); + } } catch(Exception e) { log.error("Error opening wallet", e); showErrorDialog("Error Opening Wallet", e.getMessage()); diff --git a/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java b/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java index 5181a5e4..8cc4f1d2 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/ElectrumServer.java @@ -1587,17 +1587,26 @@ public class ElectrumServer { if(nodeTransactionMap.values().stream().anyMatch(blockTransactionHashes -> !blockTransactionHashes.isEmpty())) { Wallet masterWalletCopy = wallet.copy(); List searchAccounts = getStandardAccounts(wallet); + Set foundAccounts = new LinkedHashSet<>(); for(int j = 0; j < searchAccounts.size(); j++) { StandardAccount standardAccount = searchAccounts.get(j); Wallet childWallet = masterWalletCopy.addChildWallet(standardAccount); Map> childTransactionMap = new TreeMap<>(); electrumServer.getReferences(childWallet, childWallet.getNode(KeyPurpose.RECEIVE).getChildren(), childTransactionMap, 0); if(childTransactionMap.values().stream().anyMatch(blockTransactionHashes -> !blockTransactionHashes.isEmpty())) { - wallet.addChildWallet(standardAccount); + if(StandardAccount.WHIRLPOOL_ACCOUNTS.contains(standardAccount)) { + foundAccounts.addAll(StandardAccount.WHIRLPOOL_ACCOUNTS); + } else { + foundAccounts.add(standardAccount); + } } updateProgress(i + j, wallets.size() + StandardAccount.values().length); } + for(StandardAccount standardAccount : foundAccounts) { + wallet.addChildWallet(standardAccount); + } + return Optional.of(wallet); } }