mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
Add delayedPayoutPaymentAccounts to Filter
Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
parent
364e0c47aa
commit
91a70d89a4
4 changed files with 53 additions and 10 deletions
|
@ -120,6 +120,9 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
|
||||||
private final long makerFeeBsq;
|
private final long makerFeeBsq;
|
||||||
private final long takerFeeBsq;
|
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
|
// After we have created the signature from the filter data we clone it and apply the signature
|
||||||
static Filter cloneWithSig(Filter filter, String signatureAsBase64) {
|
static Filter cloneWithSig(Filter filter, String signatureAsBase64) {
|
||||||
return new Filter(filter.getBannedOfferIds(),
|
return new Filter(filter.getBannedOfferIds(),
|
||||||
|
@ -156,7 +159,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
|
||||||
filter.getMakerFeeBtc(),
|
filter.getMakerFeeBtc(),
|
||||||
filter.getTakerFeeBtc(),
|
filter.getTakerFeeBtc(),
|
||||||
filter.getMakerFeeBsq(),
|
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
|
// 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.getMakerFeeBtc(),
|
||||||
filter.getTakerFeeBtc(),
|
filter.getTakerFeeBtc(),
|
||||||
filter.getMakerFeeBsq(),
|
filter.getMakerFeeBsq(),
|
||||||
filter.getTakerFeeBsq());
|
filter.getTakerFeeBsq(),
|
||||||
|
filter.getDelayedPayoutPaymentAccounts());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Filter(List<String> bannedOfferIds,
|
public Filter(List<String> bannedOfferIds,
|
||||||
|
@ -229,7 +234,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
|
||||||
long makerFeeBtc,
|
long makerFeeBtc,
|
||||||
long takerFeeBtc,
|
long takerFeeBtc,
|
||||||
long makerFeeBsq,
|
long makerFeeBsq,
|
||||||
long takerFeeBsq) {
|
long takerFeeBsq,
|
||||||
|
List<PaymentAccountFilter> delayedPayoutPaymentAccounts) {
|
||||||
this(bannedOfferIds,
|
this(bannedOfferIds,
|
||||||
nodeAddressesBannedFromTrading,
|
nodeAddressesBannedFromTrading,
|
||||||
bannedPaymentAccounts,
|
bannedPaymentAccounts,
|
||||||
|
@ -264,7 +270,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
|
||||||
makerFeeBtc,
|
makerFeeBtc,
|
||||||
takerFeeBtc,
|
takerFeeBtc,
|
||||||
makerFeeBsq,
|
makerFeeBsq,
|
||||||
takerFeeBsq);
|
takerFeeBsq,
|
||||||
|
delayedPayoutPaymentAccounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -307,7 +314,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
|
||||||
long makerFeeBtc,
|
long makerFeeBtc,
|
||||||
long takerFeeBtc,
|
long takerFeeBtc,
|
||||||
long makerFeeBsq,
|
long makerFeeBsq,
|
||||||
long takerFeeBsq) {
|
long takerFeeBsq,
|
||||||
|
List<PaymentAccountFilter> delayedPayoutPaymentAccounts) {
|
||||||
this.bannedOfferIds = bannedOfferIds;
|
this.bannedOfferIds = bannedOfferIds;
|
||||||
this.nodeAddressesBannedFromTrading = nodeAddressesBannedFromTrading;
|
this.nodeAddressesBannedFromTrading = nodeAddressesBannedFromTrading;
|
||||||
this.bannedPaymentAccounts = bannedPaymentAccounts;
|
this.bannedPaymentAccounts = bannedPaymentAccounts;
|
||||||
|
@ -343,6 +351,7 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
|
||||||
this.takerFeeBtc = takerFeeBtc;
|
this.takerFeeBtc = takerFeeBtc;
|
||||||
this.makerFeeBsq = makerFeeBsq;
|
this.makerFeeBsq = makerFeeBsq;
|
||||||
this.takerFeeBsq = takerFeeBsq;
|
this.takerFeeBsq = takerFeeBsq;
|
||||||
|
this.delayedPayoutPaymentAccounts = delayedPayoutPaymentAccounts;
|
||||||
|
|
||||||
// ownerPubKeyBytes can be null when called from tests
|
// ownerPubKeyBytes can be null when called from tests
|
||||||
if (ownerPubKeyBytes != null) {
|
if (ownerPubKeyBytes != null) {
|
||||||
|
@ -357,6 +366,9 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
|
||||||
List<protobuf.PaymentAccountFilter> paymentAccountFilterList = bannedPaymentAccounts.stream()
|
List<protobuf.PaymentAccountFilter> paymentAccountFilterList = bannedPaymentAccounts.stream()
|
||||||
.map(PaymentAccountFilter::toProtoMessage)
|
.map(PaymentAccountFilter::toProtoMessage)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
List<protobuf.PaymentAccountFilter> delayedPayoutPaymentAccountList = delayedPayoutPaymentAccounts.stream()
|
||||||
|
.map(PaymentAccountFilter::toProtoMessage)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
protobuf.Filter.Builder builder = protobuf.Filter.newBuilder().addAllBannedOfferIds(bannedOfferIds)
|
protobuf.Filter.Builder builder = protobuf.Filter.newBuilder().addAllBannedOfferIds(bannedOfferIds)
|
||||||
.addAllNodeAddressesBannedFromTrading(nodeAddressesBannedFromTrading)
|
.addAllNodeAddressesBannedFromTrading(nodeAddressesBannedFromTrading)
|
||||||
|
@ -390,7 +402,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
|
||||||
.setMakerFeeBtc(makerFeeBtc)
|
.setMakerFeeBtc(makerFeeBtc)
|
||||||
.setTakerFeeBtc(takerFeeBtc)
|
.setTakerFeeBtc(takerFeeBtc)
|
||||||
.setMakerFeeBsq(makerFeeBsq)
|
.setMakerFeeBsq(makerFeeBsq)
|
||||||
.setTakerFeeBsq(takerFeeBsq);
|
.setTakerFeeBsq(takerFeeBsq)
|
||||||
|
.addAllDelayedPayoutPaymentAccounts(delayedPayoutPaymentAccountList);
|
||||||
|
|
||||||
Optional.ofNullable(signatureAsBase64).ifPresent(builder::setSignatureAsBase64);
|
Optional.ofNullable(signatureAsBase64).ifPresent(builder::setSignatureAsBase64);
|
||||||
Optional.ofNullable(extraDataMap).ifPresent(builder::putAllExtraData);
|
Optional.ofNullable(extraDataMap).ifPresent(builder::putAllExtraData);
|
||||||
|
@ -402,6 +415,9 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
|
||||||
List<PaymentAccountFilter> bannedPaymentAccountsList = proto.getBannedPaymentAccountsList().stream()
|
List<PaymentAccountFilter> bannedPaymentAccountsList = proto.getBannedPaymentAccountsList().stream()
|
||||||
.map(PaymentAccountFilter::fromProto)
|
.map(PaymentAccountFilter::fromProto)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
List<PaymentAccountFilter> delayedPayoutPaymentAccounts = proto.getDelayedPayoutPaymentAccountsList().stream()
|
||||||
|
.map(PaymentAccountFilter::fromProto)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
return new Filter(ProtoUtil.protocolStringListToList(proto.getBannedOfferIdsList()),
|
return new Filter(ProtoUtil.protocolStringListToList(proto.getBannedOfferIdsList()),
|
||||||
ProtoUtil.protocolStringListToList(proto.getNodeAddressesBannedFromTradingList()),
|
ProtoUtil.protocolStringListToList(proto.getNodeAddressesBannedFromTradingList()),
|
||||||
|
@ -437,7 +453,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
|
||||||
proto.getMakerFeeBtc(),
|
proto.getMakerFeeBtc(),
|
||||||
proto.getTakerFeeBtc(),
|
proto.getTakerFeeBtc(),
|
||||||
proto.getMakerFeeBsq(),
|
proto.getMakerFeeBsq(),
|
||||||
proto.getTakerFeeBsq()
|
proto.getTakerFeeBsq(),
|
||||||
|
delayedPayoutPaymentAccounts
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -463,8 +463,25 @@ public class FilterManager {
|
||||||
return getFilter() != null &&
|
return getFilter() != null &&
|
||||||
paymentAccountPayload != null &&
|
paymentAccountPayload != null &&
|
||||||
getFilter().getBannedPaymentAccounts().stream()
|
getFilter().getBannedPaymentAccounts().stream()
|
||||||
.filter(paymentAccountFilter -> paymentAccountFilter.getPaymentMethodId().equals(
|
.filter(paymentAccountFilter -> paymentAccountFilter.getPaymentMethodId().equals(paymentAccountPayload.getPaymentMethodId()))
|
||||||
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 -> {
|
.anyMatch(paymentAccountFilter -> {
|
||||||
try {
|
try {
|
||||||
Method method = paymentAccountPayload.getClass().getMethod(paymentAccountFilter.getGetMethodName());
|
Method method = paymentAccountPayload.getClass().getMethod(paymentAccountFilter.getGetMethodName());
|
||||||
|
|
|
@ -144,6 +144,12 @@ public class FilterWindow extends Overlay<FilterWindow> {
|
||||||
Res.get("filterWindow.accounts")).second;
|
Res.get("filterWindow.accounts")).second;
|
||||||
GridPane.setHalignment(paymentAccountFilterTF, HPos.RIGHT);
|
GridPane.setHalignment(paymentAccountFilterTF, HPos.RIGHT);
|
||||||
paymentAccountFilterTF.setPromptText("E.g. PERFECT_MONEY|getAccountNr|12345"); // Do not translate
|
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,
|
InputTextField bannedCurrenciesTF = addInputTextField(gridPane, ++rowIndex,
|
||||||
Res.get("filterWindow.bannedCurrencies"));
|
Res.get("filterWindow.bannedCurrencies"));
|
||||||
InputTextField bannedPaymentMethodsTF = addTopLabelInputTextField(gridPane, ++rowIndex,
|
InputTextField bannedPaymentMethodsTF = addTopLabelInputTextField(gridPane, ++rowIndex,
|
||||||
|
@ -234,6 +240,7 @@ public class FilterWindow extends Overlay<FilterWindow> {
|
||||||
takerFeeBtcTF.setText(btcFormatter.formatCoin(Coin.valueOf(filter.getTakerFeeBtc())));
|
takerFeeBtcTF.setText(btcFormatter.formatCoin(Coin.valueOf(filter.getTakerFeeBtc())));
|
||||||
makerFeeBsqTF.setText(bsqFormatter.formatBSQSatoshis(filter.getMakerFeeBsq()));
|
makerFeeBsqTF.setText(bsqFormatter.formatBSQSatoshis(filter.getMakerFeeBsq()));
|
||||||
takerFeeBsqTF.setText(bsqFormatter.formatBSQSatoshis(filter.getTakerFeeBsq()));
|
takerFeeBsqTF.setText(bsqFormatter.formatBSQSatoshis(filter.getTakerFeeBsq()));
|
||||||
|
setupFieldFromPaymentAccountFiltersList(delayedPayoutTF, filter.getDelayedPayoutPaymentAccounts());
|
||||||
}
|
}
|
||||||
|
|
||||||
Button removeFilterMessageButton = new AutoTooltipButton(Res.get("filterWindow.remove"));
|
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(makerFeeBtcTF.getText(), btcFormatter).value,
|
||||||
ParsingUtils.parseToCoin(takerFeeBtcTF.getText(), btcFormatter).value,
|
ParsingUtils.parseToCoin(takerFeeBtcTF.getText(), btcFormatter).value,
|
||||||
ParsingUtils.parseToCoin(makerFeeBsqTF.getText(), bsqFormatter).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
|
// We remove first the old filter
|
||||||
|
|
|
@ -766,6 +766,7 @@ message Filter {
|
||||||
int64 maker_fee_bsq = 33;
|
int64 maker_fee_bsq = 33;
|
||||||
int64 taker_fee_bsq = 34;
|
int64 taker_fee_bsq = 34;
|
||||||
repeated int32 enabled_pow_versions = 35;
|
repeated int32 enabled_pow_versions = 35;
|
||||||
|
repeated PaymentAccountFilter delayedPayoutPaymentAccounts = 36;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Deprecated */
|
/* Deprecated */
|
||||||
|
|
Loading…
Add table
Reference in a new issue