From ab7fe6673ec2378d68ed532b60fae48cf1f26bcf Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Wed, 9 Jun 2021 11:32:57 +0200 Subject: [PATCH 1/9] Only allow dispute to be reopened if local node address matches contract node address --- .../resources/i18n/displayStrings.properties | 1 + .../main/support/dispute/DisputeView.java | 27 ++++++++++++++++--- .../dispute/agent/DisputeAgentView.java | 5 +++- .../agent/arbitration/ArbitratorView.java | 4 +++ .../dispute/agent/mediation/MediatorView.java | 4 +++ .../dispute/agent/refund/RefundAgentView.java | 4 +++ .../dispute/client/DisputeClientView.java | 9 ++++--- .../arbitration/ArbitrationClientView.java | 5 +++- .../client/mediation/MediationClientView.java | 4 ++- .../client/refund/RefundClientView.java | 4 ++- 10 files changed, 56 insertions(+), 11 deletions(-) diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index bdf67008e7b..fc9ff5b3417 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -1111,6 +1111,7 @@ support.sigCheck.popup.failed=Signature verification failed support.sigCheck.popup.invalidFormat=Message is not of expected format. Copy & paste summary message from dispute. support.reOpenByTrader.prompt=Are you sure you want to re-open the dispute? +support.reOpenByTrader.failed=Failed to re-open the dispute. support.reOpenButton.label=Re-open support.sendNotificationButton.label=Private notification support.reportButton.label=Report diff --git a/desktop/src/main/java/bisq/desktop/main/support/dispute/DisputeView.java b/desktop/src/main/java/bisq/desktop/main/support/dispute/DisputeView.java index 47c1f735e65..e7bd3a8baf3 100644 --- a/desktop/src/main/java/bisq/desktop/main/support/dispute/DisputeView.java +++ b/desktop/src/main/java/bisq/desktop/main/support/dispute/DisputeView.java @@ -57,6 +57,7 @@ import bisq.core.util.coin.CoinFormatter; import bisq.network.p2p.NodeAddress; +import bisq.network.p2p.P2PService; import bisq.common.UserThread; import bisq.common.crypto.KeyRing; @@ -108,6 +109,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; @@ -149,6 +151,7 @@ public enum FilterResult { protected final DisputeManager> disputeManager; protected final KeyRing keyRing; + private final P2PService p2PService; private final TradeManager tradeManager; protected final CoinFormatter formatter; protected final Preferences preferences; @@ -192,6 +195,7 @@ public enum FilterResult { public DisputeView(DisputeManager> disputeManager, KeyRing keyRing, + P2PService p2PService, TradeManager tradeManager, CoinFormatter formatter, Preferences preferences, @@ -206,6 +210,7 @@ public DisputeView(DisputeManager> disputeManager boolean useDevPrivilegeKeys) { this.disputeManager = disputeManager; this.keyRing = keyRing; + this.p2PService = p2PService; this.tradeManager = tradeManager; this.formatter = formatter; this.preferences = preferences; @@ -495,8 +500,9 @@ protected FilterResult getFilterResult(Dispute dispute, String filterTerm) { // a derived version in the ClientView for users pops up an "Are you sure" box first. // this version includes the sending of an automatic message to the user, see addMediationReOpenedMessage protected void reOpenDisputeFromButton() { - reOpenDispute(); - disputeManager.addMediationReOpenedMessage(selectedDispute, false); + if (reOpenDispute()) { + disputeManager.addMediationReOpenedMessage(selectedDispute, false); + } } // only applicable to traders @@ -517,15 +523,28 @@ protected void handleOnProcessDispute(Dispute dispute) { // overridden by clients that use it (dispute agents) } - protected void reOpenDispute() { - if (selectedDispute != null && selectedDispute.isClosed()) { + protected boolean reOpenDispute() { + if (selectedDispute != null && + selectedDispute.isClosed() && + isDisputeWithSameCurrentNodeAddress(selectedDispute, + !disputeManager.isTrader(selectedDispute))) { selectedDispute.reOpen(); handleOnProcessDispute(selectedDispute); disputeManager.requestPersistence(); onSelectDispute(selectedDispute); + return true; + } else { + new Popup().warning(Res.get("support.reOpenByTrader.failed")).show(); + return false; } } + private boolean isDisputeWithSameCurrentNodeAddress(Dispute dispute, boolean isMediator) { + NodeAddress disputeNodeAddress = isMediator ? dispute.getContract().getMediatorNodeAddress() : + dispute.getContract().getMyNodeAddress(keyRing.getPubKeyRing()); + return Objects.equals(p2PService.getNetworkNode().getNodeAddress(), disputeNodeAddress); + } + /////////////////////////////////////////////////////////////////////////////////////////// // UI actions diff --git a/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/DisputeAgentView.java b/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/DisputeAgentView.java index 8e437943d82..fefab886353 100644 --- a/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/DisputeAgentView.java +++ b/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/DisputeAgentView.java @@ -40,6 +40,8 @@ import bisq.core.user.Preferences; import bisq.core.util.coin.CoinFormatter; +import bisq.network.p2p.P2PService; + import bisq.common.crypto.KeyRing; import bisq.common.util.Utilities; @@ -72,7 +74,7 @@ public abstract class DisputeAgentView extends DisputeView implements MultipleHo public DisputeAgentView(DisputeManager> disputeManager, KeyRing keyRing, - TradeManager tradeManager, + P2PService p2PService, TradeManager tradeManager, CoinFormatter formatter, Preferences preferences, DisputeSummaryWindow disputeSummaryWindow, @@ -86,6 +88,7 @@ public DisputeAgentView(DisputeManager> disputeMa boolean useDevPrivilegeKeys) { super(disputeManager, keyRing, + p2PService, tradeManager, formatter, preferences, diff --git a/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/arbitration/ArbitratorView.java b/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/arbitration/ArbitratorView.java index 08b169734a4..ac58797a737 100644 --- a/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/arbitration/ArbitratorView.java +++ b/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/arbitration/ArbitratorView.java @@ -40,6 +40,8 @@ import bisq.core.util.FormattingUtils; import bisq.core.util.coin.CoinFormatter; +import bisq.network.p2p.P2PService; + import bisq.common.config.Config; import bisq.common.crypto.KeyRing; @@ -52,6 +54,7 @@ public class ArbitratorView extends DisputeAgentView { @Inject public ArbitratorView(ArbitrationManager arbitrationManager, KeyRing keyRing, + P2PService p2PService, TradeManager tradeManager, @Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter, Preferences preferences, @@ -66,6 +69,7 @@ public ArbitratorView(ArbitrationManager arbitrationManager, @Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys) { super(arbitrationManager, keyRing, + p2PService, tradeManager, formatter, preferences, diff --git a/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/mediation/MediatorView.java b/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/mediation/MediatorView.java index 95723a1a743..9892ee7d73e 100644 --- a/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/mediation/MediatorView.java +++ b/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/mediation/MediatorView.java @@ -38,6 +38,8 @@ import bisq.core.util.FormattingUtils; import bisq.core.util.coin.CoinFormatter; +import bisq.network.p2p.P2PService; + import bisq.common.config.Config; import bisq.common.crypto.KeyRing; @@ -50,6 +52,7 @@ public class MediatorView extends DisputeAgentView { @Inject public MediatorView(MediationManager mediationManager, KeyRing keyRing, + P2PService p2PService, TradeManager tradeManager, @Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter, Preferences preferences, @@ -64,6 +67,7 @@ public MediatorView(MediationManager mediationManager, @Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys) { super(mediationManager, keyRing, + p2PService, tradeManager, formatter, preferences, diff --git a/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/refund/RefundAgentView.java b/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/refund/RefundAgentView.java index ca17b18526f..6aa4415d1e0 100644 --- a/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/refund/RefundAgentView.java +++ b/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/refund/RefundAgentView.java @@ -40,6 +40,8 @@ import bisq.core.util.FormattingUtils; import bisq.core.util.coin.CoinFormatter; +import bisq.network.p2p.P2PService; + import bisq.common.config.Config; import bisq.common.crypto.KeyRing; @@ -52,6 +54,7 @@ public class RefundAgentView extends DisputeAgentView { @Inject public RefundAgentView(RefundManager refundManager, KeyRing keyRing, + P2PService p2PService, TradeManager tradeManager, @Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter, Preferences preferences, @@ -66,6 +69,7 @@ public RefundAgentView(RefundManager refundManager, @Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys) { super(refundManager, keyRing, + p2PService, tradeManager, formatter, preferences, diff --git a/desktop/src/main/java/bisq/desktop/main/support/dispute/client/DisputeClientView.java b/desktop/src/main/java/bisq/desktop/main/support/dispute/client/DisputeClientView.java index f2539daa6bd..44cca809fe9 100644 --- a/desktop/src/main/java/bisq/desktop/main/support/dispute/client/DisputeClientView.java +++ b/desktop/src/main/java/bisq/desktop/main/support/dispute/client/DisputeClientView.java @@ -34,11 +34,14 @@ import bisq.core.user.Preferences; import bisq.core.util.coin.CoinFormatter; +import bisq.network.p2p.P2PService; + import bisq.common.crypto.KeyRing; public abstract class DisputeClientView extends DisputeView { public DisputeClientView(DisputeManager> DisputeManager, KeyRing keyRing, + P2PService p2PService, TradeManager tradeManager, CoinFormatter formatter, Preferences preferences, @@ -51,9 +54,9 @@ public DisputeClientView(DisputeManager> DisputeM RefundAgentManager refundAgentManager, DaoFacade daoFacade, boolean useDevPrivilegeKeys) { - super(DisputeManager, keyRing, tradeManager, formatter, preferences, disputeSummaryWindow, privateNotificationManager, - contractWindow, tradeDetailsWindow, accountAgeWitnessService, - mediatorManager, refundAgentManager, daoFacade, useDevPrivilegeKeys); + super(DisputeManager, keyRing, p2PService, tradeManager, formatter, preferences, disputeSummaryWindow, + privateNotificationManager, contractWindow, tradeDetailsWindow, + accountAgeWitnessService, mediatorManager, refundAgentManager, daoFacade, useDevPrivilegeKeys); } @Override diff --git a/desktop/src/main/java/bisq/desktop/main/support/dispute/client/arbitration/ArbitrationClientView.java b/desktop/src/main/java/bisq/desktop/main/support/dispute/client/arbitration/ArbitrationClientView.java index 250886b77d6..5b3a7c6788a 100644 --- a/desktop/src/main/java/bisq/desktop/main/support/dispute/client/arbitration/ArbitrationClientView.java +++ b/desktop/src/main/java/bisq/desktop/main/support/dispute/client/arbitration/ArbitrationClientView.java @@ -38,6 +38,8 @@ import bisq.core.util.FormattingUtils; import bisq.core.util.coin.CoinFormatter; +import bisq.network.p2p.P2PService; + import bisq.common.config.Config; import bisq.common.crypto.KeyRing; @@ -49,6 +51,7 @@ public class ArbitrationClientView extends DisputeClientView { @Inject public ArbitrationClientView(ArbitrationManager arbitrationManager, KeyRing keyRing, + P2PService p2PService, TradeManager tradeManager, @Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter, Preferences preferences, @@ -61,7 +64,7 @@ public ArbitrationClientView(ArbitrationManager arbitrationManager, RefundAgentManager refundAgentManager, DaoFacade daoFacade, @Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys) { - super(arbitrationManager, keyRing, tradeManager, formatter, preferences, disputeSummaryWindow, + super(arbitrationManager, keyRing, p2PService, tradeManager, formatter, preferences, disputeSummaryWindow, privateNotificationManager, contractWindow, tradeDetailsWindow, accountAgeWitnessService, mediatorManager, refundAgentManager, daoFacade, useDevPrivilegeKeys); } diff --git a/desktop/src/main/java/bisq/desktop/main/support/dispute/client/mediation/MediationClientView.java b/desktop/src/main/java/bisq/desktop/main/support/dispute/client/mediation/MediationClientView.java index 7f55c5175b0..0594e9895e2 100644 --- a/desktop/src/main/java/bisq/desktop/main/support/dispute/client/mediation/MediationClientView.java +++ b/desktop/src/main/java/bisq/desktop/main/support/dispute/client/mediation/MediationClientView.java @@ -42,6 +42,7 @@ import bisq.core.util.coin.CoinFormatter; import bisq.network.p2p.NodeAddress; +import bisq.network.p2p.P2PService; import bisq.common.config.Config; import bisq.common.crypto.KeyRing; @@ -54,6 +55,7 @@ public class MediationClientView extends DisputeClientView { @Inject public MediationClientView(MediationManager mediationManager, KeyRing keyRing, + P2PService p2PService, TradeManager tradeManager, @Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter, Preferences preferences, @@ -66,7 +68,7 @@ public MediationClientView(MediationManager mediationManager, RefundAgentManager refundAgentManager, DaoFacade daoFacade, @Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys) { - super(mediationManager, keyRing, tradeManager, formatter, preferences, disputeSummaryWindow, + super(mediationManager, keyRing, p2PService, tradeManager, formatter, preferences, disputeSummaryWindow, privateNotificationManager, contractWindow, tradeDetailsWindow, accountAgeWitnessService, mediatorManager, refundAgentManager, daoFacade, useDevPrivilegeKeys); } diff --git a/desktop/src/main/java/bisq/desktop/main/support/dispute/client/refund/RefundClientView.java b/desktop/src/main/java/bisq/desktop/main/support/dispute/client/refund/RefundClientView.java index b622f25bef5..0efcfb38ae2 100644 --- a/desktop/src/main/java/bisq/desktop/main/support/dispute/client/refund/RefundClientView.java +++ b/desktop/src/main/java/bisq/desktop/main/support/dispute/client/refund/RefundClientView.java @@ -40,6 +40,7 @@ import bisq.core.util.coin.CoinFormatter; import bisq.network.p2p.NodeAddress; +import bisq.network.p2p.P2PService; import bisq.common.config.Config; import bisq.common.crypto.KeyRing; @@ -52,6 +53,7 @@ public class RefundClientView extends DisputeClientView { @Inject public RefundClientView(RefundManager refundManager, KeyRing keyRing, + P2PService p2PService, TradeManager tradeManager, @Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter, Preferences preferences, @@ -64,7 +66,7 @@ public RefundClientView(RefundManager refundManager, RefundAgentManager refundAgentManager, DaoFacade daoFacade, @Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys) { - super(refundManager, keyRing, tradeManager, formatter, preferences, disputeSummaryWindow, + super(refundManager, keyRing, p2PService, tradeManager, formatter, preferences, disputeSummaryWindow, privateNotificationManager, contractWindow, tradeDetailsWindow, accountAgeWitnessService, mediatorManager, refundAgentManager, daoFacade, useDevPrivilegeKeys); } From fb55e436f5d9c056590029afc07c5ef8774859b7 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Wed, 9 Jun 2021 11:47:41 +0200 Subject: [PATCH 2/9] Only allow failed trade to be moved to pending trades if local node address matches contract --- .../resources/i18n/displayStrings.properties | 1 + .../failedtrades/FailedTradesDataModel.java | 31 ++++++++++++++++--- .../failedtrades/FailedTradesView.java | 10 ++++-- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index fc9ff5b3417..27d05156ac4 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -980,6 +980,7 @@ portfolio.pending.failedTrade.txChainValid.moveToFailed=The trade protocol encou portfolio.pending.failedTrade.moveTradeToFailedIcon.tooltip=Move trade to failed trades portfolio.pending.failedTrade.warningIcon.tooltip=Click to open details about the issues of this trade portfolio.failed.revertToPending.popup=Do you want to move this trade to open trades? +portfolio.failed.revertToPending.failed=Failed to move this trade to open trades. portfolio.failed.revertToPending=Move trade to open trades portfolio.closed.completed=Completed diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/failedtrades/FailedTradesDataModel.java b/desktop/src/main/java/bisq/desktop/main/portfolio/failedtrades/FailedTradesDataModel.java index a4ce6e375e0..356bc275422 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/failedtrades/FailedTradesDataModel.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/failedtrades/FailedTradesDataModel.java @@ -25,26 +25,39 @@ import bisq.core.trade.TradeManager; import bisq.core.trade.failed.FailedTradesManager; +import bisq.network.p2p.NodeAddress; +import bisq.network.p2p.P2PService; + +import bisq.common.crypto.KeyRing; + import com.google.inject.Inject; import javafx.collections.FXCollections; import javafx.collections.ListChangeListener; import javafx.collections.ObservableList; +import java.util.Objects; import java.util.stream.Collectors; class FailedTradesDataModel extends ActivatableDataModel { private final FailedTradesManager failedTradesManager; private final TradeManager tradeManager; + private final P2PService p2PService; + private final KeyRing keyRing; private final ObservableList list = FXCollections.observableArrayList(); private final ListChangeListener tradesListChangeListener; @Inject - public FailedTradesDataModel(FailedTradesManager failedTradesManager, TradeManager tradeManager) { + public FailedTradesDataModel(FailedTradesManager failedTradesManager, + TradeManager tradeManager, + P2PService p2PService, + KeyRing keyRing) { this.failedTradesManager = failedTradesManager; this.tradeManager = tradeManager; + this.p2PService = p2PService; + this.keyRing = keyRing; tradesListChangeListener = change -> applyList(); } @@ -77,9 +90,19 @@ private void applyList() { list.sort((o1, o2) -> o2.getTrade().getDate().compareTo(o1.getTrade().getDate())); } - public void onMoveTradeToPendingTrades(Trade trade) { - failedTradesManager.removeTrade(trade); - tradeManager.addFailedTradeToPendingTrades(trade); + public boolean onMoveTradeToPendingTrades(Trade trade) { + if (isTradeWithSameCurrentNodeAddress(trade)) { + failedTradesManager.removeTrade(trade); + tradeManager.addFailedTradeToPendingTrades(trade); + return true; + } else { + return false; + } + } + + private boolean isTradeWithSameCurrentNodeAddress(Trade trade) { + NodeAddress tradeNodeAddress = trade.getContract().getMyNodeAddress(keyRing.getPubKeyRing()); + return Objects.equals(p2PService.getNetworkNode().getNodeAddress(), tradeNodeAddress); } public void unfailTrade(Trade trade) { diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/failedtrades/FailedTradesView.java b/desktop/src/main/java/bisq/desktop/main/portfolio/failedtrades/FailedTradesView.java index 26f1ec182c6..a58e1cf3ce1 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/failedtrades/FailedTradesView.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/failedtrades/FailedTradesView.java @@ -334,14 +334,18 @@ private String checkTxs() { private void onRevertTrade(Trade trade) { new Popup().attention(Res.get("portfolio.failed.revertToPending.popup")) - .onAction(() -> onMoveTradeToPendingTrades(trade)) + .onAction(() -> { + if (!onMoveTradeToPendingTrades(trade)) { + new Popup().warning(Res.get("portfolio.failed.revertToPending.failed")).show(); + } + }) .actionButtonText(Res.get("shared.yes")) .closeButtonText(Res.get("shared.no")) .show(); } - private void onMoveTradeToPendingTrades(Trade trade) { - model.dataModel.onMoveTradeToPendingTrades(trade); + private boolean onMoveTradeToPendingTrades(Trade trade) { + return model.dataModel.onMoveTradeToPendingTrades(trade); } private void setTradeIdColumnCellFactory() { From e9ef4137227f5440cd14e7693aaf3e8e50ce742a Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Mon, 14 Jun 2021 16:10:47 +0200 Subject: [PATCH 3/9] Display a tor node address v3 upgrade prompt whenever the client is in a state to do so without any problems. --- .../java/bisq/core/app/BisqHeadlessApp.java | 1 + .../main/java/bisq/core/app/BisqSetup.java | 51 ++++++++++++++++--- .../resources/i18n/displayStrings.properties | 9 +++- .../java/bisq/desktop/main/MainViewModel.java | 15 +++++- .../main/java/bisq/network/utils/Utils.java | 4 ++ .../java/bisq/network/utils/UtilsTest.java | 36 +++++++++++++ 6 files changed, 108 insertions(+), 8 deletions(-) create mode 100644 p2p/src/test/java/bisq/network/utils/UtilsTest.java diff --git a/core/src/main/java/bisq/core/app/BisqHeadlessApp.java b/core/src/main/java/bisq/core/app/BisqHeadlessApp.java index 172f94778a4..a6fcca5401c 100644 --- a/core/src/main/java/bisq/core/app/BisqHeadlessApp.java +++ b/core/src/main/java/bisq/core/app/BisqHeadlessApp.java @@ -102,6 +102,7 @@ protected void setupHandlers() { gracefulShutDownHandler.gracefulShutDown(() -> { }); }); + bisqSetup.setTorAddressUpgradeHandler(() -> log.info("setTorAddressUpgradeHandler")); corruptedStorageFileHandler.getFiles().ifPresent(files -> log.warn("getCorruptedDatabaseFiles. files={}", files)); tradeManager.setTakeOfferRequestErrorMessageHandler(errorMessage -> log.error("onTakeOfferRequestErrorMessageHandler")); diff --git a/core/src/main/java/bisq/core/app/BisqSetup.java b/core/src/main/java/bisq/core/app/BisqSetup.java index c78686f356d..541fe069da5 100644 --- a/core/src/main/java/bisq/core/app/BisqSetup.java +++ b/core/src/main/java/bisq/core/app/BisqSetup.java @@ -37,6 +37,10 @@ import bisq.core.payment.PaymentAccount; import bisq.core.payment.RevolutAccount; import bisq.core.payment.payload.PaymentMethod; +import bisq.core.support.dispute.Dispute; +import bisq.core.support.dispute.arbitration.ArbitrationManager; +import bisq.core.support.dispute.mediation.MediationManager; +import bisq.core.support.dispute.refund.RefundManager; import bisq.core.trade.TradeManager; import bisq.core.trade.TradeTxException; import bisq.core.user.Preferences; @@ -47,6 +51,7 @@ import bisq.network.Socks5ProxyProvider; import bisq.network.p2p.P2PService; import bisq.network.p2p.storage.payload.PersistableNetworkPayload; +import bisq.network.utils.Utils; import bisq.common.Timer; import bisq.common.UserThread; @@ -84,6 +89,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Objects; import java.util.Scanner; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -135,10 +141,12 @@ default void onRequestWalletPassword() { private final UnconfirmedBsqChangeOutputListService unconfirmedBsqChangeOutputListService; private final Config config; private final AccountAgeWitnessService accountAgeWitnessService; - private final TorSetup torSetup; private final CoinFormatter formatter; private final LocalBitcoinNode localBitcoinNode; private final AppStartupState appStartupState; + private final MediationManager mediationManager; + private final RefundManager refundManager; + private final ArbitrationManager arbitrationManager; @Setter @Nullable @@ -189,6 +197,9 @@ default void onRequestWalletPassword() { private Runnable daoRequiresRestartHandler; @Setter @Nullable + private Runnable torAddressUpgradeHandler; + @Setter + @Nullable private Consumer downGradePreventionHandler; @Getter @@ -217,11 +228,13 @@ public BisqSetup(DomainInitialisation domainInitialisation, UnconfirmedBsqChangeOutputListService unconfirmedBsqChangeOutputListService, Config config, AccountAgeWitnessService accountAgeWitnessService, - TorSetup torSetup, @Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter, LocalBitcoinNode localBitcoinNode, AppStartupState appStartupState, - Socks5ProxyProvider socks5ProxyProvider) { + Socks5ProxyProvider socks5ProxyProvider, + MediationManager mediationManager, + RefundManager refundManager, + ArbitrationManager arbitrationManager) { this.domainInitialisation = domainInitialisation; this.p2PNetworkSetup = p2PNetworkSetup; this.walletAppSetup = walletAppSetup; @@ -238,10 +251,12 @@ public BisqSetup(DomainInitialisation domainInitialisation, this.unconfirmedBsqChangeOutputListService = unconfirmedBsqChangeOutputListService; this.config = config; this.accountAgeWitnessService = accountAgeWitnessService; - this.torSetup = torSetup; this.formatter = formatter; this.localBitcoinNode = localBitcoinNode; this.appStartupState = appStartupState; + this.mediationManager = mediationManager; + this.refundManager = refundManager; + this.arbitrationManager = arbitrationManager; MemPoolSpaceTxBroadcaster.init(socks5ProxyProvider, preferences, localBitcoinNode); } @@ -312,6 +327,7 @@ private void step4() { maybeShowSecurityRecommendation(); maybeShowLocalhostRunningInfo(); maybeShowAccountSigningStateInfo(); + maybeShowTorAddressUpgradeInformation(); } @@ -563,8 +579,6 @@ public static void setResyncSpvSemaphore(boolean isResyncSpvRequested) { } - - private static File getVersionFile() { return new File(Config.appDataDir(), VERSION_FILE_NAME); } @@ -702,6 +716,31 @@ private void maybeTriggerDisplayHandler(String key, Consumer displayHand } } + private void maybeShowTorAddressUpgradeInformation() { + if (Config.baseCurrencyNetwork().isRegtest() || + Utils.isV3Address(Objects.requireNonNull(p2PService.getNetworkNode().getNodeAddress()).getHostName())) { + return; + } + + maybeRunTorNodeAddressUpgradeHandler(); + + tradeManager.getNumPendingTrades().addListener((observable, oldValue, newValue) -> { + long numPendingTrades = (long) newValue; + if (numPendingTrades == 0) { + maybeRunTorNodeAddressUpgradeHandler(); + } + }); + } + + private void maybeRunTorNodeAddressUpgradeHandler() { + if (mediationManager.getDisputesAsObservableList().stream().allMatch(Dispute::isClosed) && + refundManager.getDisputesAsObservableList().stream().allMatch(Dispute::isClosed) && + arbitrationManager.getDisputesAsObservableList().stream().allMatch(Dispute::isClosed) && + tradeManager.getNumPendingTrades().isEqualTo(0).get()) { + Objects.requireNonNull(torAddressUpgradeHandler).run(); + } + } + /////////////////////////////////////////////////////////////////////////////////////////// // Getters diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 27d05156ac4..b0e7493d2f2 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -2994,6 +2994,13 @@ popup.accountSigning.unsignedPubKeys.signed=Pubkeys were signed popup.accountSigning.unsignedPubKeys.result.signed=Signed pubkeys popup.accountSigning.unsignedPubKeys.result.failed=Failed to sign +popup.info.torMigration.msg=You won't be able to use your Tor v2 address anymore starting from October 15th, 2021 [HYPERLINK:https://blog.torproject.org/v2-deprecation-timeline]. \ + Your client is right now in a state that allows you to generate a new Tor v3 address [HYPERLINK:https://bisq.wiki/Changing_your_onion_address] \ + Please make a full back up of your data directory first before you proceed to switch to a Tor v3 address \ + following the guide in the bisq.wiki. Also be aware as Bisq's "reputation" is bound to onion addresses that former \ + trading partners won't be able to recognize you anymore. You'll not loose your signed account status with upgrading \ + to a new onion address. + #################################################################### # Notifications #################################################################### @@ -3109,7 +3116,7 @@ txIdTextField.missingTx.warning.tooltip=Missing required transaction #################################################################### navigation.account=\"Account\" -navigation.account.walletSeed=\"Account/Wallet seed\" +navigation.account.backup=\"Account/Backup\" navigation.funds.availableForWithdrawal=\"Funds/Send funds\" navigation.portfolio.myOpenOffers=\"Portfolio/My open offers\" navigation.portfolio.pending=\"Portfolio/Open trades\" diff --git a/desktop/src/main/java/bisq/desktop/main/MainViewModel.java b/desktop/src/main/java/bisq/desktop/main/MainViewModel.java index abba0a66b96..cf537911e9d 100644 --- a/desktop/src/main/java/bisq/desktop/main/MainViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/MainViewModel.java @@ -17,9 +17,12 @@ package bisq.desktop.main; +import bisq.desktop.Navigation; import bisq.desktop.app.BisqApp; import bisq.desktop.common.model.ViewModel; import bisq.desktop.components.TxIdTextField; +import bisq.desktop.main.account.AccountView; +import bisq.desktop.main.account.content.backup.BackupView; import bisq.desktop.main.overlays.Overlay; import bisq.desktop.main.overlays.notifications.NotificationCenter; import bisq.desktop.main.overlays.popups.Popup; @@ -135,6 +138,7 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupListener { @Getter private final TorNetworkSettingsWindow torNetworkSettingsWindow; private final CorruptedStorageFileHandler corruptedStorageFileHandler; + private final Navigation navigation; @Getter private final BooleanProperty showAppScreen = new SimpleBooleanProperty(); @@ -178,7 +182,8 @@ public MainViewModel(BisqSetup bisqSetup, LocalBitcoinNode localBitcoinNode, AccountAgeWitnessService accountAgeWitnessService, TorNetworkSettingsWindow torNetworkSettingsWindow, - CorruptedStorageFileHandler corruptedStorageFileHandler) { + CorruptedStorageFileHandler corruptedStorageFileHandler, + Navigation navigation) { this.bisqSetup = bisqSetup; this.walletsSetup = walletsSetup; this.user = user; @@ -203,6 +208,7 @@ public MainViewModel(BisqSetup bisqSetup, this.accountAgeWitnessService = accountAgeWitnessService; this.torNetworkSettingsWindow = torNetworkSettingsWindow; this.corruptedStorageFileHandler = corruptedStorageFileHandler; + this.navigation = navigation; TxIdTextField.setPreferences(preferences); @@ -415,6 +421,13 @@ private void setupHandlers() { .hideCloseButton() .show()); + bisqSetup.setTorAddressUpgradeHandler(() -> new Popup().information(Res.get("popup.info.torMigration.msg")) + .actionButtonTextWithGoTo("navigation.account.backup") + .onAction(() -> { + navigation.setReturnPath(navigation.getCurrentPath()); + navigation.navigateTo(MainView.class, AccountView.class, BackupView.class); + }).show()); + corruptedStorageFileHandler.getFiles().ifPresent(files -> new Popup() .warning(Res.get("popup.warning.incompatibleDB", files.toString(), config.appDataDir)) .useShutDownButton() diff --git a/p2p/src/main/java/bisq/network/utils/Utils.java b/p2p/src/main/java/bisq/network/utils/Utils.java index e7df798c1e9..89bc2d5ac18 100644 --- a/p2p/src/main/java/bisq/network/utils/Utils.java +++ b/p2p/src/main/java/bisq/network/utils/Utils.java @@ -34,4 +34,8 @@ public static int findFreeSystemPort() { return new Random().nextInt(10000) + 50000; } } + + public static boolean isV3Address(String address) { + return address.matches("[a-z2-7]{56}.onion"); + } } diff --git a/p2p/src/test/java/bisq/network/utils/UtilsTest.java b/p2p/src/test/java/bisq/network/utils/UtilsTest.java new file mode 100644 index 00000000000..c036cee6903 --- /dev/null +++ b/p2p/src/test/java/bisq/network/utils/UtilsTest.java @@ -0,0 +1,36 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.network.utils; + +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class UtilsTest { + + @Test + public void checkV2Address() { + assertFalse(Utils.isV3Address("xmh57jrzrnw6insl.onion")); + } + + @Test + public void checkV3Address() { + assertTrue(Utils.isV3Address("vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd.onion")); + } +} From 0dbbf4d7793c68cd44feb96715e2a7929c446cfd Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Mon, 14 Jun 2021 16:11:06 +0200 Subject: [PATCH 4/9] Remove stale "NEW" badge on settings --- .../bisq/desktop/main/presentation/SettingsPresentation.java | 1 - 1 file changed, 1 deletion(-) diff --git a/desktop/src/main/java/bisq/desktop/main/presentation/SettingsPresentation.java b/desktop/src/main/java/bisq/desktop/main/presentation/SettingsPresentation.java index 73508b05386..cd845c79756 100644 --- a/desktop/src/main/java/bisq/desktop/main/presentation/SettingsPresentation.java +++ b/desktop/src/main/java/bisq/desktop/main/presentation/SettingsPresentation.java @@ -58,6 +58,5 @@ public BooleanProperty getShowSettingsUpdatesNotification() { } public void setup() { - showNotification.set(preferences.showAgain(SETTINGS_NEWS)); } } From 8acd578ff24794a7beb778d1c41bad3513e08fdb Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Mon, 14 Jun 2021 17:01:40 +0200 Subject: [PATCH 5/9] Prevent nodes with Tor v2 address to participate in trading After the date specified take offer requests by nodes with Tor v2 addresses will be rejected and their offers will be invisible to everyone else. --- .../main/java/bisq/core/offer/OfferRestrictions.java | 10 +++++----- .../main/java/bisq/core/offer/OpenOfferManager.java | 8 ++++++++ core/src/main/resources/i18n/displayStrings.properties | 3 ++- .../bisq/desktop/main/offer/offerbook/OfferBook.java | 9 +++++++++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/bisq/core/offer/OfferRestrictions.java b/core/src/main/java/bisq/core/offer/OfferRestrictions.java index 856b7a6e206..027a8219a6a 100644 --- a/core/src/main/java/bisq/core/offer/OfferRestrictions.java +++ b/core/src/main/java/bisq/core/offer/OfferRestrictions.java @@ -28,12 +28,12 @@ import java.util.Map; public class OfferRestrictions { - // The date when traders who have not updated cannot take offers from updated clients and their offers become - // invisible for updated clients. - private static final Date REQUIRE_UPDATE_DATE = Utilities.getUTCDate(2019, GregorianCalendar.SEPTEMBER, 19); + // The date when traders who have not upgraded to a Tor v3 Node Address cannot take offers and their offers become + // invisible. + private static final Date REQUIRE_TOR_NODE_ADDRESS_V3_DATE = Utilities.getUTCDate(2021, GregorianCalendar.AUGUST, 15); - static boolean requiresUpdate() { - return new Date().after(REQUIRE_UPDATE_DATE); + public static boolean requiresNodeAddressUpdate() { + return new Date().after(REQUIRE_TOR_NODE_ADDRESS_V3_DATE); } public static Coin TOLERATED_SMALL_TRADE_AMOUNT = Coin.parseCoin("0.01"); diff --git a/core/src/main/java/bisq/core/offer/OpenOfferManager.java b/core/src/main/java/bisq/core/offer/OpenOfferManager.java index bf04e10b19e..7c8ddb2c653 100644 --- a/core/src/main/java/bisq/core/offer/OpenOfferManager.java +++ b/core/src/main/java/bisq/core/offer/OpenOfferManager.java @@ -52,6 +52,7 @@ import bisq.network.p2p.SendDirectMessageListener; import bisq.network.p2p.peers.Broadcaster; import bisq.network.p2p.peers.PeerManager; +import bisq.network.utils.Utils; import bisq.common.Timer; import bisq.common.UserThread; @@ -598,6 +599,13 @@ private void handleOfferAvailabilityRequest(OfferAvailabilityRequest request, No boolean result = false; String errorMessage = null; + if (OfferRestrictions.requiresNodeAddressUpdate() && !Utils.isV3Address(peer.getHostName())) { + errorMessage = "We got a handleOfferAvailabilityRequest from a Tor node v2 address where a Tor node v3 address is required."; + log.info(errorMessage); + sendAckMessage(request, peer, false, errorMessage); + return; + } + if (!p2PService.isBootstrapped()) { errorMessage = "We got a handleOfferAvailabilityRequest but we have not bootstrapped yet."; log.info(errorMessage); diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index b0e7493d2f2..80e4e83043d 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -2994,7 +2994,8 @@ popup.accountSigning.unsignedPubKeys.signed=Pubkeys were signed popup.accountSigning.unsignedPubKeys.result.signed=Signed pubkeys popup.accountSigning.unsignedPubKeys.result.failed=Failed to sign -popup.info.torMigration.msg=You won't be able to use your Tor v2 address anymore starting from October 15th, 2021 [HYPERLINK:https://blog.torproject.org/v2-deprecation-timeline]. \ +popup.info.torMigration.msg=You won't be able to use your Tor v2 address anymore starting from October 15th, 2021 [HYPERLINK:https://blog.torproject.org/v2-deprecation-timeline].\n\ + To provide a graceful upgrade process for everyone, nodes with Tor v2 addresses won't be able to participate in any trading activity starting from August 15th, 2021.\n\n\ Your client is right now in a state that allows you to generate a new Tor v3 address [HYPERLINK:https://bisq.wiki/Changing_your_onion_address] \ Please make a full back up of your data directory first before you proceed to switch to a Tor v3 address \ following the guide in the bisq.wiki. Also be aware as Bisq's "reputation" is bound to onion addresses that former \ diff --git a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBook.java b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBook.java index b6108d4ef35..753506bce12 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBook.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBook.java @@ -20,8 +20,11 @@ import bisq.core.filter.FilterManager; import bisq.core.offer.Offer; import bisq.core.offer.OfferBookService; +import bisq.core.offer.OfferRestrictions; import bisq.core.trade.TradeManager; +import bisq.network.utils.Utils; + import javax.inject.Inject; import javax.inject.Singleton; @@ -75,6 +78,11 @@ public void onAdded(Offer offer) { return; } + if (OfferRestrictions.requiresNodeAddressUpdate() && !Utils.isV3Address(offer.getMakerNodeAddress().getHostName())) { + log.debug("Ignored offer with Tor v2 node address. ID={}", offer.getId()); + return; + } + boolean hasSameOffer = offerBookListItems.stream() .anyMatch(item -> item.getOffer().equals(offer)); if (!hasSameOffer) { @@ -126,6 +134,7 @@ public void fillOfferBookListItems() { offerBookListItems.clear(); offerBookListItems.addAll(offerBookService.getOffers().stream() .filter(o -> !filterManager.isOfferIdBanned(o.getId())) + .filter(o -> !OfferRestrictions.requiresNodeAddressUpdate() || Utils.isV3Address(o.getMakerNodeAddress().getHostName())) .map(OfferBookListItem::new) .collect(Collectors.toList())); From 6e213e9db8436bfbb2b59afa2dc6ea7dd0a2e718 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Mon, 14 Jun 2021 17:11:31 +0200 Subject: [PATCH 6/9] Prevent reopen of disputes with tor node v2 addresses after cut off date --- .../bisq/desktop/main/support/dispute/DisputeView.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/desktop/src/main/java/bisq/desktop/main/support/dispute/DisputeView.java b/desktop/src/main/java/bisq/desktop/main/support/dispute/DisputeView.java index e7bd3a8baf3..71beb89ebf4 100644 --- a/desktop/src/main/java/bisq/desktop/main/support/dispute/DisputeView.java +++ b/desktop/src/main/java/bisq/desktop/main/support/dispute/DisputeView.java @@ -38,6 +38,7 @@ import bisq.core.dao.DaoFacade; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.Res; +import bisq.core.offer.OfferRestrictions; import bisq.core.support.SupportType; import bisq.core.support.dispute.Dispute; import bisq.core.support.dispute.DisputeList; @@ -58,6 +59,7 @@ import bisq.network.p2p.NodeAddress; import bisq.network.p2p.P2PService; +import bisq.network.utils.Utils; import bisq.common.UserThread; import bisq.common.crypto.KeyRing; @@ -542,6 +544,11 @@ protected boolean reOpenDispute() { private boolean isDisputeWithSameCurrentNodeAddress(Dispute dispute, boolean isMediator) { NodeAddress disputeNodeAddress = isMediator ? dispute.getContract().getMediatorNodeAddress() : dispute.getContract().getMyNodeAddress(keyRing.getPubKeyRing()); + + if (OfferRestrictions.requiresNodeAddressUpdate() && !Utils.isV3Address(disputeNodeAddress.getHostName())) { + return false; + } + return Objects.equals(p2PService.getNetworkNode().getNodeAddress(), disputeNodeAddress); } From 54006dc0ef8fbfefa6776f9f08023e7d17a03709 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Mon, 14 Jun 2021 17:13:47 +0200 Subject: [PATCH 7/9] Not require Tor v3 addresses on Regtest Local dev environment normally uses localhost:PORT addresses not connecting through Tor. --- core/src/main/java/bisq/core/offer/OfferRestrictions.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/bisq/core/offer/OfferRestrictions.java b/core/src/main/java/bisq/core/offer/OfferRestrictions.java index 027a8219a6a..88469c235f1 100644 --- a/core/src/main/java/bisq/core/offer/OfferRestrictions.java +++ b/core/src/main/java/bisq/core/offer/OfferRestrictions.java @@ -19,6 +19,7 @@ import bisq.common.app.Capabilities; import bisq.common.app.Capability; +import bisq.common.config.Config; import bisq.common.util.Utilities; import org.bitcoinj.core.Coin; @@ -33,7 +34,7 @@ public class OfferRestrictions { private static final Date REQUIRE_TOR_NODE_ADDRESS_V3_DATE = Utilities.getUTCDate(2021, GregorianCalendar.AUGUST, 15); public static boolean requiresNodeAddressUpdate() { - return new Date().after(REQUIRE_TOR_NODE_ADDRESS_V3_DATE); + return Config.baseCurrencyNetwork().isRegtest() || new Date().after(REQUIRE_TOR_NODE_ADDRESS_V3_DATE); } public static Coin TOLERATED_SMALL_TRADE_AMOUNT = Coin.parseCoin("0.01"); From 5a8e1cf688b6eb34d0a94963ff309ec0f0c5938b Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Thu, 17 Jun 2021 15:26:00 +0200 Subject: [PATCH 8/9] Adapted tor migration message Based on feedback by @m52go --- .../main/resources/i18n/displayStrings.properties | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 80e4e83043d..0291b57473c 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -2994,13 +2994,12 @@ popup.accountSigning.unsignedPubKeys.signed=Pubkeys were signed popup.accountSigning.unsignedPubKeys.result.signed=Signed pubkeys popup.accountSigning.unsignedPubKeys.result.failed=Failed to sign -popup.info.torMigration.msg=You won't be able to use your Tor v2 address anymore starting from October 15th, 2021 [HYPERLINK:https://blog.torproject.org/v2-deprecation-timeline].\n\ - To provide a graceful upgrade process for everyone, nodes with Tor v2 addresses won't be able to participate in any trading activity starting from August 15th, 2021.\n\n\ - Your client is right now in a state that allows you to generate a new Tor v3 address [HYPERLINK:https://bisq.wiki/Changing_your_onion_address] \ - Please make a full back up of your data directory first before you proceed to switch to a Tor v3 address \ - following the guide in the bisq.wiki. Also be aware as Bisq's "reputation" is bound to onion addresses that former \ - trading partners won't be able to recognize you anymore. You'll not loose your signed account status with upgrading \ - to a new onion address. +popup.info.torMigration.msg=Your Bisq node is currently using a Tor v2 address. Tor v2 is being deprecated soon \ + [HYPERLINK:https://blog.torproject.org/v2-deprecation-timeline], and \ + Bisq nodes with Tor v2 addresses will no longer be able to trade on August 15th, 2021.\n\n\ + Please switch your Bisq node to a Tor v3 address. It's quick and simple -- see details in this doc \ + [HYPERLINK:https://bisq.wiki/Changing_your_onion_address] or in this video [HYPERLINK:https://bitcointv.com/videos/watch/f96adc20-4092-4253-84c0-1b18088b4b95]. \n\n\ + Make sure to back up your data directory beforehand. #################################################################### # Notifications From 8d18e07f52021aa316a6f76c930e394de9b7bbcd Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Wed, 23 Jun 2021 12:25:46 +0200 Subject: [PATCH 9/9] Apply PR Review suggestion by @sqrrm --- .../main/java/bisq/core/offer/OfferRestrictions.java | 2 +- .../portfolio/failedtrades/FailedTradesDataModel.java | 10 +++++----- .../bisq/desktop/main/support/dispute/DisputeView.java | 4 ++-- .../main/support/dispute/agent/DisputeAgentView.java | 3 ++- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/bisq/core/offer/OfferRestrictions.java b/core/src/main/java/bisq/core/offer/OfferRestrictions.java index 88469c235f1..eec00333d36 100644 --- a/core/src/main/java/bisq/core/offer/OfferRestrictions.java +++ b/core/src/main/java/bisq/core/offer/OfferRestrictions.java @@ -34,7 +34,7 @@ public class OfferRestrictions { private static final Date REQUIRE_TOR_NODE_ADDRESS_V3_DATE = Utilities.getUTCDate(2021, GregorianCalendar.AUGUST, 15); public static boolean requiresNodeAddressUpdate() { - return Config.baseCurrencyNetwork().isRegtest() || new Date().after(REQUIRE_TOR_NODE_ADDRESS_V3_DATE); + return new Date().after(REQUIRE_TOR_NODE_ADDRESS_V3_DATE) && !Config.baseCurrencyNetwork().isRegtest(); } public static Coin TOLERATED_SMALL_TRADE_AMOUNT = Coin.parseCoin("0.01"); diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/failedtrades/FailedTradesDataModel.java b/desktop/src/main/java/bisq/desktop/main/portfolio/failedtrades/FailedTradesDataModel.java index 356bc275422..defd7613622 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/failedtrades/FailedTradesDataModel.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/failedtrades/FailedTradesDataModel.java @@ -91,13 +91,13 @@ private void applyList() { } public boolean onMoveTradeToPendingTrades(Trade trade) { - if (isTradeWithSameCurrentNodeAddress(trade)) { - failedTradesManager.removeTrade(trade); - tradeManager.addFailedTradeToPendingTrades(trade); - return true; - } else { + if (!isTradeWithSameCurrentNodeAddress(trade)) { return false; } + + failedTradesManager.removeTrade(trade); + tradeManager.addFailedTradeToPendingTrades(trade); + return true; } private boolean isTradeWithSameCurrentNodeAddress(Trade trade) { diff --git a/desktop/src/main/java/bisq/desktop/main/support/dispute/DisputeView.java b/desktop/src/main/java/bisq/desktop/main/support/dispute/DisputeView.java index 71beb89ebf4..4dd791d88bf 100644 --- a/desktop/src/main/java/bisq/desktop/main/support/dispute/DisputeView.java +++ b/desktop/src/main/java/bisq/desktop/main/support/dispute/DisputeView.java @@ -528,7 +528,7 @@ protected void handleOnProcessDispute(Dispute dispute) { protected boolean reOpenDispute() { if (selectedDispute != null && selectedDispute.isClosed() && - isDisputeWithSameCurrentNodeAddress(selectedDispute, + isNodeAddressOk(selectedDispute, !disputeManager.isTrader(selectedDispute))) { selectedDispute.reOpen(); handleOnProcessDispute(selectedDispute); @@ -541,7 +541,7 @@ protected boolean reOpenDispute() { } } - private boolean isDisputeWithSameCurrentNodeAddress(Dispute dispute, boolean isMediator) { + private boolean isNodeAddressOk(Dispute dispute, boolean isMediator) { NodeAddress disputeNodeAddress = isMediator ? dispute.getContract().getMediatorNodeAddress() : dispute.getContract().getMyNodeAddress(keyRing.getPubKeyRing()); diff --git a/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/DisputeAgentView.java b/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/DisputeAgentView.java index fefab886353..e7ed03bf36a 100644 --- a/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/DisputeAgentView.java +++ b/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/DisputeAgentView.java @@ -74,7 +74,8 @@ public abstract class DisputeAgentView extends DisputeView implements MultipleHo public DisputeAgentView(DisputeManager> disputeManager, KeyRing keyRing, - P2PService p2PService, TradeManager tradeManager, + P2PService p2PService, + TradeManager tradeManager, CoinFormatter formatter, Preferences preferences, DisputeSummaryWindow disputeSummaryWindow,