diff --git a/drongo b/drongo index cd1e21eb..bd01cb87 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit cd1e21ebaa167823dc7e515f21b4acd640237025 +Subproject commit bd01cb87309bcc4a4739b63a6d7548ca1b25910e diff --git a/src/main/java/com/sparrowwallet/sparrow/AppServices.java b/src/main/java/com/sparrowwallet/sparrow/AppServices.java index 5e8c0552..09cf8a50 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppServices.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppServices.java @@ -27,6 +27,7 @@ import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.concurrent.ScheduledService; +import javafx.concurrent.Service; import javafx.concurrent.Task; import javafx.concurrent.Worker; import javafx.fxml.FXMLLoader; @@ -1062,6 +1063,13 @@ public class AppServices { if(Config.get().getServerType() == ServerType.BITCOIN_CORE) { Platform.runLater(() -> restartBwt(event.getWallet())); } + + //Ensure public key cache is warm + WalletKeyDerivationService walletKeyDerivationService = new WalletKeyDerivationService(event.getWallet()); + walletKeyDerivationService.setOnFailed(workerStateEvent -> { + log.error("Error deriving public keys", workerStateEvent.getSource().getException()); + }); + walletKeyDerivationService.start(); } @Subscribe @@ -1101,4 +1109,22 @@ public class AppServices { onlineProperty.set(true); } } + + private static final class WalletKeyDerivationService extends Service { + private final Wallet wallet; + + public WalletKeyDerivationService(Wallet wallet) { + this.wallet = wallet; + } + + @Override + protected Task createTask() { + return new Task<>() { + protected Boolean call() { + wallet.derivePublicKeys(); + return true; + } + }; + } + } }