Merge pull request #6994 from jmacxx/resync_popup_change

Change unconfirmed popup to 24h after trade start.
This commit is contained in:
Alejandro García 2024-01-14 11:48:08 +00:00 committed by GitHub
commit f755efa765
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 37 additions and 24 deletions

View File

@ -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. \

View File

@ -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()));

View File

@ -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<PendingTrad
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 -> {

View File

@ -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
///////////////////////////////////////////////////////////////////////////////////////////

View File

@ -40,7 +40,7 @@ public class BuyerStep1View extends TradeStepView {
super.onPendingTradesInitialized();
validatePayoutTx();
validateDepositInputs();
checkForTimeout();
model.checkForTimeoutAtTradeStep1();
}

View File

@ -38,7 +38,7 @@ public class SellerStep1View extends TradeStepView {
protected void onPendingTradesInitialized() {
super.onPendingTradesInitialized();
validateDepositInputs();
checkForTimeout();
model.checkForTimeoutAtTradeStep1();
}
///////////////////////////////////////////////////////////////////////////////////////////

View File

@ -293,7 +293,7 @@ public class NetworkSettingsView extends ActivatableView<GridPane, Void> {
}
});
reSyncSPVChainButton.setOnAction(event -> GUIUtil.reSyncSPVChain(preferences));
reSyncSPVChainButton.setOnAction(event -> GUIUtil.reSyncSPVChain());
bitcoinPeersSubscription = EasyBind.subscribe(walletsSetup.connectedPeersProperty(),
connectedPeers -> updateBitcoinPeersTable());

View File

@ -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()