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/java/bisq/core/offer/OfferRestrictions.java b/core/src/main/java/bisq/core/offer/OfferRestrictions.java index 856b7a6e206..eec00333d36 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; @@ -28,12 +29,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) && !Config.baseCurrencyNetwork().isRegtest(); } 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 bdf67008e7b..0291b57473c 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 @@ -1111,6 +1112,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 @@ -2992,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=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 #################################################################### @@ -3107,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/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())); 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..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 @@ -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) { + public boolean onMoveTradeToPendingTrades(Trade trade) { + if (!isTradeWithSameCurrentNodeAddress(trade)) { + return false; + } + failedTradesManager.removeTrade(trade); tradeManager.addFailedTradeToPendingTrades(trade); + return true; + } + + 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() { 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)); } } 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..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 @@ -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; @@ -57,6 +58,8 @@ import bisq.core.util.coin.CoinFormatter; import bisq.network.p2p.NodeAddress; +import bisq.network.p2p.P2PService; +import bisq.network.utils.Utils; import bisq.common.UserThread; import bisq.common.crypto.KeyRing; @@ -108,6 +111,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 +153,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 +197,7 @@ public enum FilterResult { public DisputeView(DisputeManager> disputeManager, KeyRing keyRing, + P2PService p2PService, TradeManager tradeManager, CoinFormatter formatter, Preferences preferences, @@ -206,6 +212,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 +502,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 +525,33 @@ 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() && + isNodeAddressOk(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 isNodeAddressOk(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); + } + /////////////////////////////////////////////////////////////////////////////////////////// // 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..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 @@ -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,6 +74,7 @@ public abstract class DisputeAgentView extends DisputeView implements MultipleHo public DisputeAgentView(DisputeManager> disputeManager, KeyRing keyRing, + P2PService p2PService, TradeManager tradeManager, CoinFormatter formatter, Preferences preferences, @@ -86,6 +89,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); } 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")); + } +}