diff --git a/core/src/main/java/haveno/core/api/XmrConnectionService.java b/core/src/main/java/haveno/core/api/XmrConnectionService.java index 579dfd4c..a837f79f 100644 --- a/core/src/main/java/haveno/core/api/XmrConnectionService.java +++ b/core/src/main/java/haveno/core/api/XmrConnectionService.java @@ -48,6 +48,8 @@ import javafx.beans.property.ReadOnlyObjectProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleLongProperty; import javafx.beans.property.SimpleObjectProperty; +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import monero.common.MoneroConnectionManager; @@ -84,6 +86,8 @@ public final class XmrConnectionService { private final IntegerProperty numPeers = new SimpleIntegerProperty(0); private final LongProperty chainHeight = new SimpleLongProperty(0); private final DownloadListener downloadListener = new DownloadListener(); + @Getter + private final StringProperty connectionServiceErrorMsg = new SimpleStringProperty(); private final LongProperty numUpdates = new SimpleLongProperty(0); private Socks5ProxyProvider socks5ProxyProvider; @@ -652,6 +656,9 @@ public final class XmrConnectionService { log.info("Successfully fetched daemon info after previous error"); lastErrorTimestamp = null; } + + // clear error message + getConnectionServiceErrorMsg().set(null); } catch (Exception e) { // not connected to daemon @@ -668,7 +675,7 @@ public final class XmrConnectionService { } // set error message - if (HavenoUtils.havenoSetup != null) HavenoUtils.havenoSetup.getWalletServiceErrorMsg().set(e.getMessage()); + getConnectionServiceErrorMsg().set(e.getMessage()); } finally { pollInProgress = false; } diff --git a/core/src/main/java/haveno/core/app/HavenoSetup.java b/core/src/main/java/haveno/core/app/HavenoSetup.java index 799d688c..b6ecf5b7 100644 --- a/core/src/main/java/haveno/core/app/HavenoSetup.java +++ b/core/src/main/java/haveno/core/app/HavenoSetup.java @@ -53,6 +53,7 @@ import haveno.core.alert.Alert; import haveno.core.alert.AlertManager; import haveno.core.alert.PrivateNotificationManager; import haveno.core.alert.PrivateNotificationPayload; +import haveno.core.api.XmrConnectionService; import haveno.core.api.XmrLocalNode; import haveno.core.locale.Res; import haveno.core.offer.OpenOfferManager; @@ -72,7 +73,6 @@ import haveno.core.user.User; import haveno.core.util.FormattingUtils; import haveno.core.util.coin.CoinFormatter; import haveno.core.xmr.setup.WalletsSetup; -import haveno.core.xmr.wallet.BtcWalletService; import haveno.core.xmr.wallet.WalletsManager; import haveno.core.xmr.wallet.XmrWalletService; import haveno.network.Socks5ProxyProvider; @@ -120,7 +120,7 @@ public class HavenoSetup { private final WalletAppSetup walletAppSetup; private final WalletsManager walletsManager; private final WalletsSetup walletsSetup; - private final BtcWalletService btcWalletService; + private final XmrConnectionService xmrConnectionService; @Getter private final XmrWalletService xmrWalletService; private final P2PService p2PService; @@ -217,8 +217,8 @@ public class HavenoSetup { WalletAppSetup walletAppSetup, WalletsManager walletsManager, WalletsSetup walletsSetup, + XmrConnectionService xmrConnectionService, XmrWalletService xmrWalletService, - BtcWalletService btcWalletService, P2PService p2PService, PrivateNotificationManager privateNotificationManager, SignedWitnessStorageService signedWitnessStorageService, @@ -242,8 +242,8 @@ public class HavenoSetup { this.walletAppSetup = walletAppSetup; this.walletsManager = walletsManager; this.walletsSetup = walletsSetup; + this.xmrConnectionService = xmrConnectionService; this.xmrWalletService = xmrWalletService; - this.btcWalletService = btcWalletService; this.p2PService = p2PService; this.privateNotificationManager = privateNotificationManager; this.signedWitnessStorageService = signedWitnessStorageService; @@ -715,8 +715,8 @@ public class HavenoSetup { return walletAppSetup.getXmrWalletSyncProgress(); } - public StringProperty getWalletServiceErrorMsg() { - return walletAppSetup.getWalletServiceErrorMsg(); + public StringProperty getConnectionServiceErrorMsg() { + return xmrConnectionService.getConnectionServiceErrorMsg(); } public StringProperty getTopErrorMsg() { diff --git a/core/src/main/java/haveno/core/app/WalletAppSetup.java b/core/src/main/java/haveno/core/app/WalletAppSetup.java index 0a676402..a55e35d8 100644 --- a/core/src/main/java/haveno/core/app/WalletAppSetup.java +++ b/core/src/main/java/haveno/core/app/WalletAppSetup.java @@ -89,8 +89,6 @@ public class WalletAppSetup { @Getter private final DoubleProperty xmrWalletSyncProgress = new SimpleDoubleProperty(-1); @Getter - private final StringProperty walletServiceErrorMsg = new SimpleStringProperty(); - @Getter private final StringProperty xmrSplashSyncIconId = new SimpleStringProperty(); @Getter private final StringProperty xmrInfo = new SimpleStringProperty(Res.get("mainView.footer.xmrInfo.initializing")); @@ -130,7 +128,7 @@ public class WalletAppSetup { xmrWalletService.downloadPercentageProperty(), xmrWalletService.walletHeightProperty(), walletServiceException, - getWalletServiceErrorMsg(), + xmrConnectionService.getConnectionServiceErrorMsg(), (numConnectionUpdates, walletDownloadPercentage, walletHeight, exception, errorMsg) -> { String result; if (exception == null && errorMsg == null) { @@ -177,16 +175,16 @@ public class WalletAppSetup { getXmrDaemonNetworkAsString()); if (exception != null) { if (exception instanceof TimeoutException) { - getWalletServiceErrorMsg().set(Res.get("mainView.walletServiceErrorMsg.timeout")); + xmrConnectionService.getConnectionServiceErrorMsg().set(Res.get("mainView.walletServiceErrorMsg.timeout")); } else if (exception.getCause() instanceof BlockStoreException) { if (exception.getCause().getCause() instanceof ChainFileLockedException && chainFileLockedExceptionHandler != null) { chainFileLockedExceptionHandler.accept(Res.get("popup.warning.startupFailed.twoInstances")); } } else if (exception instanceof RejectedTxException) { rejectedTxException.set((RejectedTxException) exception); - getWalletServiceErrorMsg().set(Res.get("mainView.walletServiceErrorMsg.rejectedTxException", exception.getMessage())); + xmrConnectionService.getConnectionServiceErrorMsg().set(Res.get("mainView.walletServiceErrorMsg.rejectedTxException", exception.getMessage())); } else { - getWalletServiceErrorMsg().set(Res.get("mainView.walletServiceErrorMsg.connectionError", exception.getMessage())); + xmrConnectionService.getConnectionServiceErrorMsg().set(Res.get("mainView.walletServiceErrorMsg.connectionError", exception.getMessage())); } } } diff --git a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java index 78f1b52f..d10b270e 100644 --- a/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java +++ b/core/src/main/java/haveno/core/xmr/wallet/XmrWalletService.java @@ -1321,7 +1321,7 @@ public class XmrWalletService { } catch (Exception e) { log.warn("Error initializing main wallet: " + e.getMessage()); e.printStackTrace(); - HavenoUtils.havenoSetup.getWalletServiceErrorMsg().set(e.getMessage()); + HavenoUtils.havenoSetup.getTopErrorMsg().set(e.getMessage()); throw e; } } diff --git a/desktop/src/main/java/haveno/desktop/main/MainView.java b/desktop/src/main/java/haveno/desktop/main/MainView.java index 1b681f72..830c8517 100644 --- a/desktop/src/main/java/haveno/desktop/main/MainView.java +++ b/desktop/src/main/java/haveno/desktop/main/MainView.java @@ -516,7 +516,7 @@ public class MainView extends InitializableView { xmrSplashInfo.setId("splash-error-state-msg"); xmrSplashInfo.getStyleClass().add("error-text"); }; - model.getWalletServiceErrorMsg().addListener(walletServiceErrorMsgListener); + model.getConnectionServiceErrorMsg().addListener(walletServiceErrorMsgListener); xmrSyncIndicator = new ProgressBar(); xmrSyncIndicator.setPrefWidth(305); @@ -625,7 +625,7 @@ public class MainView extends InitializableView { } private void disposeSplashScreen() { - model.getWalletServiceErrorMsg().removeListener(walletServiceErrorMsgListener); + model.getConnectionServiceErrorMsg().removeListener(walletServiceErrorMsgListener); model.getXmrSplashSyncIconId().removeListener(xmrSyncIconIdListener); model.getP2pNetworkWarnMsg().removeListener(splashP2PNetworkErrorMsgListener); @@ -663,7 +663,7 @@ public class MainView extends InitializableView { //blockchainSyncIndicator.setMaxHeight(10); //blockchainSyncIndicator.progressProperty().bind(model.getCombinedSyncProgress()); - model.getWalletServiceErrorMsg().addListener((ov, oldValue, newValue) -> { + model.getConnectionServiceErrorMsg().addListener((ov, oldValue, newValue) -> { if (newValue != null) { xmrInfoLabel.setId("splash-error-state-msg"); xmrInfoLabel.getStyleClass().add("error-text"); diff --git a/desktop/src/main/java/haveno/desktop/main/MainViewModel.java b/desktop/src/main/java/haveno/desktop/main/MainViewModel.java index f2a7ab13..57af4400 100644 --- a/desktop/src/main/java/haveno/desktop/main/MainViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/MainViewModel.java @@ -637,8 +637,8 @@ public class MainViewModel implements ViewModel, HavenoSetup.HavenoSetupListener return combinedSyncProgress; } - StringProperty getWalletServiceErrorMsg() { - return havenoSetup.getWalletServiceErrorMsg(); + StringProperty getConnectionServiceErrorMsg() { + return havenoSetup.getConnectionServiceErrorMsg(); } StringProperty getTopErrorMsg() {