use of bisq.core.filter.PaymentAccountFilter in project bisq-desktop by bisq-network.
the class FilterWindow method addContent.
private void addContent() {
InputTextField keyInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("shared.unlock"), 10).second;
if (useDevPrivilegeKeys)
keyInputTextField.setText(DevEnv.DEV_PRIVILEGE_PRIV_KEY);
InputTextField offerIdsInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.offers")).second;
InputTextField nodesInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.onions")).second;
// Do not translate
nodesInputTextField.setPromptText("E.g. zqnzx6o3nifef5df.onion:9999");
InputTextField paymentAccountFilterInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.accounts")).second;
GridPane.setHalignment(paymentAccountFilterInputTextField, HPos.RIGHT);
// Do not translate
paymentAccountFilterInputTextField.setPromptText("E.g. PERFECT_MONEY|getAccountNr|12345");
InputTextField bannedCurrenciesInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.bannedCurrencies")).second;
InputTextField bannedPaymentMethodsInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.bannedPaymentMethods")).second;
// Do not translate
bannedPaymentMethodsInputTextField.setPromptText("E.g. PERFECT_MONEY");
InputTextField arbitratorsInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.arbitrators")).second;
InputTextField seedNodesInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.seedNode")).second;
InputTextField priceRelayNodesInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.priceRelayNode")).second;
InputTextField btcNodesInputTextField = addLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.btcNode")).second;
CheckBox preventPublicBtcNetworkCheckBox = addLabelCheckBox(gridPane, ++rowIndex, Res.get("filterWindow.preventPublicBtcNetwork")).second;
final Filter filter = filterManager.getDevelopersFilter();
if (filter != null) {
offerIdsInputTextField.setText(filter.getBannedOfferIds().stream().collect(Collectors.joining(", ")));
nodesInputTextField.setText(filter.getBannedNodeAddress().stream().collect(Collectors.joining(", ")));
if (filter.getBannedPaymentAccounts() != null) {
StringBuilder sb = new StringBuilder();
filter.getBannedPaymentAccounts().stream().forEach(e -> {
if (e != null && e.getPaymentMethodId() != null) {
sb.append(e.getPaymentMethodId()).append("|").append(e.getGetMethodName()).append("|").append(e.getValue()).append(", ");
}
});
paymentAccountFilterInputTextField.setText(sb.toString());
}
if (filter.getBannedCurrencies() != null)
bannedCurrenciesInputTextField.setText(filter.getBannedCurrencies().stream().collect(Collectors.joining(", ")));
if (filter.getBannedPaymentMethods() != null)
bannedPaymentMethodsInputTextField.setText(filter.getBannedPaymentMethods().stream().collect(Collectors.joining(", ")));
if (filter.getArbitrators() != null)
arbitratorsInputTextField.setText(filter.getArbitrators().stream().collect(Collectors.joining(", ")));
if (filter.getSeedNodes() != null)
seedNodesInputTextField.setText(filter.getSeedNodes().stream().collect(Collectors.joining(", ")));
if (filter.getPriceRelayNodes() != null)
priceRelayNodesInputTextField.setText(filter.getPriceRelayNodes().stream().collect(Collectors.joining(", ")));
if (filter.getBtcNodes() != null)
btcNodesInputTextField.setText(filter.getBtcNodes().stream().collect(Collectors.joining(", ")));
preventPublicBtcNetworkCheckBox.setSelected(filter.isPreventPublicBtcNetwork());
}
Button sendButton = new AutoTooltipButton(Res.get("filterWindow.add"));
sendButton.setOnAction(e -> {
List<String> offerIds = new ArrayList<>();
List<String> nodes = new ArrayList<>();
List<PaymentAccountFilter> paymentAccountFilters = new ArrayList<>();
List<String> bannedCurrencies = new ArrayList<>();
List<String> bannedPaymentMethods = new ArrayList<>();
List<String> arbitrators = new ArrayList<>();
List<String> seedNodes = new ArrayList<>();
List<String> priceRelayNodes = new ArrayList<>();
List<String> btcNodes = new ArrayList<>();
if (!offerIdsInputTextField.getText().isEmpty()) {
offerIds = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(offerIdsInputTextField.getText()).split(",")));
}
if (!nodesInputTextField.getText().isEmpty()) {
nodes = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(nodesInputTextField.getText()).replace(":9999", "").replace(".onion", "").split(",")));
}
if (!paymentAccountFilterInputTextField.getText().isEmpty()) {
paymentAccountFilters = new ArrayList<>(Arrays.asList(paymentAccountFilterInputTextField.getText().replace(", ", ",").split(",")).stream().map(item -> {
String[] list = item.split("\\|");
if (list.length == 3)
return new PaymentAccountFilter(list[0], list[1], list[2]);
else
return new PaymentAccountFilter("", "", "");
}).collect(Collectors.toList()));
}
if (!bannedCurrenciesInputTextField.getText().isEmpty()) {
bannedCurrencies = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(bannedCurrenciesInputTextField.getText()).split(",")));
}
if (!bannedPaymentMethodsInputTextField.getText().isEmpty()) {
bannedPaymentMethods = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(bannedPaymentMethodsInputTextField.getText()).split(",")));
}
if (!arbitratorsInputTextField.getText().isEmpty()) {
arbitrators = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(arbitratorsInputTextField.getText()).replace(":9999", "").replace(".onion", "").split(",")));
}
if (!seedNodesInputTextField.getText().isEmpty()) {
seedNodes = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(seedNodesInputTextField.getText()).replace(":9999", "").replace(".onion", "").split(",")));
}
if (!priceRelayNodesInputTextField.getText().isEmpty()) {
priceRelayNodes = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(priceRelayNodesInputTextField.getText()).replace(":9999", "").replace(".onion", "").split(",")));
}
if (!btcNodesInputTextField.getText().isEmpty()) {
btcNodes = new ArrayList<>(Arrays.asList(StringUtils.deleteWhitespace(btcNodesInputTextField.getText()).split(",")));
}
if (sendFilterMessageHandler.handle(new Filter(offerIds, nodes, paymentAccountFilters, bannedCurrencies, bannedPaymentMethods, arbitrators, seedNodes, priceRelayNodes, preventPublicBtcNetworkCheckBox.isSelected(), btcNodes), keyInputTextField.getText()))
hide();
else
new Popup<>().warning(Res.get("shared.invalidKey")).width(300).onClose(this::blurAgain).show();
});
Button removeFilterMessageButton = new AutoTooltipButton(Res.get("filterWindow.remove"));
removeFilterMessageButton.setOnAction(e -> {
if (keyInputTextField.getText().length() > 0) {
if (removeFilterMessageHandler.handle(keyInputTextField.getText()))
hide();
else
new Popup<>().warning(Res.get("shared.invalidKey")).width(300).onClose(this::blurAgain).show();
}
});
closeButton = new AutoTooltipButton(Res.get("shared.close"));
closeButton.setOnAction(e -> {
hide();
closeHandlerOptional.ifPresent(Runnable::run);
});
HBox hBox = new HBox();
hBox.setSpacing(10);
GridPane.setRowIndex(hBox, ++rowIndex);
GridPane.setColumnIndex(hBox, 1);
hBox.getChildren().addAll(sendButton, removeFilterMessageButton, closeButton);
gridPane.getChildren().add(hBox);
GridPane.setMargin(hBox, new Insets(10, 0, 0, 0));
}
use of bisq.core.filter.PaymentAccountFilter in project bisq-core by bisq-network.
the class CheckIfPeerIsBanned method run.
@Override
protected void run() {
try {
runInterceptHook();
final NodeAddress nodeAddress = processModel.getTempTradingPeerNodeAddress();
PaymentAccountPayload paymentAccountPayload = checkNotNull(processModel.getTradingPeer().getPaymentAccountPayload());
final PaymentAccountFilter[] appliedPaymentAccountFilter = new PaymentAccountFilter[1];
if (nodeAddress != null && processModel.getFilterManager().isNodeAddressBanned(nodeAddress)) {
failed("Other trader is banned by his node address.\n" + "tradingPeerNodeAddress=" + nodeAddress);
} else if (processModel.getFilterManager().isOfferIdBanned(trade.getId())) {
failed("Offer ID is banned.\n" + "Offer ID=" + trade.getId());
} else if (processModel.getFilterManager().isCurrencyBanned(trade.getOffer().getCurrencyCode())) {
failed("Currency is banned.\n" + "Currency code=" + trade.getOffer().getCurrencyCode());
} else if (processModel.getFilterManager().isPaymentMethodBanned(trade.getOffer().getPaymentMethod())) {
failed("Payment method is banned.\n" + "Payment method=" + trade.getOffer().getPaymentMethod().getId());
} else if (processModel.getFilterManager().isPeersPaymentAccountDataAreBanned(paymentAccountPayload, appliedPaymentAccountFilter)) {
failed("Other trader is banned by his trading account data.\n" + "paymentAccountPayload=" + paymentAccountPayload.getPaymentDetails() + "\n" + "banFilter=" + appliedPaymentAccountFilter[0].toString());
} else {
complete();
}
} catch (Throwable t) {
failed(t);
}
}
Aggregations