From e082a4976093914fb80aea6401754e5b05995183 Mon Sep 17 00:00:00 2001 From: jmacxx <47253594+jmacxx@users.noreply.github.com> Date: Fri, 5 Jan 2024 12:04:11 -0600 Subject: [PATCH] Change unconfirmed popup to 24h after trade start. --- .../resources/i18n/displayStrings.properties | 2 +- .../java/bisq/desktop/main/MainViewModel.java | 2 +- .../pendingtrades/PendingTradesViewModel.java | 32 ++++++++++++++++++- .../pendingtrades/steps/TradeStepView.java | 17 ---------- .../steps/buyer/BuyerStep1View.java | 2 +- .../steps/seller/SellerStep1View.java | 2 +- .../settings/network/NetworkSettingsView.java | 2 +- .../main/java/bisq/desktop/util/GUIUtil.java | 2 +- 8 files changed, 37 insertions(+), 24 deletions(-) diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 2e292d26b7..a4d8fd18d1 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -1564,7 +1564,7 @@ settings.net.peer=Peer settings.net.inbound=inbound settings.net.outbound=outbound settings.net.reSyncSPVChainLabel=Resync SPV chain -settings.net.reSyncSPVChainButton=Delete SPV file and resync +settings.net.reSyncSPVChainButton=Resync SPV wallet settings.net.reSyncSPVSuccess=Are you sure you want to do an SPV resync? If you proceed, the SPV chain file will be deleted on the next startup.\n\n\ After the restart it can take a while to resync with the network and you will only see all transactions once the resync is completed.\n\n\ Depending on the number of transactions and the age of your wallet the resync can take up to a few hours and consumes 100% of CPU. \ diff --git a/desktop/src/main/java/bisq/desktop/main/MainViewModel.java b/desktop/src/main/java/bisq/desktop/main/MainViewModel.java index 10148b873f..3b79982d26 100644 --- a/desktop/src/main/java/bisq/desktop/main/MainViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/MainViewModel.java @@ -387,7 +387,7 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupListener { }); bisqSetup.setSpvFileCorruptedHandler(msg -> new Popup().warning(msg) .actionButtonText(Res.get("settings.net.reSyncSPVChainButton")) - .onAction(() -> GUIUtil.reSyncSPVChain(preferences)) + .onAction(GUIUtil::reSyncSPVChain) .show()); bisqSetup.setVoteResultExceptionHandler(voteResultException -> log.warn(voteResultException.toString())); diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java index 9773bf9d4c..2c7a3a2889 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java @@ -31,12 +31,12 @@ import bisq.core.network.MessageState; import bisq.core.offer.Offer; import bisq.core.offer.OfferUtil; import bisq.core.provider.fee.FeeService; -import bisq.core.provider.mempool.FeeValidationStatus; import bisq.core.provider.mempool.MempoolService; import bisq.core.trade.ClosedTradableManager; import bisq.core.trade.bisq_v1.TradeUtil; import bisq.core.trade.model.bisq_v1.Contract; import bisq.core.trade.model.bisq_v1.Trade; +import bisq.core.user.DontShowAgainLookup; import bisq.core.user.User; import bisq.core.util.FormattingUtils; import bisq.core.util.VolumeUtil; @@ -63,6 +63,9 @@ import javafx.beans.property.ObjectProperty; import javafx.beans.property.ReadOnlyObjectProperty; import javafx.beans.property.SimpleObjectProperty; +import java.time.Duration; +import java.time.Instant; + import java.util.Date; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -206,6 +209,33 @@ public class PendingTradesViewModel extends ActivatableWithDataModel= 24 && !trade.hasFailed()) { + // PR #6994 - only show a warning popup if a block explorer says it has confirmed + mempoolService.checkTxIsConfirmed(trade.getDepositTxId(), (validator -> { + long confirms = validator.parseJsonValidateTx(); + log.info("Mempool lookup of deposit tx returned {} confirms for trade {}", confirms, trade.getShortId()); + if (confirms < 1) { + return; + } + String key = "tradeUnconfirmedTooLong_" + trade.getShortId(); + if (DontShowAgainLookup.showAgain(key)) { + new Popup().warning(Res.get("portfolio.pending.unconfirmedTooLong", trade.getShortId(), unconfirmedHours)) + .dontShowAgainId(key) + .actionButtonText(Res.get("settings.net.reSyncSPVChainButton")) + .closeButtonText(Res.get("shared.ok")) + .onAction(GUIUtil::reSyncSPVChain) + .show(); + } + })); + } + } + public void checkTakerFeeTx(Trade trade) { UserThread.runAfter(() -> { mempoolService.validateOfferTakerTx(trade, (txValidator -> { diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/TradeStepView.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/TradeStepView.java index b86ace6c20..89522e5cbc 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/TradeStepView.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/TradeStepView.java @@ -34,7 +34,6 @@ import bisq.core.support.dispute.DisputeResult; import bisq.core.support.dispute.mediation.MediationResultState; import bisq.core.trade.model.bisq_v1.Contract; import bisq.core.trade.model.bisq_v1.Trade; -import bisq.core.user.DontShowAgainLookup; import bisq.core.user.Preferences; import bisq.core.util.FormattingUtils; @@ -71,9 +70,6 @@ import org.fxmisc.easybind.Subscription; import javafx.beans.property.BooleanProperty; import javafx.beans.value.ChangeListener; -import java.time.Duration; -import java.time.Instant; - import java.util.Optional; import org.slf4j.Logger; @@ -739,19 +735,6 @@ public abstract class TradeStepView extends AnchorPane { } } - protected void checkForTimeout() { - long unconfirmedHours = Duration.between(trade.getDate().toInstant(), Instant.now()).toHours(); - if (unconfirmedHours >= 3 && !trade.hasFailed()) { - String key = "tradeUnconfirmedTooLong_" + trade.getShortId(); - if (DontShowAgainLookup.showAgain(key)) { - new Popup().warning(Res.get("portfolio.pending.unconfirmedTooLong", trade.getShortId(), unconfirmedHours)) - .dontShowAgainId(key) - .closeButtonText(Res.get("shared.ok")) - .show(); - } - } - } - /////////////////////////////////////////////////////////////////////////////////////////// // TradeDurationLimitInfo /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep1View.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep1View.java index de6c6ec8e2..f0a22e2fe3 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep1View.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep1View.java @@ -40,7 +40,7 @@ public class BuyerStep1View extends TradeStepView { super.onPendingTradesInitialized(); validatePayoutTx(); validateDepositInputs(); - checkForTimeout(); + model.checkForTimeoutAtTradeStep1(); } diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/seller/SellerStep1View.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/seller/SellerStep1View.java index 9696afdf30..a85fbc5730 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/seller/SellerStep1View.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/seller/SellerStep1View.java @@ -38,7 +38,7 @@ public class SellerStep1View extends TradeStepView { protected void onPendingTradesInitialized() { super.onPendingTradesInitialized(); validateDepositInputs(); - checkForTimeout(); + model.checkForTimeoutAtTradeStep1(); } /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/desktop/src/main/java/bisq/desktop/main/settings/network/NetworkSettingsView.java b/desktop/src/main/java/bisq/desktop/main/settings/network/NetworkSettingsView.java index 19071fb841..ae5712352b 100644 --- a/desktop/src/main/java/bisq/desktop/main/settings/network/NetworkSettingsView.java +++ b/desktop/src/main/java/bisq/desktop/main/settings/network/NetworkSettingsView.java @@ -293,7 +293,7 @@ public class NetworkSettingsView extends ActivatableView { } }); - reSyncSPVChainButton.setOnAction(event -> GUIUtil.reSyncSPVChain(preferences)); + reSyncSPVChainButton.setOnAction(event -> GUIUtil.reSyncSPVChain()); bitcoinPeersSubscription = EasyBind.subscribe(walletsSetup.connectedPeersProperty(), connectedPeers -> updateBitcoinPeersTable()); diff --git a/desktop/src/main/java/bisq/desktop/util/GUIUtil.java b/desktop/src/main/java/bisq/desktop/util/GUIUtil.java index 4d9678dee8..1d2f5b77b5 100644 --- a/desktop/src/main/java/bisq/desktop/util/GUIUtil.java +++ b/desktop/src/main/java/bisq/desktop/util/GUIUtil.java @@ -887,7 +887,7 @@ public class GUIUtil { UserThread.execute(node::requestFocus); } - public static void reSyncSPVChain(Preferences preferences) { + public static void reSyncSPVChain() { try { new Popup().information(Res.get("settings.net.reSyncSPVSuccess")) .useShutDownButton()