diff --git a/core/src/main/java/bisq/core/filter/Filter.java b/core/src/main/java/bisq/core/filter/Filter.java index 8eac477a52..3cd45bb55c 100644 --- a/core/src/main/java/bisq/core/filter/Filter.java +++ b/core/src/main/java/bisq/core/filter/Filter.java @@ -120,6 +120,9 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload { private final long makerFeeBsq; private final long takerFeeBsq; + // Added at v1.9.13 + private final List delayedPayoutPaymentAccounts; + // After we have created the signature from the filter data we clone it and apply the signature static Filter cloneWithSig(Filter filter, String signatureAsBase64) { return new Filter(filter.getBannedOfferIds(), @@ -156,7 +159,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload { filter.getMakerFeeBtc(), filter.getTakerFeeBtc(), filter.getMakerFeeBsq(), - filter.getTakerFeeBsq()); + filter.getTakerFeeBsq(), + filter.getDelayedPayoutPaymentAccounts()); } // Used for signature verification as we created the sig without the signatureAsBase64 field we set it to null again @@ -195,7 +199,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload { filter.getMakerFeeBtc(), filter.getTakerFeeBtc(), filter.getMakerFeeBsq(), - filter.getTakerFeeBsq()); + filter.getTakerFeeBsq(), + filter.getDelayedPayoutPaymentAccounts()); } public Filter(List bannedOfferIds, @@ -229,7 +234,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload { long makerFeeBtc, long takerFeeBtc, long makerFeeBsq, - long takerFeeBsq) { + long takerFeeBsq, + List delayedPayoutPaymentAccounts) { this(bannedOfferIds, nodeAddressesBannedFromTrading, bannedPaymentAccounts, @@ -264,7 +270,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload { makerFeeBtc, takerFeeBtc, makerFeeBsq, - takerFeeBsq); + takerFeeBsq, + delayedPayoutPaymentAccounts); } @@ -307,7 +314,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload { long makerFeeBtc, long takerFeeBtc, long makerFeeBsq, - long takerFeeBsq) { + long takerFeeBsq, + List delayedPayoutPaymentAccounts) { this.bannedOfferIds = bannedOfferIds; this.nodeAddressesBannedFromTrading = nodeAddressesBannedFromTrading; this.bannedPaymentAccounts = bannedPaymentAccounts; @@ -343,6 +351,7 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload { this.takerFeeBtc = takerFeeBtc; this.makerFeeBsq = makerFeeBsq; this.takerFeeBsq = takerFeeBsq; + this.delayedPayoutPaymentAccounts = delayedPayoutPaymentAccounts; // ownerPubKeyBytes can be null when called from tests if (ownerPubKeyBytes != null) { @@ -357,6 +366,9 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload { List paymentAccountFilterList = bannedPaymentAccounts.stream() .map(PaymentAccountFilter::toProtoMessage) .collect(Collectors.toList()); + List delayedPayoutPaymentAccountList = delayedPayoutPaymentAccounts.stream() + .map(PaymentAccountFilter::toProtoMessage) + .collect(Collectors.toList()); protobuf.Filter.Builder builder = protobuf.Filter.newBuilder().addAllBannedOfferIds(bannedOfferIds) .addAllNodeAddressesBannedFromTrading(nodeAddressesBannedFromTrading) @@ -390,7 +402,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload { .setMakerFeeBtc(makerFeeBtc) .setTakerFeeBtc(takerFeeBtc) .setMakerFeeBsq(makerFeeBsq) - .setTakerFeeBsq(takerFeeBsq); + .setTakerFeeBsq(takerFeeBsq) + .addAllDelayedPayoutPaymentAccounts(delayedPayoutPaymentAccountList); Optional.ofNullable(signatureAsBase64).ifPresent(builder::setSignatureAsBase64); Optional.ofNullable(extraDataMap).ifPresent(builder::putAllExtraData); @@ -402,6 +415,9 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload { List bannedPaymentAccountsList = proto.getBannedPaymentAccountsList().stream() .map(PaymentAccountFilter::fromProto) .collect(Collectors.toList()); + List delayedPayoutPaymentAccounts = proto.getDelayedPayoutPaymentAccountsList().stream() + .map(PaymentAccountFilter::fromProto) + .collect(Collectors.toList()); return new Filter(ProtoUtil.protocolStringListToList(proto.getBannedOfferIdsList()), ProtoUtil.protocolStringListToList(proto.getNodeAddressesBannedFromTradingList()), @@ -437,7 +453,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload { proto.getMakerFeeBtc(), proto.getTakerFeeBtc(), proto.getMakerFeeBsq(), - proto.getTakerFeeBsq() + proto.getTakerFeeBsq(), + delayedPayoutPaymentAccounts ); } diff --git a/core/src/main/java/bisq/core/filter/FilterManager.java b/core/src/main/java/bisq/core/filter/FilterManager.java index 82750b7519..68bdefd1d8 100644 --- a/core/src/main/java/bisq/core/filter/FilterManager.java +++ b/core/src/main/java/bisq/core/filter/FilterManager.java @@ -463,8 +463,25 @@ public class FilterManager { return getFilter() != null && paymentAccountPayload != null && getFilter().getBannedPaymentAccounts().stream() - .filter(paymentAccountFilter -> paymentAccountFilter.getPaymentMethodId().equals( - paymentAccountPayload.getPaymentMethodId())) + .filter(paymentAccountFilter -> paymentAccountFilter.getPaymentMethodId().equals(paymentAccountPayload.getPaymentMethodId())) + .anyMatch(paymentAccountFilter -> { + try { + Method method = paymentAccountPayload.getClass().getMethod(paymentAccountFilter.getGetMethodName()); + // We invoke getter methods (no args), e.g. getHolderName + String valueFromInvoke = (String) method.invoke(paymentAccountPayload); + return valueFromInvoke.equalsIgnoreCase(paymentAccountFilter.getValue()); + } catch (Throwable e) { + log.error(e.getMessage()); + return false; + } + }); + } + + public boolean isDelayedPayoutPaymentAccount(PaymentAccountPayload paymentAccountPayload) { + return getFilter() != null && + paymentAccountPayload != null && + getFilter().getDelayedPayoutPaymentAccounts().stream() + .filter(paymentAccountFilter -> paymentAccountFilter.getPaymentMethodId().equals(paymentAccountPayload.getPaymentMethodId())) .anyMatch(paymentAccountFilter -> { try { Method method = paymentAccountPayload.getClass().getMethod(paymentAccountFilter.getGetMethodName()); diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/FilterWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/FilterWindow.java index 240e128575..f33429fba2 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/FilterWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/FilterWindow.java @@ -144,6 +144,12 @@ public class FilterWindow extends Overlay { Res.get("filterWindow.accounts")).second; GridPane.setHalignment(paymentAccountFilterTF, HPos.RIGHT); paymentAccountFilterTF.setPromptText("E.g. PERFECT_MONEY|getAccountNr|12345"); // Do not translate + + InputTextField delayedPayoutTF = addTopLabelInputTextField(gridPane, ++rowIndex, + Res.get("filterWindow.delayedPayout")).second; + GridPane.setHalignment(delayedPayoutTF, HPos.RIGHT); + delayedPayoutTF.setPromptText("E.g. SEPA|getBic|COBADEH077X"); // Do not translate + InputTextField bannedCurrenciesTF = addInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.bannedCurrencies")); InputTextField bannedPaymentMethodsTF = addTopLabelInputTextField(gridPane, ++rowIndex, @@ -234,6 +240,7 @@ public class FilterWindow extends Overlay { takerFeeBtcTF.setText(btcFormatter.formatCoin(Coin.valueOf(filter.getTakerFeeBtc()))); makerFeeBsqTF.setText(bsqFormatter.formatBSQSatoshis(filter.getMakerFeeBsq())); takerFeeBsqTF.setText(bsqFormatter.formatBSQSatoshis(filter.getTakerFeeBsq())); + setupFieldFromPaymentAccountFiltersList(delayedPayoutTF, filter.getDelayedPayoutPaymentAccounts()); } Button removeFilterMessageButton = new AutoTooltipButton(Res.get("filterWindow.remove")); @@ -276,7 +283,8 @@ public class FilterWindow extends Overlay { ParsingUtils.parseToCoin(makerFeeBtcTF.getText(), btcFormatter).value, ParsingUtils.parseToCoin(takerFeeBtcTF.getText(), btcFormatter).value, ParsingUtils.parseToCoin(makerFeeBsqTF.getText(), bsqFormatter).value, - ParsingUtils.parseToCoin(takerFeeBsqTF.getText(), bsqFormatter).value + ParsingUtils.parseToCoin(takerFeeBsqTF.getText(), bsqFormatter).value, + readAsPaymentAccountFiltersList(delayedPayoutTF) ); // We remove first the old filter diff --git a/proto/src/main/proto/pb.proto b/proto/src/main/proto/pb.proto index f6a8dd2499..14154cc954 100644 --- a/proto/src/main/proto/pb.proto +++ b/proto/src/main/proto/pb.proto @@ -766,6 +766,7 @@ message Filter { int64 maker_fee_bsq = 33; int64 taker_fee_bsq = 34; repeated int32 enabled_pow_versions = 35; + repeated PaymentAccountFilter delayedPayoutPaymentAccounts = 36; } /* Deprecated */