Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change unconfirmed popup to 24h after trade start. #6994

Merged
merged 1 commit into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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. \
Expand Down
2 changes: 1 addition & 1 deletion desktop/src/main/java/bisq/desktop/main/MainViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ private void setupHandlers() {
});
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()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
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;
Expand All @@ -63,6 +63,9 @@
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;
Expand Down Expand Up @@ -206,6 +209,33 @@ private void onMessageStateChanged(MessageState messageState) {
messageStateProperty.set(messageState);
}

public void checkForTimeoutAtTradeStep1() {
if (trade == null) {
return;
}
// Trade is waiting confirmation. If it has been unconfirmed for too long, prompt the user.
long unconfirmedHours = Duration.between(trade.getDate().toInstant(), Instant.now()).toHours();
if (unconfirmedHours >= 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 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
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;

Expand Down Expand Up @@ -71,9 +70,6 @@
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;
Expand Down Expand Up @@ -739,19 +735,6 @@ private void checkIfLockTimeIsOver() {
}
}

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
///////////////////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected void onPendingTradesInitialized() {
super.onPendingTradesInitialized();
validatePayoutTx();
validateDepositInputs();
checkForTimeout();
model.checkForTimeoutAtTradeStep1();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public SellerStep1View(PendingTradesViewModel model) {
protected void onPendingTradesInitialized() {
super.onPendingTradesInitialized();
validateDepositInputs();
checkForTimeout();
model.checkForTimeoutAtTradeStep1();
}

///////////////////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public void activate() {
}
});

reSyncSPVChainButton.setOnAction(event -> GUIUtil.reSyncSPVChain(preferences));
reSyncSPVChainButton.setOnAction(event -> GUIUtil.reSyncSPVChain());

bitcoinPeersSubscription = EasyBind.subscribe(walletsSetup.connectedPeersProperty(),
connectedPeers -> updateBitcoinPeersTable());
Expand Down
2 changes: 1 addition & 1 deletion desktop/src/main/java/bisq/desktop/util/GUIUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ public static void requestFocus(Node node) {
UserThread.execute(node::requestFocus);
}

public static void reSyncSPVChain(Preferences preferences) {
public static void reSyncSPVChain() {
try {
new Popup().information(Res.get("settings.net.reSyncSPVSuccess"))
.useShutDownButton()
Expand Down