From 01355fdc54996bcf479b6a9047a6bb54a51c56a8 Mon Sep 17 00:00:00 2001 From: HenrikJannsen Date: Fri, 7 Jun 2024 18:11:23 +0700 Subject: [PATCH] Add addedBtcNodes and addedSeedNodes fields to Filter. Signed-off-by: HenrikJannsen --- .../main/java/bisq/core/filter/Filter.java | 36 +++++++++++++++---- .../java/bisq/core/filter/FilterManager.java | 6 ++++ .../resources/i18n/displayStrings.properties | 4 ++- .../main/overlays/windows/FilterWindow.java | 14 ++++++-- proto/src/main/proto/pb.proto | 2 ++ 5 files changed, 51 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/bisq/core/filter/Filter.java b/core/src/main/java/bisq/core/filter/Filter.java index 3cd45bb55c..069cc91dbf 100644 --- a/core/src/main/java/bisq/core/filter/Filter.java +++ b/core/src/main/java/bisq/core/filter/Filter.java @@ -123,6 +123,10 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload { // Added at v1.9.13 private final List delayedPayoutPaymentAccounts; + // Added at v 1.9.16 + private final List addedBtcNodes; + private final List addedSeedNodes; + // After we have created the signature from the filter data we clone it and apply the signature static Filter cloneWithSig(Filter filter, String signatureAsBase64) { return new Filter(filter.getBannedOfferIds(), @@ -160,7 +164,9 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload { filter.getTakerFeeBtc(), filter.getMakerFeeBsq(), filter.getTakerFeeBsq(), - filter.getDelayedPayoutPaymentAccounts()); + filter.getDelayedPayoutPaymentAccounts(), + filter.getAddedBtcNodes(), + filter.getAddedSeedNodes()); } // Used for signature verification as we created the sig without the signatureAsBase64 field we set it to null again @@ -200,7 +206,9 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload { filter.getTakerFeeBtc(), filter.getMakerFeeBsq(), filter.getTakerFeeBsq(), - filter.getDelayedPayoutPaymentAccounts()); + filter.getDelayedPayoutPaymentAccounts(), + filter.getAddedBtcNodes(), + filter.getAddedSeedNodes()); } public Filter(List bannedOfferIds, @@ -235,7 +243,9 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload { long takerFeeBtc, long makerFeeBsq, long takerFeeBsq, - List delayedPayoutPaymentAccounts) { + List delayedPayoutPaymentAccounts, + List addedBtcNodes, + List addedSeedNodes) { this(bannedOfferIds, nodeAddressesBannedFromTrading, bannedPaymentAccounts, @@ -271,7 +281,9 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload { takerFeeBtc, makerFeeBsq, takerFeeBsq, - delayedPayoutPaymentAccounts); + delayedPayoutPaymentAccounts, + addedBtcNodes, + addedSeedNodes); } @@ -315,7 +327,9 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload { long takerFeeBtc, long makerFeeBsq, long takerFeeBsq, - List delayedPayoutPaymentAccounts) { + List delayedPayoutPaymentAccounts, + List addedBtcNodes, + List addedSeedNodes) { this.bannedOfferIds = bannedOfferIds; this.nodeAddressesBannedFromTrading = nodeAddressesBannedFromTrading; this.bannedPaymentAccounts = bannedPaymentAccounts; @@ -352,6 +366,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload { this.makerFeeBsq = makerFeeBsq; this.takerFeeBsq = takerFeeBsq; this.delayedPayoutPaymentAccounts = delayedPayoutPaymentAccounts; + this.addedBtcNodes = addedBtcNodes; + this.addedSeedNodes = addedSeedNodes; // ownerPubKeyBytes can be null when called from tests if (ownerPubKeyBytes != null) { @@ -403,7 +419,9 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload { .setTakerFeeBtc(takerFeeBtc) .setMakerFeeBsq(makerFeeBsq) .setTakerFeeBsq(takerFeeBsq) - .addAllDelayedPayoutPaymentAccounts(delayedPayoutPaymentAccountList); + .addAllDelayedPayoutPaymentAccounts(delayedPayoutPaymentAccountList) + .addAllAddedBtcNodes(addedBtcNodes) + .addAllAddedSeedNodes(addedSeedNodes); Optional.ofNullable(signatureAsBase64).ifPresent(builder::setSignatureAsBase64); Optional.ofNullable(extraDataMap).ifPresent(builder::putAllExtraData); @@ -454,7 +472,9 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload { proto.getTakerFeeBtc(), proto.getMakerFeeBsq(), proto.getTakerFeeBsq(), - delayedPayoutPaymentAccounts + delayedPayoutPaymentAccounts, + ProtoUtil.protocolStringListToList(proto.getAddedBtcNodesList()), + ProtoUtil.protocolStringListToList(proto.getAddedSeedNodesList()) ); } @@ -512,6 +532,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload { ",\n takerFeeBtc=" + takerFeeBtc + ",\n makerFeeBsq=" + makerFeeBsq + ",\n takerFeeBsq=" + takerFeeBsq + + ",\n addedBtcNodes=" + addedBtcNodes + + ",\n addedSeedNodes=" + addedSeedNodes + "\n}"; } } diff --git a/core/src/main/java/bisq/core/filter/FilterManager.java b/core/src/main/java/bisq/core/filter/FilterManager.java index 6384e2c659..8d531fe530 100644 --- a/core/src/main/java/bisq/core/filter/FilterManager.java +++ b/core/src/main/java/bisq/core/filter/FilterManager.java @@ -85,6 +85,8 @@ public class FilterManager { private static final String BANNED_PRICE_RELAY_NODES = "bannedPriceRelayNodes"; private static final String BANNED_SEED_NODES = "bannedSeedNodes"; private static final String BANNED_BTC_NODES = "bannedBtcNodes"; + private static final String FILTER_PROVIDED_SEED_NODES = "filterProvidedSeedNodes"; + private static final String FILTER_PROVIDED_BTC_NODES = "filterProvidedBtcNodes"; /////////////////////////////////////////////////////////////////////////////////////////// // Listener @@ -570,6 +572,8 @@ public class FilterManager { // We persist it to the property file which is read before any other initialisation. saveBannedNodes(BANNED_SEED_NODES, newFilter.getSeedNodes()); saveBannedNodes(BANNED_BTC_NODES, newFilter.getBtcNodes()); + saveBannedNodes(FILTER_PROVIDED_BTC_NODES, newFilter.getAddedBtcNodes()); + saveBannedNodes(FILTER_PROVIDED_SEED_NODES, newFilter.getAddedSeedNodes()); // Banned price relay nodes we can apply at runtime List priceRelayNodes = newFilter.getPriceRelayNodes(); @@ -614,7 +618,9 @@ public class FilterManager { // Clears options files from banned nodes private void clearBannedNodes() { saveBannedNodes(BANNED_BTC_NODES, null); + saveBannedNodes(FILTER_PROVIDED_BTC_NODES, null); saveBannedNodes(BANNED_SEED_NODES, null); + saveBannedNodes(FILTER_PROVIDED_SEED_NODES, null); saveBannedNodes(BANNED_PRICE_RELAY_NODES, null); if (providersRepository.getBannedNodes() != null) { diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 05d2b5f666..6c74cb1a5f 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -3057,8 +3057,10 @@ filterWindow.arbitrators=Filtered arbitrators (comma sep. onion addresses) filterWindow.mediators=Filtered mediators (comma sep. onion addresses) filterWindow.refundAgents=Filtered refund agents (comma sep. onion addresses) filterWindow.seedNode=Filtered seed nodes (comma sep. onion addresses) +filterWindow.addedSeedNodes=Added Seed nodes (comma sep. addresses + port) filterWindow.priceRelayNode=Filtered price relay nodes (comma sep. onion addresses) -filterWindow.btcNode=Filtered Bitcoin nodes (comma sep. addresses + port) +filterWindow.btcNode=Banned Bitcoin nodes (comma sep. addresses + port) +filterWindow.addedBtcNodes=Added Bitcoin nodes (comma sep. addresses + port) filterWindow.preventPublicBtcNetwork=Prevent usage of public Bitcoin network filterWindow.disableDao=Disable DAO filterWindow.disableAutoConf=Disable auto-confirm 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 d89a94e250..c997271d66 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 @@ -168,12 +168,16 @@ public class FilterWindow extends Overlay { Res.get("filterWindow.btcFeeReceiverAddresses")); InputTextField seedNodesTF = addInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.seedNode")); + InputTextField addedSeedNodesTF = addInputTextField(gridPane, ++rowIndex, + Res.get("filterWindow.addedSeedNodes")); InputTextField priceRelayNodesTF = addInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.priceRelayNode")); InputTextField btcNodesTF = addInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.btcNode")); + InputTextField addedBtcNodesTF = addInputTextField(gridPane, ++rowIndex, + Res.get("filterWindow.addedBtcNodes")); CheckBox preventPublicBtcNetworkCheckBox = addLabelCheckBox(gridPane, ++rowIndex, - Res.get("filterWindow.preventPublicBtcNetwork")); + Res.get("filterWindow.preventPublicBtcNetwork"), 15); CheckBox disableDaoCheckBox = addLabelCheckBox(gridPane, ++rowIndex, Res.get("filterWindow.disableDao")); CheckBox disableAutoConfCheckBox = addLabelCheckBox(gridPane, ++rowIndex, @@ -187,7 +191,7 @@ public class FilterWindow extends Overlay { InputTextField autoConfExplorersTF = addTopLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.autoConfExplorers")).second; CheckBox disableMempoolValidationCheckBox = addLabelCheckBox(gridPane, ++rowIndex, - Res.get("filterWindow.disableMempoolValidation")); + Res.get("filterWindow.disableMempoolValidation"), 15); CheckBox disableApiCheckBox = addLabelCheckBox(gridPane, ++rowIndex, Res.get("filterWindow.disableApi")); CheckBox disablePowMessage = addLabelCheckBox(gridPane, ++rowIndex, @@ -220,8 +224,10 @@ public class FilterWindow extends Overlay { setupFieldFromList(refundAgentsTF, filter.getRefundAgents()); setupFieldFromList(btcFeeReceiverAddressesTF, filter.getBtcFeeReceiverAddresses()); setupFieldFromList(seedNodesTF, filter.getSeedNodes()); + setupFieldFromList(addedSeedNodesTF, filter.getAddedSeedNodes()); setupFieldFromList(priceRelayNodesTF, filter.getPriceRelayNodes()); setupFieldFromList(btcNodesTF, filter.getBtcNodes()); + setupFieldFromList(addedBtcNodesTF, filter.getAddedBtcNodes()); setupFieldFromList(bannedPrivilegedDevPubKeysTF, filter.getBannedPrivilegedDevPubKeys()); setupFieldFromList(autoConfExplorersTF, filter.getBannedAutoConfExplorers()); setupFieldFromList(enabledPowVersionsTF, filter.getEnabledPowVersions()); @@ -284,7 +290,9 @@ public class FilterWindow extends Overlay { ParsingUtils.parseToCoin(takerFeeBtcTF.getText(), btcFormatter).value, ParsingUtils.parseToCoin(makerFeeBsqTF.getText(), bsqFormatter).value, ParsingUtils.parseToCoin(takerFeeBsqTF.getText(), bsqFormatter).value, - readAsPaymentAccountFiltersList(delayedPayoutTF) + readAsPaymentAccountFiltersList(delayedPayoutTF), + readAsList(addedBtcNodesTF), + readAsList(addedSeedNodesTF) ); // We remove first the old filter diff --git a/proto/src/main/proto/pb.proto b/proto/src/main/proto/pb.proto index cef0de17ee..f5be6a1f66 100644 --- a/proto/src/main/proto/pb.proto +++ b/proto/src/main/proto/pb.proto @@ -767,6 +767,8 @@ message Filter { int64 taker_fee_bsq = 34; repeated int32 enabled_pow_versions = 35; repeated PaymentAccountFilter delayedPayoutPaymentAccounts = 36; + repeated string addedBtcNodes = 37; + repeated string addedSeedNodes = 38; } /* Deprecated */