diff --git a/core/src/main/java/bisq/core/filter/Filter.java b/core/src/main/java/bisq/core/filter/Filter.java index 2461dd0179..5e97b91cdd 100644 --- a/core/src/main/java/bisq/core/filter/Filter.java +++ b/core/src/main/java/bisq/core/filter/Filter.java @@ -37,6 +37,7 @@ import com.google.common.annotations.VisibleForTesting; import java.security.PublicKey; +import java.util.Date; import java.util.List; import java.util.Map; import java.util.Optional; @@ -532,7 +533,9 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload, @Override public String toString() { return "Filter{" + - "\n bannedOfferIds=" + bannedOfferIds + + "\n creationDate=" + creationDate + " (" + new Date(creationDate) + ")" + + ",\n uid=" + uid + + ",\n bannedOfferIds=" + bannedOfferIds + ",\n nodeAddressesBannedFromTrading=" + nodeAddressesBannedFromTrading + ",\n bannedAutoConfExplorers=" + bannedAutoConfExplorers + ",\n bannedPaymentAccounts=" + bannedPaymentAccounts + @@ -553,7 +556,6 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload, ",\n refundAgents=" + refundAgents + ",\n bannedAccountWitnessSignerPubKeys=" + bannedAccountWitnessSignerPubKeys + ",\n btcFeeReceiverAddresses=" + btcFeeReceiverAddresses + - ",\n creationDate=" + creationDate + ",\n bannedPrivilegedDevPubKeys=" + bannedPrivilegedDevPubKeys + ",\n extraDataMap=" + extraDataMap + ",\n ownerPubKey=" + ownerPubKey + @@ -570,7 +572,6 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload, ",\n takerFeeBsq=" + takerFeeBsq + ",\n addedBtcNodes=" + addedBtcNodes + ",\n addedSeedNodes=" + addedSeedNodes + - ",\n uid=" + uid + "\n}"; } } diff --git a/core/src/main/java/bisq/core/filter/FilterManager.java b/core/src/main/java/bisq/core/filter/FilterManager.java index c0fb5bae85..25c4d36354 100644 --- a/core/src/main/java/bisq/core/filter/FilterManager.java +++ b/core/src/main/java/bisq/core/filter/FilterManager.java @@ -361,7 +361,7 @@ public class FilterManager { setFilterSigningKey(privKeyString); Filter filterWithSig = user.getDevelopersFilter(); if (filterWithSig == null) { - // Should not happen as UI button is deactivated in that case + log.warn("removeDevFilter: filterWithSig == null. Should not happen as UI button is deactivated in that case"); return; } @@ -525,37 +525,40 @@ public class FilterManager { // Private /////////////////////////////////////////////////////////////////////////////////////////// - private void onFilterAddedFromNetwork(Filter newFilter) { + private void onFilterAddedFromNetwork(Filter filterFromNetwork) { Filter currentFilter = getFilter(); - if (!isFilterPublicKeyInList(newFilter)) { - if (newFilter.getSignerPubKeyAsHex() != null && !newFilter.getSignerPubKeyAsHex().isEmpty()) { - log.warn("isFilterPublicKeyInList failed. Filter.getSignerPubKeyAsHex={}", newFilter.getSignerPubKeyAsHex()); + if (!isFilterPublicKeyInList(filterFromNetwork)) { + if (filterFromNetwork.getSignerPubKeyAsHex() != null && !filterFromNetwork.getSignerPubKeyAsHex().isEmpty()) { + log.warn("isFilterPublicKeyInList failed. filterFromNetwork.getSignerPubKeyAsHex={}", filterFromNetwork.getSignerPubKeyAsHex()); } else { - log.info("isFilterPublicKeyInList failed. Filter.getSignerPubKeyAsHex not set (expected case for pre v1.3.9 filter)"); + log.info("isFilterPublicKeyInList failed. filterFromNetwork.getSignerPubKeyAsHex not set (expected case for pre v1.3.9 filter)"); } return; } - if (!isSignatureValid(newFilter)) { - log.warn("verifySignature failed. Filter={}", newFilter); + if (!isSignatureValid(filterFromNetwork)) { + log.warn("verifySignature failed. filterFromNetwork={}", filterFromNetwork); return; } if (currentFilter != null) { - if (currentFilter.getCreationDate() > newFilter.getCreationDate()) { + if (currentFilter.getCreationDate() > filterFromNetwork.getCreationDate()) { log.info("We received a new filter from the network but the creation date is older than the " + - "filter we have already. We ignore the new filter."); + "filter we have already. We ignore the new filter from the network.\n" + + "currentFilter\n{}" + + "filterFromNetwork\n{}", + currentFilter, filterFromNetwork); - addToInvalidFilters(newFilter); + addToInvalidFilters(filterFromNetwork); return; } - if (isPrivilegedDevPubKeyBanned(newFilter.getSignerPubKeyAsHex())) { - log.warn("Pub key of filter is banned. currentFilter={}, newFilter={}", currentFilter, newFilter); + if (isPrivilegedDevPubKeyBanned(filterFromNetwork.getSignerPubKeyAsHex())) { + log.warn("Pub key of filter is banned. currentFilter={}, filterFromNetwork={}", currentFilter, filterFromNetwork); return; } else { log.info("We received a new filter with a newer creation date and the signer is not banned. " + - "We ignore the old filter."); + "We ignore the current (older) filter."); addToInvalidFilters(currentFilter); } @@ -565,30 +568,30 @@ public class FilterManager { // We do not require strict guarantees here (e.g. clocks not synced) as only trusted developers have the key // for deploying filters and this is only in place to avoid unintended situations of multiple filters // from multiple devs or if same dev publishes new filter from different app without the persisted devFilter. - filterProperty.set(newFilter); + filterProperty.set(filterFromNetwork); // Seed nodes are requested at startup before we get the filter so we only apply the banned // nodes at the next startup and don't update the list in the P2P network domain. // 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()); + saveBannedNodes(BANNED_SEED_NODES, filterFromNetwork.getSeedNodes()); + saveBannedNodes(BANNED_BTC_NODES, filterFromNetwork.getBtcNodes()); + saveBannedNodes(FILTER_PROVIDED_BTC_NODES, filterFromNetwork.getAddedBtcNodes()); + saveBannedNodes(FILTER_PROVIDED_SEED_NODES, filterFromNetwork.getAddedSeedNodes()); // Banned price relay nodes we can apply at runtime - List priceRelayNodes = newFilter.getPriceRelayNodes(); + List priceRelayNodes = filterFromNetwork.getPriceRelayNodes(); saveBannedNodes(BANNED_PRICE_RELAY_NODES, priceRelayNodes); //TODO should be moved to client with listening on onFilterAdded providersRepository.applyBannedNodes(priceRelayNodes); //TODO should be moved to client with listening on onFilterAdded - if (newFilter.isPreventPublicBtcNetwork() && + if (filterFromNetwork.isPreventPublicBtcNetwork() && preferences.getBitcoinNodesOptionOrdinal() == BtcNodes.BitcoinNodesOption.PUBLIC.ordinal()) { preferences.setBitcoinNodesOptionOrdinal(BtcNodes.BitcoinNodesOption.PROVIDED.ordinal()); } - listeners.forEach(e -> e.onFilterAdded(newFilter)); + listeners.forEach(e -> e.onFilterAdded(filterFromNetwork)); } private void onFilterRemovedFromNetwork(Filter filter) {