diff --git a/common/src/main/proto/pb.proto b/common/src/main/proto/pb.proto index 65afa4df9f8..29875026d0e 100644 --- a/common/src/main/proto/pb.proto +++ b/common/src/main/proto/pb.proto @@ -528,6 +528,7 @@ message Filter { bool prevent_public_btc_network = 12; repeated string btc_nodes = 13; bool disable_dao = 14; + string disable_dao_below_version = 15; } // not used anymore from v0.6 on. But leave it for receiving TradeStatistics objects from older diff --git a/core/src/main/java/bisq/core/dao/DaoKillSwitch.java b/core/src/main/java/bisq/core/dao/DaoKillSwitch.java index bec83f76ea3..af72fb3dea6 100644 --- a/core/src/main/java/bisq/core/dao/DaoKillSwitch.java +++ b/core/src/main/java/bisq/core/dao/DaoKillSwitch.java @@ -21,10 +21,16 @@ import bisq.core.filter.Filter; import bisq.core.filter.FilterManager; +import bisq.common.app.Version; + import javax.inject.Inject; import lombok.Getter; +import lombok.extern.slf4j.Slf4j; + +import javax.annotation.Nullable; +@Slf4j public class DaoKillSwitch implements DaoSetupService { private static DaoKillSwitch INSTANCE; private final FilterManager filterManager; @@ -49,8 +55,19 @@ public void start() { applyFilter(filterManager.getFilter()); } - private void applyFilter(Filter filter) { - daoDisabled = filter != null && filter.isDisableDao(); + private void applyFilter(@Nullable Filter filter) { + if (filter == null) { + daoDisabled = false; + return; + } + + boolean requireUpdateToNewVersion = false; + String disableDaoBelowVersion = filter.getDisableDaoBelowVersion(); + if (disableDaoBelowVersion != null && !disableDaoBelowVersion.isEmpty()) { + requireUpdateToNewVersion = Version.isNewVersion(disableDaoBelowVersion); + } + + daoDisabled = requireUpdateToNewVersion || filter.isDisableDao(); } public static void assertDaoIsNotDisabled() { diff --git a/core/src/main/java/bisq/core/filter/Filter.java b/core/src/main/java/bisq/core/filter/Filter.java index b2fc9f92020..53d761c3440 100644 --- a/core/src/main/java/bisq/core/filter/Filter.java +++ b/core/src/main/java/bisq/core/filter/Filter.java @@ -90,6 +90,10 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload { // added in v0.9.4 private final boolean disableDao; + // added in v0.9.8 + @Nullable + private final String disableDaoBelowVersion; + public Filter(List bannedOfferIds, List bannedNodeAddress, List bannedPaymentAccounts, @@ -100,7 +104,8 @@ public Filter(List bannedOfferIds, @Nullable List priceRelayNodes, boolean preventPublicBtcNetwork, @Nullable List btcNodes, - boolean disableDao) { + boolean disableDao, + @Nullable String disableDaoBelowVersion) { this.bannedOfferIds = bannedOfferIds; this.bannedNodeAddress = bannedNodeAddress; this.bannedPaymentAccounts = bannedPaymentAccounts; @@ -112,6 +117,7 @@ public Filter(List bannedOfferIds, this.preventPublicBtcNetwork = preventPublicBtcNetwork; this.btcNodes = btcNodes; this.disableDao = disableDao; + this.disableDaoBelowVersion = disableDaoBelowVersion; } @@ -131,6 +137,7 @@ public Filter(List bannedOfferIds, boolean preventPublicBtcNetwork, @Nullable List btcNodes, boolean disableDao, + @Nullable String disableDaoBelowVersion, String signatureAsBase64, byte[] ownerPubKeyBytes, @Nullable Map extraDataMap) { @@ -144,7 +151,8 @@ public Filter(List bannedOfferIds, priceRelayNodes, preventPublicBtcNetwork, btcNodes, - disableDao); + disableDao, + disableDaoBelowVersion); this.signatureAsBase64 = signatureAsBase64; this.ownerPubKeyBytes = ownerPubKeyBytes; this.extraDataMap = ExtraDataMapValidator.getValidatedExtraDataMap(extraDataMap); @@ -174,6 +182,7 @@ public PB.StoragePayload toProtoMessage() { Optional.ofNullable(seedNodes).ifPresent(builder::addAllSeedNodes); Optional.ofNullable(priceRelayNodes).ifPresent(builder::addAllPriceRelayNodes); Optional.ofNullable(btcNodes).ifPresent(builder::addAllBtcNodes); + Optional.ofNullable(disableDaoBelowVersion).ifPresent(builder::setDisableDaoBelowVersion); Optional.ofNullable(extraDataMap).ifPresent(builder::putAllExtraData); return PB.StoragePayload.newBuilder().setFilter(builder).build(); @@ -193,6 +202,7 @@ public static Filter fromProto(PB.Filter proto) { proto.getPreventPublicBtcNetwork(), CollectionUtils.isEmpty(proto.getBtcNodesList()) ? null : new ArrayList<>(proto.getBtcNodesList()), proto.getDisableDao(), + proto.getDisableDaoBelowVersion().isEmpty() ? null : proto.getDisableDaoBelowVersion(), proto.getSignatureAsBase64(), proto.getOwnerPubKeyBytes().toByteArray(), CollectionUtils.isEmpty(proto.getExtraDataMap()) ? null : proto.getExtraDataMap()); @@ -205,7 +215,7 @@ public static Filter fromProto(PB.Filter proto) { @Override public long getTTL() { - return TimeUnit.DAYS.toMillis(90); + return TimeUnit.DAYS.toMillis(180); } public void setSigAndPubKey(String signatureAsBase64, PublicKey ownerPubKey) { diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index a63277d9e85..26dcce62247 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -2075,6 +2075,7 @@ filterWindow.priceRelayNode=Filtered price relay nodes (comma sep. onion address filterWindow.btcNode=Filtered Bitcoin nodes (comma sep. addresses + port) filterWindow.preventPublicBtcNetwork=Prevent usage of public Bitcoin network filterWindow.disableDao=Disable DAO +filterWindow.disableDaoBelowVersion=Min. version required for DAO filterWindow.add=Add filter filterWindow.remove=Remove filter diff --git a/core/src/test/java/bisq/core/user/UserPayloadModelVOTest.java b/core/src/test/java/bisq/core/user/UserPayloadModelVOTest.java index 1bed53d8cfb..8896703d7a6 100644 --- a/core/src/test/java/bisq/core/user/UserPayloadModelVOTest.java +++ b/core/src/test/java/bisq/core/user/UserPayloadModelVOTest.java @@ -43,7 +43,7 @@ public void testRoundtripFull() { vo.setDisplayedAlert(new Alert("message", true, "version", new byte[]{12, -64, 12}, "string", null)); vo.setDevelopersFilter(new Filter(Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList(), - false, Lists.newArrayList(), false, "string", new byte[]{10, 0, 0}, null)); + false, Lists.newArrayList(), false, null, "string", new byte[]{10, 0, 0}, null)); vo.setRegisteredArbitrator(ArbitratorTest.getArbitratorMock()); vo.setRegisteredMediator(MediatorTest.getMediatorMock()); vo.setAcceptedArbitrators(Lists.newArrayList(ArbitratorTest.getArbitratorMock())); diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/FilterWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/FilterWindow.java index 8ced3df8888..0f89e8e0001 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/FilterWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/FilterWindow.java @@ -141,6 +141,7 @@ private void addContent() { InputTextField btcNodesInputTextField = addInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.btcNode")); CheckBox preventPublicBtcNetworkCheckBox = addLabelCheckBox(gridPane, ++rowIndex, Res.get("filterWindow.preventPublicBtcNetwork")); CheckBox disableDaoCheckBox = addLabelCheckBox(gridPane, ++rowIndex, Res.get("filterWindow.disableDao")); + InputTextField disableDaoBelowVersionInputTextField = addInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.disableDaoBelowVersion")); final Filter filter = filterManager.getDevelopersFilter(); if (filter != null) { @@ -182,6 +183,7 @@ private void addContent() { preventPublicBtcNetworkCheckBox.setSelected(filter.isPreventPublicBtcNetwork()); disableDaoCheckBox.setSelected(filter.isDisableDao()); + disableDaoBelowVersionInputTextField.setText(filter.getDisableDaoBelowVersion()); } Button sendButton = new AutoTooltipButton(Res.get("filterWindow.add")); sendButton.setOnAction(e -> { @@ -267,7 +269,8 @@ private void addContent() { priceRelayNodes, preventPublicBtcNetworkCheckBox.isSelected(), btcNodes, - disableDaoCheckBox.isSelected()), + disableDaoCheckBox.isSelected(), + disableDaoBelowVersionInputTextField.getText()), keyInputTextField.getText())) hide(); else