add all whirlpool accounts if any one is discovered on wallet import

This commit is contained in:
Craig Raw
2022-07-07 15:18:19 +02:00
parent 930e36fa2b
commit c2eb505bd9
3 changed files with 14 additions and 3 deletions
@@ -1587,17 +1587,26 @@ public class ElectrumServer {
if(nodeTransactionMap.values().stream().anyMatch(blockTransactionHashes -> !blockTransactionHashes.isEmpty())) {
Wallet masterWalletCopy = wallet.copy();
List<StandardAccount> searchAccounts = getStandardAccounts(wallet);
Set<StandardAccount> foundAccounts = new LinkedHashSet<>();
for(int j = 0; j < searchAccounts.size(); j++) {
StandardAccount standardAccount = searchAccounts.get(j);
Wallet childWallet = masterWalletCopy.addChildWallet(standardAccount);
Map<WalletNode, Set<BlockTransactionHash>> 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);
}
}