From dd2b17fde72a3fda77943859f38995b81f2717a5 Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Sat, 20 Mar 2021 18:22:52 -0300 Subject: [PATCH] Block UI popups in api startup's encrypted wallet init Running the UI's walletPasswordHandler during wallet initialization will fail and block wallet initialization. This change ensures an encrypted wallet does not trigger a walletPasswordHandler.run() if isApiUser=true during startup. --- core/src/main/java/bisq/core/app/WalletAppSetup.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/bisq/core/app/WalletAppSetup.java b/core/src/main/java/bisq/core/app/WalletAppSetup.java index b8967597a6..8f0fd15f1d 100644 --- a/core/src/main/java/bisq/core/app/WalletAppSetup.java +++ b/core/src/main/java/bisq/core/app/WalletAppSetup.java @@ -17,6 +17,7 @@ package bisq.core.app; +import bisq.core.api.CoreContext; import bisq.core.btc.exceptions.InvalidHostException; import bisq.core.btc.exceptions.RejectedTxException; import bisq.core.btc.setup.WalletsSetup; @@ -63,6 +64,7 @@ import javax.annotation.Nullable; @Singleton public class WalletAppSetup { + private final CoreContext coreContext; private final WalletsManager walletsManager; private final WalletsSetup walletsSetup; private final FeeService feeService; @@ -86,11 +88,13 @@ public class WalletAppSetup { private final BooleanProperty useTorForBTC = new SimpleBooleanProperty(); @Inject - public WalletAppSetup(WalletsManager walletsManager, + public WalletAppSetup(CoreContext coreContext, + WalletsManager walletsManager, WalletsSetup walletsSetup, FeeService feeService, Config config, Preferences preferences) { + this.coreContext = coreContext; this.walletsManager = walletsManager; this.walletsSetup = walletsSetup; this.feeService = feeService; @@ -172,10 +176,10 @@ public class WalletAppSetup { walletsSetup.initialize(null, () -> { // We only check one wallet as we apply encryption to all or none - if (walletsManager.areWalletsEncrypted()) { + if (walletsManager.areWalletsEncrypted() && !coreContext.isApiUser()) { walletPasswordHandler.run(); } else { - if (preferences.isResyncSpvRequested()) { + if (preferences.isResyncSpvRequested() && !coreContext.isApiUser()) { if (showFirstPopupIfResyncSPVRequestedHandler != null) showFirstPopupIfResyncSPVRequestedHandler.run(); } else {