From b39cdbab1ff620708c962607034701413a9ab685 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Thu, 19 Mar 2020 09:38:19 +0100 Subject: [PATCH 1/3] Improve messaging layout --- .../main/overlays/windows/SendPrivateNotificationWindow.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/SendPrivateNotificationWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/SendPrivateNotificationWindow.java index 521cca97dc7..c47ad17bb45 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/SendPrivateNotificationWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/SendPrivateNotificationWindow.java @@ -42,6 +42,7 @@ import javafx.scene.layout.HBox; import javafx.geometry.Insets; +import javafx.geometry.Pos; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -145,8 +146,10 @@ public void onFault(String errorMessage) { HBox hBox = new HBox(); hBox.setSpacing(10); + hBox.setAlignment(Pos.CENTER_RIGHT); GridPane.setRowIndex(hBox, ++rowIndex); - GridPane.setColumnIndex(hBox, 1); + GridPane.setColumnSpan(hBox, 2); + GridPane.setColumnIndex(hBox, 0); hBox.getChildren().addAll(sendButton, closeButton); gridPane.getChildren().add(hBox); GridPane.setMargin(hBox, new Insets(10, 0, 0, 0)); From a859c7485d602c12d7b7407e07d99c507529caba Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Thu, 19 Mar 2020 09:39:00 +0100 Subject: [PATCH 2/3] Default in case unknown payment methods to high risk and log an error --- .../main/java/bisq/core/payment/payload/PaymentMethod.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java b/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java index a1935faf16b..0b77c461d90 100644 --- a/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java +++ b/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java @@ -302,8 +302,10 @@ else if (maxTradeLimit == DEFAULT_TRADE_LIMIT_MID_RISK.value) riskFactor = 4; else if (maxTradeLimit == DEFAULT_TRADE_LIMIT_HIGH_RISK.value) riskFactor = 8; - else - throw new RuntimeException("maxTradeLimit is not matching one of our default values. maxTradeLimit=" + Coin.valueOf(maxTradeLimit).toFriendlyString()); + else { + riskFactor = 8; + log.error("maxTradeLimit is not matching one of our default values. maxTradeLimit=" + Coin.valueOf(maxTradeLimit).toFriendlyString()); + } TradeLimits tradeLimits = TradeLimits.getINSTANCE(); checkNotNull(tradeLimits, "tradeLimits must not be null"); From 290bd6ed42a6279f9206be5ba0105295d843d962 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Thu, 19 Mar 2020 10:10:01 +0100 Subject: [PATCH 3/3] Filter out banned offers completely to prevent any unexpected error by offer misconfigurations --- .../desktop/main/offer/offerbook/OfferBook.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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 99670bac962..8bc0d091c80 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 @@ -17,6 +17,7 @@ package bisq.desktop.main.offer.offerbook; +import bisq.core.filter.FilterManager; import bisq.core.offer.Offer; import bisq.core.offer.OfferBookService; import bisq.core.trade.TradeManager; @@ -37,7 +38,7 @@ import static bisq.core.offer.OfferPayload.Direction.BUY; /** - * Holds and manages the unsorted and unfiltered offerbook list of both buy and sell offers. + * Holds and manages the unsorted and unfiltered offerbook list (except for banned offers) of both buy and sell offers. * It is handled as singleton by Guice and is used by 2 instances of OfferBookDataModel (one for Buy one for Sell). * As it is used only by the Buy and Sell UIs we treat it as local UI model. * It also use OfferRepository.Listener as the lists items class and we don't want to get any dependency out of the @@ -50,21 +51,30 @@ public class OfferBook { private final ObservableList offerBookListItems = FXCollections.observableArrayList(); private final Map buyOfferCountMap = new HashMap<>(); private final Map sellOfferCountMap = new HashMap<>(); + private final FilterManager filterManager; /////////////////////////////////////////////////////////////////////////////////////////// // Constructor /////////////////////////////////////////////////////////////////////////////////////////// @Inject - OfferBook(OfferBookService offerBookService, TradeManager tradeManager) { + OfferBook(OfferBookService offerBookService, TradeManager tradeManager, FilterManager filterManager) { this.offerBookService = offerBookService; + this.filterManager = filterManager; offerBookService.addOfferBookChangedListener(new OfferBookService.OfferBookChangedListener() { @Override public void onAdded(Offer offer) { // We get onAdded called every time a new ProtectedStorageEntry is received. // Mostly it is the same OfferPayload but the ProtectedStorageEntry is different. - // We filter here to only add new offers if the same offer (using equals) was not already added. + // We filter here to only add new offers if the same offer (using equals) was not already added and it + // is not banned. + + if (filterManager.isOfferIdBanned(offer.getId())) { + log.debug("Ignored banned offer. ID={}", offer.getId()); + return; + } + boolean hasSameOffer = offerBookListItems.stream() .anyMatch(item -> item.getOffer().equals(offer)); if (!hasSameOffer) { @@ -112,6 +122,7 @@ public void fillOfferBookListItems() { // Investigate why.... offerBookListItems.clear(); offerBookListItems.addAll(offerBookService.getOffers().stream() + .filter(o -> !filterManager.isOfferIdBanned(o.getId())) .map(OfferBookListItem::new) .collect(Collectors.toList()));