From f08c2036a7ed66e8888e566a00b6f190d3d0d0f3 Mon Sep 17 00:00:00 2001 From: woodser Date: Thu, 18 Nov 2021 15:37:33 -0500 Subject: [PATCH] api returns offers for unconfigured payment method --- .../main/java/bisq/core/api/CoreOffersService.java | 11 +++++++++-- core/src/main/java/bisq/core/offer/OfferFilter.java | 6 +++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/bisq/core/api/CoreOffersService.java b/core/src/main/java/bisq/core/api/CoreOffersService.java index 6fc3bb6e..5f417ef1 100644 --- a/core/src/main/java/bisq/core/api/CoreOffersService.java +++ b/core/src/main/java/bisq/core/api/CoreOffersService.java @@ -24,6 +24,7 @@ import bisq.core.offer.CreateOfferService; import bisq.core.offer.Offer; import bisq.core.offer.OfferBookService; import bisq.core.offer.OfferFilter; +import bisq.core.offer.OfferFilter.Result; import bisq.core.offer.OfferUtil; import bisq.core.offer.OpenOffer; import bisq.core.offer.OpenOfferManager; @@ -110,7 +111,10 @@ class CoreOffersService { return offerBookService.getOffers().stream() .filter(o -> o.getId().equals(id)) .filter(o -> !o.isMyOffer(keyRing)) - .filter(o -> offerFilter.canTakeOffer(o, coreContext.isApiUser()).isValid()) + .filter(o -> { + Result result = offerFilter.canTakeOffer(o, coreContext.isApiUser()); + return result.isValid() || result == Result.HAS_NO_PAYMENT_ACCOUNT_VALID_FOR_OFFER; + }) .findAny().orElseThrow(() -> new IllegalStateException(format("offer with id '%s' not found", id))); } @@ -127,7 +131,10 @@ class CoreOffersService { List offers = offerBookService.getOffers().stream() .filter(o -> !o.isMyOffer(keyRing)) .filter(o -> offerMatchesDirectionAndCurrency(o, direction, currencyCode)) - .filter(o -> offerFilter.canTakeOffer(o, coreContext.isApiUser()).isValid()) + .filter(o -> { + Result result = offerFilter.canTakeOffer(o, coreContext.isApiUser()); + return result.isValid() || result == Result.HAS_NO_PAYMENT_ACCOUNT_VALID_FOR_OFFER; + }) .sorted(priceComparator(direction)) .collect(Collectors.toList()); offers.removeAll(getUnreservedOffers(offers)); diff --git a/core/src/main/java/bisq/core/offer/OfferFilter.java b/core/src/main/java/bisq/core/offer/OfferFilter.java index 466f0216..8a7385ab 100644 --- a/core/src/main/java/bisq/core/offer/OfferFilter.java +++ b/core/src/main/java/bisq/core/offer/OfferFilter.java @@ -101,9 +101,6 @@ public class OfferFilter { if (isTakerApiUser && filterManager.getFilter() != null && filterManager.getFilter().isDisableApi()) { return Result.API_DISABLED; } - if (!isAnyPaymentAccountValidForOffer(offer)) { - return Result.HAS_NO_PAYMENT_ACCOUNT_VALID_FOR_OFFER; - } if (!hasSameProtocolVersion(offer)) { return Result.HAS_NOT_SAME_PROTOCOL_VERSION; } @@ -134,6 +131,9 @@ public class OfferFilter { if (!hasValidSignature(offer)) { return Result.SIGNATURE_NOT_VALIDATED; // TODO (woodser): handle this wherever IS_MY_INSUFFICIENT_TRADE_LIMIT is handled } + if (!isAnyPaymentAccountValidForOffer(offer)) { + return Result.HAS_NO_PAYMENT_ACCOUNT_VALID_FOR_OFFER; + } return Result.VALID; }