From 707b36739fe9c6c41846488cea0137ddffa606f4 Mon Sep 17 00:00:00 2001 From: HenrikJannsen Date: Mon, 30 Sep 2024 19:10:35 +0700 Subject: [PATCH] Use the 30k min required reputation score for backward compatibility. In case a 2.1.1 user makes a buy offer, the min req. score is 30k, protecting the maker from pre 2.1.1 user with lower score. For 2.1.1 takers its ignored. --- .../bisq/offer/bisq_easy/BisqEasyOffer.java | 5 ++++- .../bisq/offer/options/OfferOptionUtil.java | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/offer/src/main/java/bisq/offer/bisq_easy/BisqEasyOffer.java b/offer/src/main/java/bisq/offer/bisq_easy/BisqEasyOffer.java index 52f0fbcc01..a77a1d568b 100644 --- a/offer/src/main/java/bisq/offer/bisq_easy/BisqEasyOffer.java +++ b/offer/src/main/java/bisq/offer/bisq_easy/BisqEasyOffer.java @@ -60,6 +60,9 @@ public BisqEasyOffer(NetworkId makerNetworkId, List fiatPaymentMethods, String makersTradeTerms, List supportedLanguageCodes) { + // We use the default SettingsService.DEFAULT_MIN_REQUIRED_REPUTATION_SCORE (as we don't have the dependency + // to settings we use the plain value) so that offers from makers on 2.1.1 can only be taken by v2.1.0 takers with + // 30k reputation score. This can be removed once there are no pre-2.1.1 users anymore. this(StringUtils.createUid(), System.currentTimeMillis(), makerNetworkId, @@ -70,7 +73,7 @@ public BisqEasyOffer(NetworkId makerNetworkId, List.of(TradeProtocolType.BISQ_EASY), PaymentMethodSpecUtil.createBitcoinPaymentMethodSpecs(bitcoinPaymentMethods), PaymentMethodSpecUtil.createFiatPaymentMethodSpecs(fiatPaymentMethods), - OfferOptionUtil.fromTradeTerms(makersTradeTerms), + OfferOptionUtil.fromTradeTermsAndReputationScore(makersTradeTerms, 30_000), supportedLanguageCodes ); } diff --git a/offer/src/main/java/bisq/offer/options/OfferOptionUtil.java b/offer/src/main/java/bisq/offer/options/OfferOptionUtil.java index 1789124866..0c609e00c2 100644 --- a/offer/src/main/java/bisq/offer/options/OfferOptionUtil.java +++ b/offer/src/main/java/bisq/offer/options/OfferOptionUtil.java @@ -25,6 +25,17 @@ import java.util.Optional; public class OfferOptionUtil { + public static List fromTradeTermsAndReputationScore(String makersTradeTerms, long requiredTotalReputationScore) { + List offerOptions = new ArrayList<>(); + if (makersTradeTerms != null && !makersTradeTerms.isEmpty()) { + offerOptions.add(new TradeTermsOption(makersTradeTerms)); + } + if (requiredTotalReputationScore > 0) { + offerOptions.add(new ReputationOption(requiredTotalReputationScore)); + } + return offerOptions; + } + public static List fromTradeTerms(String makersTradeTerms) { List offerOptions = new ArrayList<>(); if (makersTradeTerms != null && !makersTradeTerms.isEmpty()) { @@ -40,6 +51,13 @@ public static Optional findTradeTermsOption(Collection findReputationOption(Collection offerOptions) { + return offerOptions.stream() + .filter(option -> option instanceof ReputationOption) + .map(option -> (ReputationOption) option) + .findAny(); + } + public static Optional findCollateralOption(Collection offerOptions) { return offerOptions.stream() .filter(option -> option instanceof CollateralOption)