Add delayedPayoutPaymentAccounts to Filter

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
HenrikJannsen 2023-10-08 16:14:34 +07:00 committed by Alejandro García
parent 27b7401da8
commit 57ef8bedc7
No known key found for this signature in database
GPG Key ID: F806F422E222AA02
4 changed files with 53 additions and 10 deletions

View File

@ -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<PaymentAccountFilter> 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<String> bannedOfferIds,
@ -229,7 +234,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
long makerFeeBtc,
long takerFeeBtc,
long makerFeeBsq,
long takerFeeBsq) {
long takerFeeBsq,
List<PaymentAccountFilter> 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<PaymentAccountFilter> 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<protobuf.PaymentAccountFilter> paymentAccountFilterList = bannedPaymentAccounts.stream()
.map(PaymentAccountFilter::toProtoMessage)
.collect(Collectors.toList());
List<protobuf.PaymentAccountFilter> 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<PaymentAccountFilter> bannedPaymentAccountsList = proto.getBannedPaymentAccountsList().stream()
.map(PaymentAccountFilter::fromProto)
.collect(Collectors.toList());
List<PaymentAccountFilter> 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
);
}

View File

@ -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());

View File

@ -144,6 +144,12 @@ public class FilterWindow extends Overlay<FilterWindow> {
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<FilterWindow> {
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<FilterWindow> {
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

View File

@ -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 */