Skip to content

Commit

Permalink
Use the 30k min required reputation score for backward compatibility.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
HenrikJannsen committed Sep 30, 2024
1 parent e1515ff commit 707b367
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
5 changes: 4 additions & 1 deletion offer/src/main/java/bisq/offer/bisq_easy/BisqEasyOffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public BisqEasyOffer(NetworkId makerNetworkId,
List<FiatPaymentMethod> fiatPaymentMethods,
String makersTradeTerms,
List<String> 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,
Expand All @@ -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
);
}
Expand Down
18 changes: 18 additions & 0 deletions offer/src/main/java/bisq/offer/options/OfferOptionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@
import java.util.Optional;

public class OfferOptionUtil {
public static List<OfferOption> fromTradeTermsAndReputationScore(String makersTradeTerms, long requiredTotalReputationScore) {
List<OfferOption> 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<OfferOption> fromTradeTerms(String makersTradeTerms) {
List<OfferOption> offerOptions = new ArrayList<>();
if (makersTradeTerms != null && !makersTradeTerms.isEmpty()) {
Expand All @@ -40,6 +51,13 @@ public static Optional<TradeTermsOption> findTradeTermsOption(Collection<OfferOp
.findAny();
}

public static Optional<ReputationOption> findReputationOption(Collection<OfferOption> offerOptions) {
return offerOptions.stream()
.filter(option -> option instanceof ReputationOption)
.map(option -> (ReputationOption) option)
.findAny();
}

public static Optional<CollateralOption> findCollateralOption(Collection<OfferOption> offerOptions) {
return offerOptions.stream()
.filter(option -> option instanceof CollateralOption)
Expand Down

0 comments on commit 707b367

Please sign in to comment.