diff --git a/core/src/main/java/bisq/core/app/BisqHeadlessApp.java b/core/src/main/java/bisq/core/app/BisqHeadlessApp.java index 2d470403c3..80c908ab00 100644 --- a/core/src/main/java/bisq/core/app/BisqHeadlessApp.java +++ b/core/src/main/java/bisq/core/app/BisqHeadlessApp.java @@ -79,6 +79,7 @@ public class BisqHeadlessApp implements HeadlessApp { bisqSetup.setSpvFileCorruptedHandler(msg -> log.error("onSpvFileCorruptedHandler: msg={}", msg)); bisqSetup.setChainFileLockedExceptionHandler(msg -> log.error("onChainFileLockedExceptionHandler: msg={}", msg)); bisqSetup.setDiskSpaceWarningHandler(msg -> log.error("onDiskSpaceWarningHandler: msg={}", msg)); + bisqSetup.setChainNotSyncedHandler(msg -> log.error("onChainNotSyncedHandler: msg={}", msg)); bisqSetup.setLockedUpFundsHandler(msg -> log.info("onLockedUpFundsHandler: msg={}", msg)); bisqSetup.setShowFirstPopupIfResyncSPVRequestedHandler(() -> log.info("onShowFirstPopupIfResyncSPVRequestedHandler")); bisqSetup.setRequestWalletPasswordHandler(aesKeyHandler -> log.info("onRequestWalletPasswordHandler")); diff --git a/core/src/main/java/bisq/core/app/BisqSetup.java b/core/src/main/java/bisq/core/app/BisqSetup.java index 2b6ba038d5..11eaf06007 100644 --- a/core/src/main/java/bisq/core/app/BisqSetup.java +++ b/core/src/main/java/bisq/core/app/BisqSetup.java @@ -164,7 +164,7 @@ public class BisqSetup { filterWarningHandler, displaySecurityRecommendationHandler, displayLocalhostHandler, wrongOSArchitectureHandler, displaySignedByArbitratorHandler, displaySignedByPeerHandler, displayPeerLimitLiftedHandler, displayPeerSignerHandler, - rejectedTxErrorMessageHandler, diskSpaceWarningHandler; + rejectedTxErrorMessageHandler, diskSpaceWarningHandler, chainNotSyncedHandler; @Setter @Nullable private Consumer displayTorNetworkSettingsHandler; @@ -481,6 +481,7 @@ public class BisqSetup { daoErrorMessageHandler, daoWarnMessageHandler, filterWarningHandler, + chainNotSyncedHandler, voteResultExceptionHandler, revolutAccountsUpdateHandler, amazonGiftCardAccountsUpdateHandler, diff --git a/core/src/main/java/bisq/core/app/DomainInitialisation.java b/core/src/main/java/bisq/core/app/DomainInitialisation.java index ec96c217ff..cb19c89d39 100644 --- a/core/src/main/java/bisq/core/app/DomainInitialisation.java +++ b/core/src/main/java/bisq/core/app/DomainInitialisation.java @@ -204,6 +204,7 @@ public class DomainInitialisation { Consumer daoErrorMessageHandler, Consumer daoWarnMessageHandler, Consumer filterWarningHandler, + Consumer chainNotSyncedHandler, Consumer voteResultExceptionHandler, Consumer> revolutAccountsUpdateHandler, Consumer> amazonGiftCardAccountsUpdateHandler, @@ -225,6 +226,7 @@ public class DomainInitialisation { failedTradesManager.onAllServicesInitialized(); xmrTxProofService.onAllServicesInitialized(); + openOfferManager.setChainNotSyncedHandler(chainNotSyncedHandler); openOfferManager.onAllServicesInitialized(); openBsqSwapOfferService.onAllServicesInitialized(); diff --git a/core/src/main/java/bisq/core/offer/OpenOfferManager.java b/core/src/main/java/bisq/core/offer/OpenOfferManager.java index 06a85ae6ab..2e6ac72488 100644 --- a/core/src/main/java/bisq/core/offer/OpenOfferManager.java +++ b/core/src/main/java/bisq/core/offer/OpenOfferManager.java @@ -89,9 +89,11 @@ import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; import java.util.stream.Collectors; import lombok.Getter; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; import javax.annotation.Nullable; @@ -133,6 +135,8 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe private final TradableList openOffers = new TradableList<>(); private boolean stopped; private Timer periodicRepublishOffersTimer, periodicRefreshOffersTimer, retryRepublishOffersTimer; + @Setter + private Consumer chainNotSyncedHandler; @Getter private final ObservableList> invalidOffers = FXCollections.observableArrayList(); @@ -653,6 +657,20 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe errorMessage = "We got a handleOfferAvailabilityRequest but our chain is not synced."; log.info(errorMessage); sendAckMessage(request, peer, false, errorMessage); + if (chainNotSyncedHandler != null) { + chainNotSyncedHandler.accept(Res.get("popup.warning.chainNotSynced")); + } + return; + } + + // Don't allow trade start if DAO is not fully synced + if (!daoFacade.isDaoStateReadyAndInSync()) { + errorMessage = "We got a handleOfferAvailabilityRequest but our DAO is not synced."; + log.info(errorMessage); + sendAckMessage(request, peer, false, errorMessage); + if (chainNotSyncedHandler != null) { + chainNotSyncedHandler.accept(Res.get("popup.warning.daoNeedsResync")); + } return; } diff --git a/desktop/src/main/java/bisq/desktop/main/MainViewModel.java b/desktop/src/main/java/bisq/desktop/main/MainViewModel.java index cf96b23d68..097f0e1e5e 100644 --- a/desktop/src/main/java/bisq/desktop/main/MainViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/MainViewModel.java @@ -399,7 +399,11 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupListener { new Popup().warning(msg).show(); } }); - + bisqSetup.setChainNotSyncedHandler(msg -> { + if (PopupManager.isNoPopupDisplayed()) { + new Popup().warning(msg).show(); + } + }); bisqSetup.setLockedUpFundsHandler(msg -> { // repeated popups of the same message text can be stopped by selecting the "Dont show again" checkbox String key = Hex.encode(Hash.getSha256Ripemd160hash(msg.getBytes(Charsets.UTF_8)));