From faeb9ca8db5feeb020132933b366851eaba125c9 Mon Sep 17 00:00:00 2001 From: woodser Date: Thu, 16 Jun 2022 18:58:27 -0400 Subject: [PATCH] refactor payment account form api to support structured, dynamic forms --- .../payment/AbstractPaymentAccountTest.java | 11 +- .../bisq/apitest/scenario/bot/BotClient.java | 3 +- .../bot/BotPaymentAccountGenerator.java | 5 +- cli/src/main/java/bisq/cli/GrpcClient.java | 1 + .../PaymentAccountsServiceRequest.java | 8 +- core/src/main/java/bisq/core/api/CoreApi.java | 14 +- .../core/api/CorePaymentAccountsService.java | 51 ++- .../core/api/model/PaymentAccountForm.java | 267 ++++++------ .../api/model/PaymentAccountFormField.java | 170 ++++++++ .../api/model/PaymentAccountTypeAdapter.java | 28 +- .../java/bisq/core/locale/CountryUtil.java | 32 +- .../bisq/core/payment/AchTransferAccount.java | 9 + .../core/payment/AdvancedCashAccount.java | 7 + .../java/bisq/core/payment/AliPayAccount.java | 6 + .../core/payment/AmazonGiftCardAccount.java | 9 +- .../core/payment/AustraliaPayidAccount.java | 6 + .../java/bisq/core/payment/BizumAccount.java | 9 + .../bisq/core/payment/CapitualAccount.java | 7 + .../bisq/core/payment/CashAppAccount.java | 6 + .../bisq/core/payment/CashByMailAccount.java | 6 + .../bisq/core/payment/CashDepositAccount.java | 6 + .../java/bisq/core/payment/CelPayAccount.java | 12 +- .../core/payment/ChaseQuickPayAccount.java | 6 + .../core/payment/ClearXchangeAccount.java | 13 + .../payment/CountryBasedPaymentAccount.java | 25 +- .../core/payment/CryptoCurrencyAccount.java | 6 + .../payment/DomesticWireTransferAccount.java | 9 + .../java/bisq/core/payment/F2FAccount.java | 27 +- .../core/payment/FasterPaymentsAccount.java | 6 + .../bisq/core/payment/HalCashAccount.java | 6 + .../bisq/core/payment/IfscBasedAccount.java | 6 + .../java/bisq/core/payment/ImpsAccount.java | 9 + .../payment/InstantCryptoCurrencyAccount.java | 6 + .../core/payment/InteracETransferAccount.java | 9 +- .../bisq/core/payment/JapanBankAccount.java | 6 + .../bisq/core/payment}/JapanBankData.java | 17 +- .../java/bisq/core/payment/MoneseAccount.java | 9 + .../bisq/core/payment/MoneyBeamAccount.java | 6 + .../bisq/core/payment/MoneyGramAccount.java | 9 +- .../core/payment/NationalBankAccount.java | 6 + .../java/bisq/core/payment/NequiAccount.java | 9 + .../java/bisq/core/payment/OKPayAccount.java | 9 +- .../java/bisq/core/payment/PaxumAccount.java | 9 +- .../bisq/core/payment/PaymentAccount.java | 408 +++++++++++++++++- .../bisq/core/payment/PayseraAccount.java | 9 +- .../core/payment/PerfectMoneyAccount.java | 6 + .../java/bisq/core/payment/PixAccount.java | 9 + .../bisq/core/payment/PopmoneyAccount.java | 6 + .../bisq/core/payment/PromptPayAccount.java | 6 + .../bisq/core/payment/RevolutAccount.java | 23 +- .../bisq/core/payment/SameBankAccount.java | 6 + .../bisq/core/payment/SatispayAccount.java | 9 + .../java/bisq/core/payment/SepaAccount.java | 60 ++- .../bisq/core/payment/SepaInstantAccount.java | 9 +- .../core/payment/SpecificBanksAccount.java | 6 + .../java/bisq/core/payment/StrikeAccount.java | 32 +- .../java/bisq/core/payment/SwiftAccount.java | 30 ++ .../java/bisq/core/payment/SwishAccount.java | 6 + .../java/bisq/core/payment/TikkieAccount.java | 12 +- .../core/payment/TransferwiseAccount.java | 28 +- .../core/payment/TransferwiseUsdAccount.java | 12 +- .../payment/USPostalMoneyOrderAccount.java | 6 + .../java/bisq/core/payment/UpholdAccount.java | 9 +- .../java/bisq/core/payment/VenmoAccount.java | 6 + .../java/bisq/core/payment/VerseAccount.java | 9 + .../bisq/core/payment/WeChatPayAccount.java | 6 + .../core/payment/WesternUnionAccount.java | 6 + .../payload/AchTransferAccountPayload.java | 6 +- .../payment/payload/BankAccountPayload.java | 4 +- .../payment/payload/BizumAccountPayload.java | 6 +- .../payload/CashDepositAccountPayload.java | 6 +- .../CountryBasedPaymentAccountPayload.java | 11 +- .../DomesticWireTransferAccountPayload.java | 7 +- .../payment/payload/F2FAccountPayload.java | 6 +- .../payload/IfscBasedAccountPayload.java | 4 +- .../payment/payload/ImpsAccountPayload.java | 6 +- .../payload/NationalBankAccountPayload.java | 6 +- .../payment/payload/NeftAccountPayload.java | 6 +- .../payment/payload/NequiAccountPayload.java | 7 +- .../core/payment/payload/PaymentMethod.java | 15 +- .../payment/payload/PaytmAccountPayload.java | 6 +- .../payment/payload/PixAccountPayload.java | 6 +- .../payment/payload/RtgsAccountPayload.java | 6 +- .../payload/SameBankAccountPayload.java | 6 +- .../payload/SatispayAccountPayload.java | 7 +- .../payment/payload/SepaAccountPayload.java | 15 +- .../payload/SepaInstantAccountPayload.java | 10 +- .../payload/SpecificBanksAccountPayload.java | 4 + .../payment/payload/StrikeAccountPayload.java | 6 +- .../payment/payload/TikkieAccountPayload.java | 6 +- .../TransferwiseUsdAccountPayload.java | 6 +- .../payment/payload/UpiAccountPayload.java | 6 +- .../payload/WesternUnionAccountPayload.java | 6 +- .../validation/AccountNrValidator.java | 2 +- .../validation/AdvancedCashValidator.java | 2 +- .../payment}/validation/AliPayValidator.java | 2 +- .../AustraliaPayidAccountNameValidator.java | 2 +- .../validation/AustraliaPayidValidator.java | 2 +- .../payment}/validation/BICValidator.java | 2 +- .../payment}/validation/BankIdValidator.java | 2 +- .../payment}/validation/BankValidator.java | 2 +- .../validation/BranchIdValidator.java | 2 +- .../payment}/validation/BtcValidator.java | 2 +- .../validation/CapitualValidator.java | 2 +- .../validation/ChaseQuickPayValidator.java | 2 +- .../validation/CountryCallingCodes.java | 2 +- .../validation/EmailOrMobileNrValidator.java | 6 +- .../payment}/validation/EmailValidator.java | 2 +- .../payment}/validation/F2FValidator.java | 2 +- .../validation/FiatVolumeValidator.java | 6 +- .../payment}/validation/HalCashValidator.java | 2 +- .../payment}/validation/IBANValidator.java | 2 +- .../InteracETransferAnswerValidator.java | 2 +- .../InteracETransferQuestionValidator.java | 2 +- .../validation/InteracETransferValidator.java | 2 +- .../JapanBankAccountNameValidator.java | 5 +- .../JapanBankAccountNumberValidator.java | 4 +- .../JapanBankBranchCodeValidator.java | 4 +- .../JapanBankBranchNameValidator.java | 4 +- .../JapanBankTransferValidator.java | 2 +- .../payment}/validation/LengthValidator.java | 2 +- .../validation/MoneyBeamValidator.java | 2 +- .../NationalAccountIdValidator.java | 2 +- .../validation/PercentageNumberValidator.java | 2 +- .../validation/PerfectMoneyValidator.java | 2 +- .../validation/PhoneNumberValidator.java | 4 +- .../validation/PopmoneyValidator.java | 2 +- .../validation/PromptPayValidator.java | 2 +- .../payment}/validation/RevolutValidator.java | 2 +- .../validation/SecurityDepositValidator.java | 2 +- .../validation/SepaIBANValidator.java | 2 +- .../payment}/validation/SwishValidator.java | 2 +- .../validation/TransferwiseValidator.java | 2 +- .../USPostalMoneyOrderValidator.java | 2 +- .../payment}/validation/UpholdValidator.java | 2 +- .../validation/WeChatPayValidator.java | 2 +- .../util/validation/AltcoinValidator.java | 4 +- .../util/validation/FiatPriceValidator.java | 4 +- .../util/validation/MonetaryValidator.java | 4 +- .../grpc/GrpcPaymentAccountsService.java | 35 +- .../desktop/components/InputTextField.java | 4 +- .../paymentmethods/AdvancedCashForm.java | 3 +- .../components/paymentmethods/AliPayForm.java | 3 +- .../paymentmethods/AustraliaPayidForm.java | 3 +- .../paymentmethods/CapitualForm.java | 3 +- .../paymentmethods/CashDepositForm.java | 3 +- .../components/paymentmethods/CelPayForm.java | 3 +- .../paymentmethods/ChaseQuickPayForm.java | 3 +- .../paymentmethods/ClearXchangeForm.java | 7 +- .../components/paymentmethods/F2FForm.java | 3 +- .../paymentmethods/FasterPaymentsForm.java | 5 +- .../paymentmethods/GeneralBankForm.java | 9 +- .../paymentmethods/HalCashForm.java | 3 +- .../paymentmethods/InteracETransferForm.java | 3 +- .../paymentmethods/JapanBankTransferForm.java | 13 +- .../paymentmethods/MoneyBeamForm.java | 3 +- .../paymentmethods/MoneyGramForm.java | 5 +- .../components/paymentmethods/PaxumForm.java | 3 +- .../paymentmethods/PayseraForm.java | 3 +- .../paymentmethods/PerfectMoneyForm.java | 3 +- .../paymentmethods/PopmoneyForm.java | 3 +- .../paymentmethods/PromptPayForm.java | 3 +- .../paymentmethods/RevolutForm.java | 3 +- .../components/paymentmethods/SepaForm.java | 24 +- .../paymentmethods/SepaInstantForm.java | 5 +- .../components/paymentmethods/SwiftForm.java | 3 +- .../components/paymentmethods/SwishForm.java | 3 +- .../components/paymentmethods/TikkieForm.java | 3 +- .../paymentmethods/TransferwiseForm.java | 3 +- .../paymentmethods/TransferwiseUsdForm.java | 5 +- .../USPostalMoneyOrderForm.java | 3 +- .../components/paymentmethods/UpholdForm.java | 3 +- .../paymentmethods/WeChatPayForm.java | 3 +- .../paymentmethods/WesternUnionForm.java | 3 +- .../fiataccounts/FiatAccountsView.java | 51 ++- .../MobileNotificationsView.java | 3 +- .../content/password/PasswordView.java | 1 - .../main/offer/MutableOfferViewModel.java | 7 +- .../createoffer/CreateOfferViewModel.java | 7 +- .../offer/offerbook/OfferBookViewModel.java | 2 +- .../offer/takeoffer/TakeOfferViewModel.java | 3 +- .../windows/EditCustomExplorerWindow.java | 3 +- .../windows/ManualPayoutTxWindow.java | 4 +- .../windows/SignPaymentAccountsWindow.java | 2 +- .../windows/UpdateRevolutAccountWindow.java | 3 +- .../DuplicateOfferViewModel.java | 7 +- .../editoffer/EditOfferViewModel.java | 7 +- .../settings/preferences/PreferencesView.java | 3 +- .../createoffer/CreateOfferViewModelTest.java | 5 +- .../validation/AccountNrValidatorTest.java | 2 +- .../validation/AdvancedCashValidatorTest.java | 2 + .../validation/BranchIdValidatorTest.java | 2 +- .../util/validation/BtcValidatorTest.java | 1 + .../validation/CapitualValidatorTest.java | 1 + .../validation/FiatVolumeValidatorTest.java | 2 +- .../InteracETransferAnswerValidatorTest.java | 2 + ...InteracETransferQuestionValidatorTest.java | 2 + .../InteracETransferValidatorTest.java | 5 + .../util/validation/LengthValidatorTest.java | 2 +- .../NationalAccountIdValidatorTest.java | 2 +- .../validation/PhoneNumberValidatorTest.java | 1 + proto/src/main/proto/grpc.proto | 26 +- proto/src/main/proto/pb.proto | 111 ++++- 203 files changed, 1844 insertions(+), 509 deletions(-) create mode 100644 core/src/main/java/bisq/core/api/model/PaymentAccountFormField.java rename {desktop/src/main/java/bisq/desktop/components/paymentmethods/data => core/src/main/java/bisq/core/payment}/JapanBankData.java (99%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/AccountNrValidator.java (99%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/AdvancedCashValidator.java (96%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/AliPayValidator.java (97%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/AustraliaPayidAccountNameValidator.java (97%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/AustraliaPayidValidator.java (98%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/BICValidator.java (98%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/BankIdValidator.java (97%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/BankValidator.java (96%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/BranchIdValidator.java (98%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/BtcValidator.java (99%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/CapitualValidator.java (94%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/ChaseQuickPayValidator.java (97%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/CountryCallingCodes.java (99%) rename desktop/src/main/java/bisq/desktop/util/validation/ClearXchangeValidator.java => core/src/main/java/bisq/core/payment/validation/EmailOrMobileNrValidator.java (92%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/EmailValidator.java (99%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/F2FValidator.java (97%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/FiatVolumeValidator.java (91%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/HalCashValidator.java (97%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/IBANValidator.java (99%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/InteracETransferAnswerValidator.java (96%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/InteracETransferQuestionValidator.java (96%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/InteracETransferValidator.java (99%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/JapanBankAccountNameValidator.java (94%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/JapanBankAccountNumberValidator.java (93%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/JapanBankBranchCodeValidator.java (91%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/JapanBankBranchNameValidator.java (94%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/JapanBankTransferValidator.java (97%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/LengthValidator.java (96%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/MoneyBeamValidator.java (96%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/NationalAccountIdValidator.java (95%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/PercentageNumberValidator.java (98%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/PerfectMoneyValidator.java (97%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/PhoneNumberValidator.java (98%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/PopmoneyValidator.java (96%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/PromptPayValidator.java (96%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/RevolutValidator.java (97%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/SecurityDepositValidator.java (98%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/SepaIBANValidator.java (95%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/SwishValidator.java (97%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/TransferwiseValidator.java (97%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/USPostalMoneyOrderValidator.java (97%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/UpholdValidator.java (96%) rename {desktop/src/main/java/bisq/desktop/util => core/src/main/java/bisq/core/payment}/validation/WeChatPayValidator.java (96%) diff --git a/apitest/src/test/java/bisq/apitest/method/payment/AbstractPaymentAccountTest.java b/apitest/src/test/java/bisq/apitest/method/payment/AbstractPaymentAccountTest.java index d1aa90b3ad..544ac930fd 100644 --- a/apitest/src/test/java/bisq/apitest/method/payment/AbstractPaymentAccountTest.java +++ b/apitest/src/test/java/bisq/apitest/method/payment/AbstractPaymentAccountTest.java @@ -115,9 +115,6 @@ public class AbstractPaymentAccountTest extends MethodTest { static final Map COMPLETED_FORM_MAP = new HashMap<>(); - // A payment account serializer / deserializer. - static final PaymentAccountForm PAYMENT_ACCOUNT_FORM = new PaymentAccountForm(); - @BeforeEach public void setup() { Res.setup(); @@ -134,7 +131,7 @@ public class AbstractPaymentAccountTest extends MethodTest { // File emptyForm = PAYMENT_ACCOUNT_FORM.getPaymentAccountForm(paymentMethodId); log.debug("{} Empty form saved to {}", testName(testInfo), - PAYMENT_ACCOUNT_FORM.getClickableURI(emptyForm)); + PaymentAccountForm.getClickableURI(emptyForm)); emptyForm.deleteOnExit(); return emptyForm; } @@ -142,7 +139,7 @@ public class AbstractPaymentAccountTest extends MethodTest { protected final void verifyEmptyForm(File jsonForm, String paymentMethodId, String... fields) { @SuppressWarnings("unchecked") Map emptyForm = (Map) GSON.fromJson( - PAYMENT_ACCOUNT_FORM.toJsonString(jsonForm), + PaymentAccountForm.toJsonString(jsonForm), Object.class); assertNotNull(emptyForm); @@ -201,14 +198,14 @@ public class AbstractPaymentAccountTest extends MethodTest { protected final String getCompletedFormAsJsonString(List comments) { File completedForm = fillPaymentAccountForm(comments); - String jsonString = PAYMENT_ACCOUNT_FORM.toJsonString(completedForm); + String jsonString = PaymentAccountForm.toJsonString(completedForm); log.debug("Completed form: {}", jsonString); return jsonString; } protected final String getCompletedFormAsJsonString() { File completedForm = fillPaymentAccountForm(PROPERTY_VALUE_JSON_COMMENTS); - String jsonString = PAYMENT_ACCOUNT_FORM.toJsonString(completedForm); + String jsonString = PaymentAccountForm.toJsonString(completedForm); log.debug("Completed form: {}", jsonString); return jsonString; } diff --git a/apitest/src/test/java/bisq/apitest/scenario/bot/BotClient.java b/apitest/src/test/java/bisq/apitest/scenario/bot/BotClient.java index 046f3aaae0..6049f4b8db 100644 --- a/apitest/src/test/java/bisq/apitest/scenario/bot/BotClient.java +++ b/apitest/src/test/java/bisq/apitest/scenario/bot/BotClient.java @@ -36,11 +36,12 @@ import static org.apache.commons.lang3.StringUtils.capitalize; import bisq.cli.GrpcClient; +import bisq.core.api.model.PaymentAccountForm; /** * Convenience GrpcClient wrapper for bots using gRPC services. */ -@SuppressWarnings({"JavaDoc", "unused"}) +@SuppressWarnings({"unused"}) @Slf4j public class BotClient { diff --git a/apitest/src/test/java/bisq/apitest/scenario/bot/BotPaymentAccountGenerator.java b/apitest/src/test/java/bisq/apitest/scenario/bot/BotPaymentAccountGenerator.java index e586c3236a..f437a141ce 100644 --- a/apitest/src/test/java/bisq/apitest/scenario/bot/BotPaymentAccountGenerator.java +++ b/apitest/src/test/java/bisq/apitest/scenario/bot/BotPaymentAccountGenerator.java @@ -58,10 +58,9 @@ public class BotPaymentAccountGenerator { } private Map getPaymentAccountFormMap(String paymentMethodId) { - PaymentAccountForm paymentAccountForm = new PaymentAccountForm(); - File jsonFormTemplate = paymentAccountForm.getPaymentAccountForm(paymentMethodId); + File jsonFormTemplate = PaymentAccountForm.getPaymentAccountForm(paymentMethodId); jsonFormTemplate.deleteOnExit(); - String jsonString = paymentAccountForm.toJsonString(jsonFormTemplate); + String jsonString = PaymentAccountForm.toJsonString(jsonFormTemplate); //noinspection unchecked return (Map) gson.fromJson(jsonString, Object.class); } diff --git a/cli/src/main/java/bisq/cli/GrpcClient.java b/cli/src/main/java/bisq/cli/GrpcClient.java index cb1d3919b9..071e88fdbc 100644 --- a/cli/src/main/java/bisq/cli/GrpcClient.java +++ b/cli/src/main/java/bisq/cli/GrpcClient.java @@ -31,6 +31,7 @@ import bisq.proto.grpc.TxFeeRateInfo; import bisq.proto.grpc.TxInfo; import protobuf.PaymentAccount; +import protobuf.PaymentAccountForm; import protobuf.PaymentMethod; import java.util.List; diff --git a/cli/src/main/java/bisq/cli/request/PaymentAccountsServiceRequest.java b/cli/src/main/java/bisq/cli/request/PaymentAccountsServiceRequest.java index 709a765958..4fab133072 100644 --- a/cli/src/main/java/bisq/cli/request/PaymentAccountsServiceRequest.java +++ b/cli/src/main/java/bisq/cli/request/PaymentAccountsServiceRequest.java @@ -20,11 +20,13 @@ package bisq.cli.request; import bisq.proto.grpc.CreateCryptoCurrencyPaymentAccountRequest; import bisq.proto.grpc.CreatePaymentAccountRequest; import bisq.proto.grpc.GetCryptoCurrencyPaymentMethodsRequest; +import bisq.proto.grpc.GetPaymentAccountFormAsJsonRequest; import bisq.proto.grpc.GetPaymentAccountFormRequest; import bisq.proto.grpc.GetPaymentAccountsRequest; import bisq.proto.grpc.GetPaymentMethodsRequest; import protobuf.PaymentAccount; +import protobuf.PaymentAccountForm; import protobuf.PaymentMethod; import java.util.List; @@ -49,15 +51,15 @@ public class PaymentAccountsServiceRequest { } public String getPaymentAcctFormAsJson(String paymentMethodId) { - var request = GetPaymentAccountFormRequest.newBuilder() + var request = GetPaymentAccountFormAsJsonRequest.newBuilder() .setPaymentMethodId(paymentMethodId) .build(); - return grpcStubs.paymentAccountsService.getPaymentAccountForm(request).getPaymentAccountFormJson(); + return grpcStubs.paymentAccountsService.getPaymentAccountFormAsJson(request).getPaymentAccountFormAsJson(); } public PaymentAccount createPaymentAccount(String json) { var request = CreatePaymentAccountRequest.newBuilder() - .setPaymentAccountForm(json) + .setPaymentAccountFormAsJson(json) .build(); return grpcStubs.paymentAccountsService.createPaymentAccount(request).getPaymentAccount(); } diff --git a/core/src/main/java/bisq/core/api/CoreApi.java b/core/src/main/java/bisq/core/api/CoreApi.java index 3b2b67a6bd..3f84a620d2 100644 --- a/core/src/main/java/bisq/core/api/CoreApi.java +++ b/core/src/main/java/bisq/core/api/CoreApi.java @@ -21,6 +21,8 @@ import bisq.core.api.model.AddressBalanceInfo; import bisq.core.api.model.BalancesInfo; import bisq.core.api.model.MarketDepthInfo; import bisq.core.api.model.MarketPriceInfo; +import bisq.core.api.model.PaymentAccountForm; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.api.model.TxFeeRateInfo; import bisq.core.app.AppStartupState; import bisq.core.monetary.Price; @@ -488,8 +490,8 @@ public class CoreApi { // PaymentAccounts /////////////////////////////////////////////////////////////////////////////////////////// - public PaymentAccount createPaymentAccount(String jsonString) { - return paymentAccountsService.createPaymentAccount(jsonString); + public PaymentAccount createPaymentAccount(PaymentAccountForm form) { + return paymentAccountsService.createPaymentAccount(form); } public Set getPaymentAccounts() { @@ -500,8 +502,8 @@ public class CoreApi { return paymentAccountsService.getFiatPaymentMethods(); } - public String getPaymentAccountForm(String paymentMethodId) { - return paymentAccountsService.getPaymentAccountFormAsString(paymentMethodId); + public PaymentAccountForm getPaymentAccountForm(String paymentMethodId) { + return paymentAccountsService.getPaymentAccountForm(paymentMethodId); } public PaymentAccount createCryptoCurrencyPaymentAccount(String accountName, @@ -517,6 +519,10 @@ public class CoreApi { public List getCryptoCurrencyPaymentMethods() { return paymentAccountsService.getCryptoCurrencyPaymentMethods(); } + + public void validateFormField(PaymentAccountForm form, PaymentAccountFormField.FieldId fieldId, String value) { + paymentAccountsService.validateFormField(form, fieldId, value); + } /////////////////////////////////////////////////////////////////////////////////////////// // Prices diff --git a/core/src/main/java/bisq/core/api/CorePaymentAccountsService.java b/core/src/main/java/bisq/core/api/CorePaymentAccountsService.java index 77a647d8ab..6438b12b14 100644 --- a/core/src/main/java/bisq/core/api/CorePaymentAccountsService.java +++ b/core/src/main/java/bisq/core/api/CorePaymentAccountsService.java @@ -19,7 +19,11 @@ package bisq.core.api; import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.api.model.PaymentAccountForm; +import bisq.core.api.model.PaymentAccountForm; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.CryptoCurrency; +import bisq.core.locale.CurrencyUtil; +import bisq.core.locale.TradeCurrency; import bisq.core.payment.AssetAccount; import bisq.core.payment.CryptoCurrencyAccount; import bisq.core.payment.InstantCryptoCurrencyAccount; @@ -27,7 +31,6 @@ import bisq.core.payment.PaymentAccount; import bisq.core.payment.PaymentAccountFactory; import bisq.core.payment.payload.PaymentMethod; import bisq.core.user.User; - import javax.inject.Inject; import javax.inject.Singleton; @@ -50,24 +53,22 @@ class CorePaymentAccountsService { private final CoreAccountService accountService; private final AccountAgeWitnessService accountAgeWitnessService; - private final PaymentAccountForm paymentAccountForm; private final User user; @Inject public CorePaymentAccountsService(CoreAccountService accountService, AccountAgeWitnessService accountAgeWitnessService, - PaymentAccountForm paymentAccountForm, User user) { this.accountService = accountService; this.accountAgeWitnessService = accountAgeWitnessService; - this.paymentAccountForm = paymentAccountForm; this.user = user; } // Fiat Currency Accounts - PaymentAccount createPaymentAccount(String jsonString) { - PaymentAccount paymentAccount = paymentAccountForm.toPaymentAccount(jsonString); + PaymentAccount createPaymentAccount(PaymentAccountForm form) { + PaymentAccount paymentAccount = form.toPaymentAccount(); + setSelectedTradeCurrency(paymentAccount); // TODO: selected trade currency is function of offer, not payment account payload verifyPaymentAccountHasRequiredFields(paymentAccount); user.addPaymentAccountIfNotExists(paymentAccount); accountAgeWitnessService.publishMyAccountAgeWitness(paymentAccount.getPaymentAccountPayload()); @@ -76,6 +77,18 @@ class CorePaymentAccountsService { paymentAccount.getPaymentAccountPayload().getPaymentMethodId()); return paymentAccount; } + + private static void setSelectedTradeCurrency(PaymentAccount paymentAccount) { + TradeCurrency singleTradeCurrency = paymentAccount.getSingleTradeCurrency(); + List tradeCurrencies = paymentAccount.getTradeCurrencies(); + if (singleTradeCurrency != null) return; + else if (tradeCurrencies != null && !tradeCurrencies.isEmpty()) { + if (tradeCurrencies.contains(CurrencyUtil.getDefaultTradeCurrency())) + paymentAccount.setSelectedTradeCurrency(CurrencyUtil.getDefaultTradeCurrency()); + else + paymentAccount.setSelectedTradeCurrency(tradeCurrencies.get(0)); + } + } Set getPaymentAccounts() { return user.getPaymentAccounts(); @@ -88,14 +101,18 @@ class CorePaymentAccountsService { .collect(Collectors.toList()); } - String getPaymentAccountFormAsString(String paymentMethodId) { - File jsonForm = getPaymentAccountForm(paymentMethodId); - jsonForm.deleteOnExit(); // If just asking for a string, delete the form file. - return paymentAccountForm.toJsonString(jsonForm); + PaymentAccountForm getPaymentAccountForm(String paymentMethodId) { + return PaymentAccountForm.getForm(paymentMethodId); } - File getPaymentAccountForm(String paymentMethodId) { - return paymentAccountForm.getPaymentAccountForm(paymentMethodId); + String getPaymentAccountFormAsString(String paymentMethodId) { + File jsonForm = getPaymentAccountFormFile(paymentMethodId); + jsonForm.deleteOnExit(); // If just asking for a string, delete the form file. + return PaymentAccountForm.toJsonString(jsonForm); + } + + File getPaymentAccountFormFile(String paymentMethodId) { + return PaymentAccountForm.getPaymentAccountForm(paymentMethodId); } // Crypto Currency Accounts @@ -134,6 +151,16 @@ class CorePaymentAccountsService { .collect(Collectors.toList()); } + void validateFormField(PaymentAccountForm form, PaymentAccountFormField.FieldId fieldId, String value) { + + // get payment method id + PaymentAccountForm.FormId formId = form.getId(); + + // validate field with empty payment account + PaymentAccount paymentAccount = PaymentAccountFactory.getPaymentAccount(PaymentMethod.getPaymentMethod(formId.toString())); + paymentAccount.validateFormField(form, fieldId, value); + } + private void verifyPaymentAccountHasRequiredFields(PaymentAccount paymentAccount) { if (!paymentAccount.hasMultipleCurrencies() && paymentAccount.getSingleTradeCurrency() == null) throw new IllegalArgumentException(format("no trade currency defined for %s payment account", diff --git a/core/src/main/java/bisq/core/api/model/PaymentAccountForm.java b/core/src/main/java/bisq/core/api/model/PaymentAccountForm.java index a5aeae247d..1c96a6f872 100644 --- a/core/src/main/java/bisq/core/api/model/PaymentAccountForm.java +++ b/core/src/main/java/bisq/core/api/model/PaymentAccountForm.java @@ -17,130 +17,137 @@ package bisq.core.api.model; -import bisq.core.payment.PaymentAccount; -import bisq.core.payment.PaymentAccountFactory; -import bisq.core.payment.payload.PaymentMethod; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -import javax.inject.Singleton; - -import com.google.common.annotations.VisibleForTesting; - -import org.apache.commons.lang3.StringUtils; - -import java.net.URI; -import java.net.URISyntaxException; - -import java.nio.file.Files; -import java.nio.file.Paths; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; - -import java.util.Map; - -import java.lang.reflect.Type; - -import lombok.extern.slf4j.Slf4j; - import static bisq.core.payment.payload.PaymentMethod.getPaymentMethod; import static com.google.common.base.Preconditions.checkNotNull; import static java.lang.String.format; import static java.lang.System.getProperty; import static java.nio.charset.StandardCharsets.UTF_8; +import bisq.common.proto.ProtoUtil; +import bisq.common.proto.persistable.PersistablePayload; +import bisq.core.payment.PaymentAccount; +import bisq.core.payment.PaymentAccountFactory; +import bisq.core.payment.payload.PaymentMethod; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.CaseFormat; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.lang.reflect.Type; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import javax.annotation.concurrent.Immutable; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.ToString; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; -/** - *

- * An instance of this class can write new payment account forms (editable json files), - * and de-serialize edited json files into {@link PaymentAccount} - * instances. - *

- *

- * Example use case: (1) ask for a blank Hal Cash account form, (2) edit it, (3) derive a - * {@link bisq.core.payment.HalCashAccount} instance from the edited json file. - *

- *
- *

- * (1) Ask for a hal cash account form: Pass a {@link PaymentMethod#HAL_CASH_ID} - * to {@link PaymentAccountForm#getPaymentAccountForm(String)} to - * get the json Hal Cash payment account form: - *

- * {
- *   "_COMMENTS_": [
- *     "Do not manually edit the paymentMethodId field.",
- *     "Edit the salt field only if you are recreating a payment account on a new installation and wish to preserve the account age."
- *   ],
- *   "paymentMethodId": "HAL_CASH",
- *   "accountName": "Your accountname",
- *   "mobileNr": "Your mobilenr"
- *   "salt": ""
- * }
- * 
- *

- *

- * (2) Save the Hal Cash payment account form to disk, and edit it: - *

- * {
- *   "_COMMENTS_": [
- *     "Do not manually edit the paymentMethodId field.",
- *     "Edit the salt field only if you are recreating a payment account on a new installation and wish to preserve the account age."
- *   ],
- *   "paymentMethodId": "HAL_CASH",
- *   "accountName": "Hal Cash Acct",
- *   "mobileNr": "798 123 456"
- *   "salt": ""
- * }
- * 
- *

- * (3) De-serialize the edited json account form: Pass the edited json file to - * {@link PaymentAccountForm#toPaymentAccount(File)}, or - * a json string to {@link PaymentAccountForm#toPaymentAccount(String)} - * and get a {@link bisq.core.payment.HalCashAccount} instance. - *
- * PaymentAccount(
- * paymentMethod=PaymentMethod(id=HAL_CASH,
- *                             maxTradePeriod=86400000,
- *                             maxTradeLimit=50000000),
- * id=e33c9d94-1a1a-43fd-aa11-fcaacbb46100,
- * creationDate=Mon Nov 16 12:26:43 BRST 2020,
- * paymentAccountPayload=HalCashAccountPayload(mobileNr=798 123 456),
- * accountName=Hal Cash Acct,
- * tradeCurrencies=[FiatCurrency(currency=EUR)],
- * selectedTradeCurrency=FiatCurrency(currency=EUR)
- * )
- * 
- */ -@Singleton +@Getter +@Immutable +@EqualsAndHashCode +@ToString @Slf4j -public class PaymentAccountForm { - - private final GsonBuilder gsonBuilder = new GsonBuilder() +public final class PaymentAccountForm implements PersistablePayload { + + private static final GsonBuilder gsonBuilder = new GsonBuilder() .setPrettyPrinting() .serializeNulls(); + + public enum FormId { + REVOLUT, + SEPA, + TRANSFERWISE, + CLEAR_X_CHANGE, + SWIFT, + F2F, + STRIKE; - // A list of PaymentAccount fields to exclude from json forms. - private final String[] excludedFields = new String[]{ - "log", - "id", - "acceptedCountryCodes", - "countryCode", - "creationDate", - "excludeFromJsonDataMap", - "maxTradePeriod", - "paymentAccountPayload", - "paymentMethod", - "paymentMethodId", // Will be included, but handled differently. - "persistedAccountName", // Automatically set in PaymentAccount.onPersistChanges(). - "selectedTradeCurrency", // May be included, but handled differently. - "tradeCurrencies", // May be included, but handled differently. - "HOLDER_NAME", - "SALT" // Will be included, but handled differently. - }; + public static PaymentAccountForm.FormId fromProto(protobuf.PaymentAccountForm.FormId formId) { + return ProtoUtil.enumFromProto(PaymentAccountForm.FormId.class, formId.name()); + } + + public static protobuf.PaymentAccountForm.FormId toProtoMessage(PaymentAccountForm.FormId formId) { + return protobuf.PaymentAccountForm.FormId.valueOf(formId.name()); + } + } + + private final FormId id; + private final List fields; + + public PaymentAccountForm(FormId id) { + this.id = id; + this.fields = new ArrayList(); + } + + public PaymentAccountForm(FormId id, List fields) { + this.id = id; + this.fields = fields; + } + + @Override + public protobuf.PaymentAccountForm toProtoMessage() { + return protobuf.PaymentAccountForm.newBuilder() + .setId(PaymentAccountForm.FormId.toProtoMessage(id)) + .addAllFields(fields.stream().map(field -> field.toProtoMessage()).collect(Collectors.toList())) + .build(); + } + + public static PaymentAccountForm fromProto(protobuf.PaymentAccountForm proto) { + List fields = proto.getFieldsList().isEmpty() ? null : proto.getFieldsList().stream().map(PaymentAccountFormField::fromProto).collect(Collectors.toList()); + return new PaymentAccountForm(FormId.fromProto(proto.getId()), fields); + } + + /** + * Get a structured form for the given payment method. + */ + public static PaymentAccountForm getForm(String paymentMethodId) { + PaymentAccount paymentAccount = PaymentAccountFactory.getPaymentAccount(PaymentMethod.getPaymentMethod(paymentMethodId)); + return paymentAccount.toForm(); + } + + /** + * Convert this form to a PaymentAccount json string. + */ + public String toPaymentAccountJsonString() { + Map formMap = new HashMap(); + formMap.put("paymentMethodId", getId().toString()); + for (PaymentAccountFormField field : getFields()) { + formMap.put(toCamelCase(field.getId().toString()), field.getValue()); + } + return new Gson().toJson(formMap); + } + + /** + * Convert this form to a PaymentAccount. + */ + public PaymentAccount toPaymentAccount() { + return toPaymentAccount(toPaymentAccountJsonString()); + } + + /** + * De-serialize a PaymentAccount json string into a new PaymentAccount instance. + * + * @param paymentAccountJsonString The json data representing a new payment account form. + * @return A populated PaymentAccount subclass instance. + */ + public static PaymentAccount toPaymentAccount(String paymentAccountJsonString) { + Class clazz = getPaymentAccountClassFromJson(paymentAccountJsonString); + Gson gson = gsonBuilder.registerTypeAdapter(clazz, new PaymentAccountTypeAdapter(clazz)).create(); + return gson.fromJson(paymentAccountJsonString, clazz); + } + + // ----------------------------- OLD FORM API ----------------------------- /** * Returns a blank payment account form (json) for the given paymentMethodId. @@ -148,14 +155,12 @@ public class PaymentAccountForm { * @param paymentMethodId Determines what kind of json form to return. * @return A uniquely named tmp file used to define new payment account details. */ - public File getPaymentAccountForm(String paymentMethodId) { + public static File getPaymentAccountForm(String paymentMethodId) { PaymentMethod paymentMethod = getPaymentMethod(paymentMethodId); File file = getTmpJsonFile(paymentMethodId); try (OutputStreamWriter outputStreamWriter = new OutputStreamWriter(new FileOutputStream(checkNotNull(file), false), UTF_8)) { PaymentAccount paymentAccount = PaymentAccountFactory.getPaymentAccount(paymentMethod); - Class clazz = paymentAccount.getClass(); - Gson gson = gsonBuilder.registerTypeAdapter(clazz, new PaymentAccountTypeAdapter(clazz, excludedFields)).create(); - String json = gson.toJson(paymentAccount); // serializes target to json + String json = paymentAccount.toForm().toPaymentAccountJsonString(); outputStreamWriter.write(json); } catch (Exception ex) { String errMsg = format("cannot create a payment account form for a %s payment method", paymentMethodId); @@ -173,24 +178,12 @@ public class PaymentAccountForm { */ @SuppressWarnings("unused") @VisibleForTesting - public PaymentAccount toPaymentAccount(File jsonForm) { + public static PaymentAccount toPaymentAccount(File jsonForm) { String jsonString = toJsonString(jsonForm); return toPaymentAccount(jsonString); } - /** - * De-serialize a PaymentAccount json string into a new PaymentAccount instance. - * - * @param jsonString The json data representing a new payment account form. - * @return A populated PaymentAccount subclass instance. - */ - public PaymentAccount toPaymentAccount(String jsonString) { - Class clazz = getPaymentAccountClassFromJson(jsonString); - Gson gson = gsonBuilder.registerTypeAdapter(clazz, new PaymentAccountTypeAdapter(clazz)).create(); - return gson.fromJson(jsonString, clazz); - } - - public String toJsonString(File jsonFile) { + public static String toJsonString(File jsonFile) { try { checkNotNull(jsonFile, "json file cannot be null"); return new String(Files.readAllBytes(Paths.get(jsonFile.getAbsolutePath()))); @@ -203,7 +196,7 @@ public class PaymentAccountForm { } @VisibleForTesting - public URI getClickableURI(File jsonFile) { + public static URI getClickableURI(File jsonFile) { try { return new URI("file", "", @@ -237,14 +230,20 @@ public class PaymentAccountForm { return file; } - private Class getPaymentAccountClassFromJson(String json) { + // -------------------------------- HELPERS ------------------------------- + + private static String toCamelCase(String underscore) { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, underscore); + } + + private static Class getPaymentAccountClassFromJson(String json) { Map jsonMap = gsonBuilder.create().fromJson(json, (Type) Object.class); String paymentMethodId = checkNotNull((String) jsonMap.get("paymentMethodId"), format("cannot not find a paymentMethodId in json string: %s", json)); return getPaymentAccountClass(paymentMethodId); } - private Class getPaymentAccountClass(String paymentMethodId) { + private static Class getPaymentAccountClass(String paymentMethodId) { PaymentMethod paymentMethod = getPaymentMethod(paymentMethodId); return PaymentAccountFactory.getPaymentAccount(paymentMethod).getClass(); } diff --git a/core/src/main/java/bisq/core/api/model/PaymentAccountFormField.java b/core/src/main/java/bisq/core/api/model/PaymentAccountFormField.java new file mode 100644 index 0000000000..9da56a96cd --- /dev/null +++ b/core/src/main/java/bisq/core/api/model/PaymentAccountFormField.java @@ -0,0 +1,170 @@ +/* + * This file is part of Haveno. + * + * Haveno is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Haveno is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Haveno. If not, see . + */ + +package bisq.core.api.model; + +import bisq.common.proto.ProtoUtil; +import bisq.common.proto.persistable.PersistablePayload; +import bisq.core.locale.Country; +import bisq.core.locale.TradeCurrency; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import javax.annotation.Nullable; +import javax.annotation.concurrent.Immutable; + +@Getter +@Setter +@Immutable +@EqualsAndHashCode +@ToString +public final class PaymentAccountFormField implements PersistablePayload { + + public enum FieldId { + ACCEPTED_COUNTRY_CODES, + ACCOUNT_ID, + ACCOUNT_NAME, + ACCOUNT_NR, + ACCOUNT_OWNER, + ACCOUNT_TYPE, + ANSWER, + BANK_ACCOUNT_NAME, + BANK_ACCOUNT_NUMBER, + BANK_ACCOUNT_TYPE, + BANK_ADDRESS, + BANK_BRANCH, + BANK_BRANCH_CODE, + BANK_BRANCH_NAME, + BANK_CODE, + BANK_COUNTRY_CODE, + BANK_ID, + BANK_NAME, + BANK_SWIFT_CODE, + BENEFICIARY_ACCOUNT_NR, + BENEFICIARY_ADDRESS, + BENEFICIARY_CITY, + BENEFICIARY_NAME, + BENEFICIARY_PHONE, + BIC, + BRANCH_ID, + CITY, + CONTACT, + COUNTRY, + EMAIL, + EMAIL_OR_MOBILE_NR, + EXTRA_INFO, + HOLDER_ADDRESS, + HOLDER_EMAIL, + HOLDER_NAME, + HOLDER_TAX_ID, + IBAN, + IFSC, + INTERMEDIARY_ADDRESS, + INTERMEDIARY_BRANCH, + INTERMEDIARY_COUNTRY_CODE, + INTERMEDIARY_NAME, + INTERMEDIARY_SWIFT_CODE, + MOBILE_NR, + NATIONAL_ACCOUNT_ID, + PAYID, + PIX_KEY, + POSTAL_ADDRESS, + PROMPT_PAY_ID, + QUESTION, + REQUIREMENTS, + SALT, + SORT_CODE, + SPECIAL_INSTRUCTIONS, + STATE, + TRADE_CURRENCIES, + USER_NAME, + VIRTUAL_PAYMENT_ADDRESS; + + public static PaymentAccountFormField.FieldId fromProto(protobuf.PaymentAccountFormField.FieldId fieldId) { + return ProtoUtil.enumFromProto(PaymentAccountFormField.FieldId.class, fieldId.name()); + } + + public static protobuf.PaymentAccountFormField.FieldId toProtoMessage(PaymentAccountFormField.FieldId fieldId) { + return protobuf.PaymentAccountFormField.FieldId.valueOf(fieldId.name()); + } + } + + public enum Component { + TEXT, + SELECT_ONE, + SELECT_MULTIPLE; + + public static PaymentAccountFormField.Component fromProto(protobuf.PaymentAccountFormField.Component component) { + return ProtoUtil.enumFromProto(PaymentAccountFormField.Component.class, component.name()); + } + + public static protobuf.PaymentAccountFormField.Component toProtoMessage(PaymentAccountFormField.Component component) { + return protobuf.PaymentAccountFormField.Component.valueOf(component.name()); + } + } + + private FieldId id; + private Component component; + @Nullable + private String type; + private String label; + private String value; + private int minLength; + private int maxLength; + private List supportedCurrencies; + private List supportedCountries; + private List supportedSepaEuroCountries; + private List supportedSepaNonEuroCountries; + + public PaymentAccountFormField(FieldId id) { + this.id = id; + } + + @Override + public protobuf.PaymentAccountFormField toProtoMessage() { + protobuf.PaymentAccountFormField.Builder builder = protobuf.PaymentAccountFormField.newBuilder() + .setId(PaymentAccountFormField.FieldId.toProtoMessage(id)) + .setComponent(PaymentAccountFormField.Component.toProtoMessage(component)) + .setMinLength(minLength) + .setMaxLength(maxLength); + Optional.ofNullable(type).ifPresent(builder::setType); + Optional.ofNullable(label).ifPresent(builder::setLabel); + Optional.ofNullable(value).ifPresent(builder::setValue); + Optional.ofNullable(supportedCurrencies).ifPresent(e -> builder.addAllSupportedCurrencies(ProtoUtil.collectionToProto(supportedCurrencies, protobuf.TradeCurrency.class))); + Optional.ofNullable(supportedCountries).ifPresent(e -> builder.addAllSupportedCountries(ProtoUtil.collectionToProto(supportedCountries, protobuf.Country.class))); + Optional.ofNullable(supportedSepaEuroCountries).ifPresent(e -> builder.addAllSupportedSepaEuroCountries(ProtoUtil.collectionToProto(supportedSepaEuroCountries, protobuf.Country.class))); + Optional.ofNullable(supportedSepaNonEuroCountries).ifPresent(e -> builder.addAllSupportedSepaNonEuroCountries(ProtoUtil.collectionToProto(supportedSepaNonEuroCountries, protobuf.Country.class))); + return builder.build(); + } + + public static PaymentAccountFormField fromProto(protobuf.PaymentAccountFormField proto) { + PaymentAccountFormField formField = new PaymentAccountFormField(FieldId.fromProto(proto.getId())); + formField.type = proto.getType(); + formField.label = proto.getLabel(); + formField.value = proto.getValue(); + formField.minLength = proto.getMinLength(); + formField.maxLength = proto.getMaxLength(); + formField.supportedCountries = proto.getSupportedCountriesList().isEmpty() ? null : proto.getSupportedCountriesList().stream().map(Country::fromProto).collect(Collectors.toList()); + formField.supportedSepaEuroCountries = proto.getSupportedSepaEuroCountriesList().isEmpty() ? null : proto.getSupportedSepaEuroCountriesList().stream().map(Country::fromProto).collect(Collectors.toList()); + formField.supportedSepaNonEuroCountries = proto.getSupportedSepaNonEuroCountriesList().isEmpty() ? null : proto.getSupportedSepaNonEuroCountriesList().stream().map(Country::fromProto).collect(Collectors.toList()); + return formField; + } +} diff --git a/core/src/main/java/bisq/core/api/model/PaymentAccountTypeAdapter.java b/core/src/main/java/bisq/core/api/model/PaymentAccountTypeAdapter.java index 631b6f4c9f..dcd83fd33e 100644 --- a/core/src/main/java/bisq/core/api/model/PaymentAccountTypeAdapter.java +++ b/core/src/main/java/bisq/core/api/model/PaymentAccountTypeAdapter.java @@ -19,6 +19,7 @@ package bisq.core.api.model; import bisq.core.locale.Country; +import bisq.core.locale.CountryUtil; import bisq.core.locale.FiatCurrency; import bisq.core.locale.Res; import bisq.core.locale.TradeCurrency; @@ -39,7 +40,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.function.Function; import java.util.function.Predicate; import java.lang.reflect.Constructor; @@ -59,10 +59,8 @@ import static bisq.core.payment.payload.PaymentMethod.MONEY_GRAM_ID; import static com.google.common.base.Preconditions.checkNotNull; import static java.lang.String.format; import static java.util.Arrays.stream; -import static java.util.Collections.singletonList; import static java.util.Collections.unmodifiableMap; import static java.util.Comparator.comparing; -import static java.util.stream.Collectors.toList; import static org.apache.commons.lang3.StringUtils.capitalize; @Slf4j @@ -222,6 +220,10 @@ class PaymentAccountTypeAdapter extends TypeAdapter { if (didReadTradeCurrenciesField(in, account, currentFieldName)) continue; + // The acceptedCountryCodes field has no setter. + if (didReadAcceptedCountryCodes(in, account, currentFieldName)) + continue; + // The selectedTradeCurrency field is common to all payment account types, // but is @Nullable, and may not need to be explicitly defined by user. if (didReadSelectedTradeCurrencyField(in, account, currentFieldName)) @@ -339,15 +341,15 @@ class PaymentAccountTypeAdapter extends TypeAdapter { } } - private final Predicate isCommaDelimitedCurrencyList = (s) -> s != null && s.contains(","); - private final Function> commaDelimitedCodesToList = (s) -> { - if (isCommaDelimitedCurrencyList.test(s)) - return stream(s.split(",")).map(a -> a.trim().toUpperCase()).collect(toList()); - else if (s != null && !s.isEmpty()) - return singletonList(s.trim().toUpperCase()); - else - return new ArrayList<>(); - }; + private boolean didReadAcceptedCountryCodes(JsonReader in, + PaymentAccount account, + String fieldName) { + if (!fieldName.equals("acceptedCountryCodes")) return false; + String fieldValue = nextStringOrNull(in); + List countryCodes = PaymentAccount.commaDelimitedCodesToList.apply(fieldValue); + ((CountryBasedPaymentAccount) account).setAcceptedCountries(CountryUtil.getCountries(countryCodes)); + return true; + } private boolean didReadTradeCurrenciesField(JsonReader in, PaymentAccount account, @@ -359,7 +361,7 @@ class PaymentAccountTypeAdapter extends TypeAdapter { // no setter, so we add currencies to the List here if the payment account // supports multiple trade currencies. String fieldValue = nextStringOrNull(in); - List currencyCodes = commaDelimitedCodesToList.apply(fieldValue); + List currencyCodes = PaymentAccount.commaDelimitedCodesToList.apply(fieldValue); Optional> tradeCurrencies = getReconciledTradeCurrencies(currencyCodes, account); if (tradeCurrencies.isPresent()) { for (TradeCurrency tradeCurrency : tradeCurrencies.get()) { diff --git a/core/src/main/java/bisq/core/locale/CountryUtil.java b/core/src/main/java/bisq/core/locale/CountryUtil.java index 9ae9e7a321..c1b5e3819e 100644 --- a/core/src/main/java/bisq/core/locale/CountryUtil.java +++ b/core/src/main/java/bisq/core/locale/CountryUtil.java @@ -21,6 +21,7 @@ import com.google.common.collect.Collections2; import com.google.common.collect.Lists; import java.util.ArrayList; +import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; @@ -35,6 +36,26 @@ import lombok.extern.slf4j.Slf4j; @Slf4j public class CountryUtil { + + public static List getCountryCodes(List countries) { + return countries.stream().map(country -> country.code).collect(Collectors.toList()); + } + + public static List getCountries(List codes) { + List countries = new ArrayList(); + for (String code : codes) { + Locale locale = new Locale(LanguageUtil.getDefaultLanguage(), code, ""); + final String countryCode = locale.getCountry(); + String regionCode = getRegionCode(countryCode); + final Region region = new Region(regionCode, getRegionName(regionCode)); + Country country = new Country(countryCode, locale.getDisplayCountry(), region); + if (countryCode.equals("XK")) + country = new Country(countryCode, getNameByCode(countryCode), region); + countries.add(country); + } + return countries; + } + public static List getAllSepaEuroCountries() { List list = new ArrayList<>(); String[] codes = {"AT", "BE", "CY", "DE", "EE", "FI", "FR", "GR", "IE", @@ -72,16 +93,7 @@ public class CountryUtil { } private static void populateCountryListByCodes(List list, String[] codes) { - for (String code : codes) { - Locale locale = new Locale(LanguageUtil.getDefaultLanguage(), code, ""); - final String countryCode = locale.getCountry(); - String regionCode = getRegionCode(countryCode); - final Region region = new Region(regionCode, getRegionName(regionCode)); - Country country = new Country(countryCode, locale.getDisplayCountry(), region); - if (countryCode.equals("XK")) - country = new Country(countryCode, getNameByCode(countryCode), region); - list.add(country); - } + list.addAll(getCountries(Arrays.asList(codes))); } public static boolean containsAllSepaEuroCountries(List countryCodesToCompare) { diff --git a/core/src/main/java/bisq/core/payment/AchTransferAccount.java b/core/src/main/java/bisq/core/payment/AchTransferAccount.java index a5bcb871be..a2b2c91b9b 100644 --- a/core/src/main/java/bisq/core/payment/AchTransferAccount.java +++ b/core/src/main/java/bisq/core/payment/AchTransferAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.AchTransferAccountPayload; @@ -57,14 +58,17 @@ public final class AchTransferAccount extends CountryBasedPaymentAccount impleme return (AchTransferAccountPayload) paymentAccountPayload; } + @Override public String getMessageForBuyer() { return "payment.achTransfer.info.buyer"; } + @Override public String getMessageForSeller() { return "payment.achTransfer.info.seller"; } + @Override public String getMessageForAccountCreation() { return "payment.achTransfer.info.account"; } @@ -73,4 +77,9 @@ public final class AchTransferAccount extends CountryBasedPaymentAccount impleme public @NonNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } } diff --git a/core/src/main/java/bisq/core/payment/AdvancedCashAccount.java b/core/src/main/java/bisq/core/payment/AdvancedCashAccount.java index 62632a5c05..9f6429a563 100644 --- a/core/src/main/java/bisq/core/payment/AdvancedCashAccount.java +++ b/core/src/main/java/bisq/core/payment/AdvancedCashAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.AdvancedCashAccountPayload; @@ -57,6 +58,12 @@ public final class AdvancedCashAccount extends PaymentAccount { return SUPPORTED_CURRENCIES; } + @NotNull + @Override + public List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public void setAccountNr(String accountNr) { ((AdvancedCashAccountPayload) paymentAccountPayload).setAccountNr(accountNr); } diff --git a/core/src/main/java/bisq/core/payment/AliPayAccount.java b/core/src/main/java/bisq/core/payment/AliPayAccount.java index ab3d724f8f..7e0ac51af3 100644 --- a/core/src/main/java/bisq/core/payment/AliPayAccount.java +++ b/core/src/main/java/bisq/core/payment/AliPayAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.AliPayAccountPayload; @@ -48,6 +49,11 @@ public final class AliPayAccount extends PaymentAccount { return SUPPORTED_CURRENCIES; } + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public void setAccountNr(String accountNr) { ((AliPayAccountPayload) paymentAccountPayload).setAccountNr(accountNr); } diff --git a/core/src/main/java/bisq/core/payment/AmazonGiftCardAccount.java b/core/src/main/java/bisq/core/payment/AmazonGiftCardAccount.java index 52685b1674..0c9a17a12a 100644 --- a/core/src/main/java/bisq/core/payment/AmazonGiftCardAccount.java +++ b/core/src/main/java/bisq/core/payment/AmazonGiftCardAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.Country; import bisq.core.locale.CountryUtil; import bisq.core.locale.FiatCurrency; @@ -59,12 +60,16 @@ public final class AmazonGiftCardAccount extends PaymentAccount { return new AmazonGiftCardAccountPayload(paymentMethod.getId(), id); } - @NotNull @Override - public List getSupportedCurrencies() { + public @NotNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + @Override + public @NotNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public String getEmailOrMobileNr() { return getAmazonGiftCardAccountPayload().getEmailOrMobileNr(); } diff --git a/core/src/main/java/bisq/core/payment/AustraliaPayidAccount.java b/core/src/main/java/bisq/core/payment/AustraliaPayidAccount.java index 3eab1302c6..f575b0435e 100644 --- a/core/src/main/java/bisq/core/payment/AustraliaPayidAccount.java +++ b/core/src/main/java/bisq/core/payment/AustraliaPayidAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.AustraliaPayidAccountPayload; @@ -46,6 +47,11 @@ public final class AustraliaPayidAccount extends PaymentAccount { return SUPPORTED_CURRENCIES; } + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public String getPayid() { return ((AustraliaPayidAccountPayload) paymentAccountPayload).getPayid(); } diff --git a/core/src/main/java/bisq/core/payment/BizumAccount.java b/core/src/main/java/bisq/core/payment/BizumAccount.java index d98cb3a41f..6a4bddd2eb 100644 --- a/core/src/main/java/bisq/core/payment/BizumAccount.java +++ b/core/src/main/java/bisq/core/payment/BizumAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.BizumAccountPayload; @@ -50,14 +51,17 @@ public final class BizumAccount extends CountryBasedPaymentAccount { return ((BizumAccountPayload) paymentAccountPayload).getMobileNr(); } + @Override public String getMessageForBuyer() { return "payment.bizum.info.buyer"; } + @Override public String getMessageForSeller() { return "payment.bizum.info.seller"; } + @Override public String getMessageForAccountCreation() { return "payment.bizum.info.account"; } @@ -66,4 +70,9 @@ public final class BizumAccount extends CountryBasedPaymentAccount { public @NonNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } } diff --git a/core/src/main/java/bisq/core/payment/CapitualAccount.java b/core/src/main/java/bisq/core/payment/CapitualAccount.java index db827e9968..da27fe6151 100644 --- a/core/src/main/java/bisq/core/payment/CapitualAccount.java +++ b/core/src/main/java/bisq/core/payment/CapitualAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.CapitualAccountPayload; @@ -55,6 +56,12 @@ public final class CapitualAccount extends PaymentAccount { return SUPPORTED_CURRENCIES; } + @NotNull + @Override + public List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public void setAccountNr(String accountNr) { ((CapitualAccountPayload) paymentAccountPayload).setAccountNr(accountNr); } diff --git a/core/src/main/java/bisq/core/payment/CashAppAccount.java b/core/src/main/java/bisq/core/payment/CashAppAccount.java index 74c9951bbf..e31663235c 100644 --- a/core/src/main/java/bisq/core/payment/CashAppAccount.java +++ b/core/src/main/java/bisq/core/payment/CashAppAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.CashAppAccountPayload; @@ -51,6 +52,11 @@ public final class CashAppAccount extends PaymentAccount { return SUPPORTED_CURRENCIES; } + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public void setCashTag(String cashTag) { ((CashAppAccountPayload) paymentAccountPayload).setCashTag(cashTag); } diff --git a/core/src/main/java/bisq/core/payment/CashByMailAccount.java b/core/src/main/java/bisq/core/payment/CashByMailAccount.java index 14d1da9e26..dfc2fd5feb 100644 --- a/core/src/main/java/bisq/core/payment/CashByMailAccount.java +++ b/core/src/main/java/bisq/core/payment/CashByMailAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.CashByMailAccountPayload; @@ -45,6 +46,11 @@ public final class CashByMailAccount extends PaymentAccount { return SUPPORTED_CURRENCIES; } + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public void setPostalAddress(String postalAddress) { ((CashByMailAccountPayload) paymentAccountPayload).setPostalAddress(postalAddress); } diff --git a/core/src/main/java/bisq/core/payment/CashDepositAccount.java b/core/src/main/java/bisq/core/payment/CashDepositAccount.java index 5113e34f34..702961ec05 100644 --- a/core/src/main/java/bisq/core/payment/CashDepositAccount.java +++ b/core/src/main/java/bisq/core/payment/CashDepositAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.CashDepositAccountPayload; @@ -47,6 +48,11 @@ public final class CashDepositAccount extends CountryBasedPaymentAccount impleme return SUPPORTED_CURRENCIES; } + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + @Override public String getBankId() { return ((CashDepositAccountPayload) paymentAccountPayload).getBankId(); diff --git a/core/src/main/java/bisq/core/payment/CelPayAccount.java b/core/src/main/java/bisq/core/payment/CelPayAccount.java index a33107028e..e1b0f2accd 100644 --- a/core/src/main/java/bisq/core/payment/CelPayAccount.java +++ b/core/src/main/java/bisq/core/payment/CelPayAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.CelPayAccountPayload; @@ -58,21 +59,28 @@ public final class CelPayAccount extends PaymentAccount { return ((CelPayAccountPayload) paymentAccountPayload).getEmail(); } + @Override public String getMessageForBuyer() { return "payment.celpay.info.buyer"; } + @Override public String getMessageForSeller() { return "payment.celpay.info.seller"; } + @Override public String getMessageForAccountCreation() { return "payment.celpay.info.account"; } - @NotNull @Override - public List getSupportedCurrencies() { + public @NotNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + + @Override + public @NotNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } } diff --git a/core/src/main/java/bisq/core/payment/ChaseQuickPayAccount.java b/core/src/main/java/bisq/core/payment/ChaseQuickPayAccount.java index 4a80f7d7cd..153baa0795 100644 --- a/core/src/main/java/bisq/core/payment/ChaseQuickPayAccount.java +++ b/core/src/main/java/bisq/core/payment/ChaseQuickPayAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.ChaseQuickPayAccountPayload; @@ -51,6 +52,11 @@ public final class ChaseQuickPayAccount extends PaymentAccount { return SUPPORTED_CURRENCIES; } + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public void setEmail(String email) { ((ChaseQuickPayAccountPayload) paymentAccountPayload).setEmail(email); } diff --git a/core/src/main/java/bisq/core/payment/ClearXchangeAccount.java b/core/src/main/java/bisq/core/payment/ClearXchangeAccount.java index 6c99446bff..edcb62ceaa 100644 --- a/core/src/main/java/bisq/core/payment/ClearXchangeAccount.java +++ b/core/src/main/java/bisq/core/payment/ClearXchangeAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.ClearXchangeAccountPayload; @@ -38,6 +39,13 @@ public final class ClearXchangeAccount extends PaymentAccount { setSingleTradeCurrency(SUPPORTED_CURRENCIES.get(0)); } + private static final List INPUT_FIELD_IDS = List.of( + PaymentAccountFormField.FieldId.ACCOUNT_NAME, + PaymentAccountFormField.FieldId.HOLDER_NAME, + PaymentAccountFormField.FieldId.EMAIL_OR_MOBILE_NR, + PaymentAccountFormField.FieldId.SALT + ); + @Override protected PaymentAccountPayload createPayload() { return new ClearXchangeAccountPayload(paymentMethod.getId(), id); @@ -48,6 +56,11 @@ public final class ClearXchangeAccount extends PaymentAccount { return SUPPORTED_CURRENCIES; } + @Override + public @NonNull List getInputFieldIds() { + return INPUT_FIELD_IDS; + } + public void setEmailOrMobileNr(String mobileNr) { ((ClearXchangeAccountPayload) paymentAccountPayload).setEmailOrMobileNr(mobileNr); } diff --git a/core/src/main/java/bisq/core/payment/CountryBasedPaymentAccount.java b/core/src/main/java/bisq/core/payment/CountryBasedPaymentAccount.java index 0ca08d8554..bdcbf7c19e 100644 --- a/core/src/main/java/bisq/core/payment/CountryBasedPaymentAccount.java +++ b/core/src/main/java/bisq/core/payment/CountryBasedPaymentAccount.java @@ -21,9 +21,9 @@ import bisq.core.locale.Country; import bisq.core.locale.CountryUtil; import bisq.core.payment.payload.CountryBasedPaymentAccountPayload; import bisq.core.payment.payload.PaymentMethod; - +import java.util.List; import lombok.EqualsAndHashCode; - +import lombok.NonNull; import org.jetbrains.annotations.NotNull; import javax.annotation.Nullable; @@ -32,6 +32,8 @@ import javax.annotation.Nullable; public abstract class CountryBasedPaymentAccount extends PaymentAccount { @Nullable protected Country country; + @Nullable + protected List acceptedCountries; /////////////////////////////////////////////////////////////////////////////////////////// @@ -61,4 +63,23 @@ public abstract class CountryBasedPaymentAccount extends PaymentAccount { this.country = country; ((CountryBasedPaymentAccountPayload) paymentAccountPayload).setCountryCode(country.code); } + + @Nullable + public List getAcceptedCountries() { + if (acceptedCountries == null) { + final List acceptedCountryCodes = ((CountryBasedPaymentAccountPayload) paymentAccountPayload).getAcceptedCountryCodes(); + acceptedCountries = CountryUtil.getCountries(acceptedCountryCodes); + } + return acceptedCountries; + } + + public void setAcceptedCountries(List acceptedCountries) { + this.acceptedCountries = acceptedCountries; + ((CountryBasedPaymentAccountPayload) paymentAccountPayload).setAcceptedCountryCodes(CountryUtil.getCountryCodes(acceptedCountries)); + } + + @Nullable + public List getSupportedCountries() { + return null; // support all countries by default + } } diff --git a/core/src/main/java/bisq/core/payment/CryptoCurrencyAccount.java b/core/src/main/java/bisq/core/payment/CryptoCurrencyAccount.java index 8e11cf5e1a..14cc659291 100644 --- a/core/src/main/java/bisq/core/payment/CryptoCurrencyAccount.java +++ b/core/src/main/java/bisq/core/payment/CryptoCurrencyAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.CryptoCurrencyAccountPayload; @@ -47,4 +48,9 @@ public final class CryptoCurrencyAccount extends AssetAccount { public @NonNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } } diff --git a/core/src/main/java/bisq/core/payment/DomesticWireTransferAccount.java b/core/src/main/java/bisq/core/payment/DomesticWireTransferAccount.java index a976f9ba14..e48ccbf7cf 100644 --- a/core/src/main/java/bisq/core/payment/DomesticWireTransferAccount.java +++ b/core/src/main/java/bisq/core/payment/DomesticWireTransferAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.BankAccountPayload; @@ -57,14 +58,17 @@ public final class DomesticWireTransferAccount extends CountryBasedPaymentAccoun return (DomesticWireTransferAccountPayload) paymentAccountPayload; } + @Override public String getMessageForBuyer() { return "payment.domesticWire.info.buyer"; } + @Override public String getMessageForSeller() { return "payment.domesticWire.info.seller"; } + @Override public String getMessageForAccountCreation() { return "payment.domesticWire.info.account"; } @@ -73,4 +77,9 @@ public final class DomesticWireTransferAccount extends CountryBasedPaymentAccoun public @NonNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } } diff --git a/core/src/main/java/bisq/core/payment/F2FAccount.java b/core/src/main/java/bisq/core/payment/F2FAccount.java index 4d6e9198fe..78d80e1cba 100644 --- a/core/src/main/java/bisq/core/payment/F2FAccount.java +++ b/core/src/main/java/bisq/core/payment/F2FAccount.java @@ -16,15 +16,15 @@ */ package bisq.core.payment; - +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.CurrencyUtil; +import bisq.core.locale.Res; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.F2FAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.PaymentMethod; import java.util.List; - import lombok.EqualsAndHashCode; import lombok.NonNull; @@ -33,6 +33,15 @@ public final class F2FAccount extends CountryBasedPaymentAccount { public static final List SUPPORTED_CURRENCIES = CurrencyUtil.getAllFiatCurrencies(); + private static final List INPUT_FIELD_IDS = List.of( + PaymentAccountFormField.FieldId.ACCOUNT_NAME, + PaymentAccountFormField.FieldId.COUNTRY, + PaymentAccountFormField.FieldId.CONTACT, // TODO: contact is not used anywhere? + PaymentAccountFormField.FieldId.CITY, + PaymentAccountFormField.FieldId.EXTRA_INFO, + PaymentAccountFormField.FieldId.SALT + ); + public F2FAccount() { super(PaymentMethod.F2F); } @@ -47,6 +56,11 @@ public final class F2FAccount extends CountryBasedPaymentAccount { return SUPPORTED_CURRENCIES; } + @Override + public @NonNull List getInputFieldIds() { + return INPUT_FIELD_IDS; + } + public void setContact(String contact) { ((F2FAccountPayload) paymentAccountPayload).setContact(contact); } @@ -70,4 +84,13 @@ public final class F2FAccount extends CountryBasedPaymentAccount { public String getExtraInfo() { return ((F2FAccountPayload) paymentAccountPayload).getExtraInfo(); } + + @Override + protected PaymentAccountFormField getEmptyFormField(PaymentAccountFormField.FieldId fieldId) { + var field = super.getEmptyFormField(fieldId); + if (field.getId() == PaymentAccountFormField.FieldId.CITY) field.setLabel(Res.get("payment.f2f.city")); + if (field.getId() == PaymentAccountFormField.FieldId.CONTACT) field.setLabel(Res.get("payment.f2f.contact")); + if (field.getId() == PaymentAccountFormField.FieldId.EXTRA_INFO) field.setLabel(Res.get("payment.shared.extraInfo.prompt")); + return field; + } } diff --git a/core/src/main/java/bisq/core/payment/FasterPaymentsAccount.java b/core/src/main/java/bisq/core/payment/FasterPaymentsAccount.java index 61b5385db4..77ed108085 100644 --- a/core/src/main/java/bisq/core/payment/FasterPaymentsAccount.java +++ b/core/src/main/java/bisq/core/payment/FasterPaymentsAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.FasterPaymentsAccountPayload; @@ -48,6 +49,11 @@ public final class FasterPaymentsAccount extends PaymentAccount { return SUPPORTED_CURRENCIES; } + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public void setHolderName(String value) { ((FasterPaymentsAccountPayload) paymentAccountPayload).setHolderName(value); } diff --git a/core/src/main/java/bisq/core/payment/HalCashAccount.java b/core/src/main/java/bisq/core/payment/HalCashAccount.java index bf059b3441..f3f543fbb6 100644 --- a/core/src/main/java/bisq/core/payment/HalCashAccount.java +++ b/core/src/main/java/bisq/core/payment/HalCashAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.HalCashAccountPayload; @@ -48,6 +49,11 @@ public final class HalCashAccount extends PaymentAccount { return SUPPORTED_CURRENCIES; } + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public void setMobileNr(String mobileNr) { ((HalCashAccountPayload) paymentAccountPayload).setMobileNr(mobileNr); } diff --git a/core/src/main/java/bisq/core/payment/IfscBasedAccount.java b/core/src/main/java/bisq/core/payment/IfscBasedAccount.java index 316ea9df3b..9be970b5cb 100644 --- a/core/src/main/java/bisq/core/payment/IfscBasedAccount.java +++ b/core/src/main/java/bisq/core/payment/IfscBasedAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaymentMethod; @@ -37,4 +38,9 @@ abstract public class IfscBasedAccount extends CountryBasedPaymentAccount { public @NonNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } } diff --git a/core/src/main/java/bisq/core/payment/ImpsAccount.java b/core/src/main/java/bisq/core/payment/ImpsAccount.java index b96b0ccaa6..c6560c0090 100644 --- a/core/src/main/java/bisq/core/payment/ImpsAccount.java +++ b/core/src/main/java/bisq/core/payment/ImpsAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.ImpsAccountPayload; @@ -42,14 +43,17 @@ public final class ImpsAccount extends CountryBasedPaymentAccount { return new ImpsAccountPayload(paymentMethod.getId(), id); } + @Override public String getMessageForBuyer() { return "payment.imps.info.buyer"; } + @Override public String getMessageForSeller() { return "payment.imps.info.seller"; } + @Override public String getMessageForAccountCreation() { return "payment.imps.info.account"; } @@ -58,4 +62,9 @@ public final class ImpsAccount extends CountryBasedPaymentAccount { public @NonNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } } diff --git a/core/src/main/java/bisq/core/payment/InstantCryptoCurrencyAccount.java b/core/src/main/java/bisq/core/payment/InstantCryptoCurrencyAccount.java index 4fd6cb9ae2..4d4f78f3bf 100644 --- a/core/src/main/java/bisq/core/payment/InstantCryptoCurrencyAccount.java +++ b/core/src/main/java/bisq/core/payment/InstantCryptoCurrencyAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.InstantCryptoCurrencyPayload; @@ -47,4 +48,9 @@ public final class InstantCryptoCurrencyAccount extends AssetAccount { public @NonNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } } diff --git a/core/src/main/java/bisq/core/payment/InteracETransferAccount.java b/core/src/main/java/bisq/core/payment/InteracETransferAccount.java index 00db851ce9..a6ae04d53b 100644 --- a/core/src/main/java/bisq/core/payment/InteracETransferAccount.java +++ b/core/src/main/java/bisq/core/payment/InteracETransferAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.InteracETransferAccountPayload; @@ -44,12 +45,16 @@ public final class InteracETransferAccount extends PaymentAccount { return new InteracETransferAccountPayload(paymentMethod.getId(), id); } - @NotNull @Override - public List getSupportedCurrencies() { + public @NotNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + @Override + public @NotNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public void setEmail(String email) { ((InteracETransferAccountPayload) paymentAccountPayload).setEmail(email); } diff --git a/core/src/main/java/bisq/core/payment/JapanBankAccount.java b/core/src/main/java/bisq/core/payment/JapanBankAccount.java index 9f38fddb61..8dcd47dbf3 100644 --- a/core/src/main/java/bisq/core/payment/JapanBankAccount.java +++ b/core/src/main/java/bisq/core/payment/JapanBankAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.JapanBankAccountPayload; @@ -46,6 +47,11 @@ public final class JapanBankAccount extends PaymentAccount { return SUPPORTED_CURRENCIES; } + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + // bank code public String getBankCode() { return ((JapanBankAccountPayload) paymentAccountPayload).getBankCode(); diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/data/JapanBankData.java b/core/src/main/java/bisq/core/payment/JapanBankData.java similarity index 99% rename from desktop/src/main/java/bisq/desktop/components/paymentmethods/data/JapanBankData.java rename to core/src/main/java/bisq/core/payment/JapanBankData.java index 9787bfae1c..23d3efa745 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/data/JapanBankData.java +++ b/core/src/main/java/bisq/core/payment/JapanBankData.java @@ -15,12 +15,11 @@ * along with Haveno. If not, see . */ -package bisq.desktop.components.paymentmethods.data; - -import bisq.desktop.util.GUIUtil; +package bisq.core.payment; +import bisq.core.user.Preferences; import com.google.common.collect.ImmutableMap; - +import com.google.inject.Inject; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -46,6 +45,14 @@ import java.util.Map; */ public class JapanBankData { + + private static String userLanguage; + + @Inject + JapanBankData(Preferences preferences) { + userLanguage = preferences.getUserLanguage(); + } + /* Returns the main list of ~500 banks in Japan with bank codes, but since 90%+ of people will be using one of ~30 major banks, @@ -785,7 +792,7 @@ public class JapanBankData { // don't localize these strings into all languages, // all we want is either Japanese or English here. public static String getString(String id) { - boolean ja = GUIUtil.getUserLanguage().equals("ja"); + boolean ja = userLanguage.equals("ja"); switch (id) { case "bank": diff --git a/core/src/main/java/bisq/core/payment/MoneseAccount.java b/core/src/main/java/bisq/core/payment/MoneseAccount.java index aac0608f8b..7f49888b43 100644 --- a/core/src/main/java/bisq/core/payment/MoneseAccount.java +++ b/core/src/main/java/bisq/core/payment/MoneseAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.MoneseAccountPayload; @@ -63,14 +64,17 @@ public final class MoneseAccount extends PaymentAccount { return ((MoneseAccountPayload) paymentAccountPayload).getMobileNr(); } + @Override public String getMessageForBuyer() { return "payment.monese.info.buyer"; } + @Override public String getMessageForSeller() { return "payment.monese.info.seller"; } + @Override public String getMessageForAccountCreation() { return "payment.monese.info.account"; } @@ -79,4 +83,9 @@ public final class MoneseAccount extends PaymentAccount { public @NonNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } } diff --git a/core/src/main/java/bisq/core/payment/MoneyBeamAccount.java b/core/src/main/java/bisq/core/payment/MoneyBeamAccount.java index 318168d229..a7b1d45b1b 100644 --- a/core/src/main/java/bisq/core/payment/MoneyBeamAccount.java +++ b/core/src/main/java/bisq/core/payment/MoneyBeamAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.MoneyBeamAccountPayload; @@ -49,6 +50,11 @@ public final class MoneyBeamAccount extends PaymentAccount { return SUPPORTED_CURRENCIES; } + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public void setAccountId(String accountId) { ((MoneyBeamAccountPayload) paymentAccountPayload).setAccountId(accountId); } diff --git a/core/src/main/java/bisq/core/payment/MoneyGramAccount.java b/core/src/main/java/bisq/core/payment/MoneyGramAccount.java index c27b100341..7f44dd98be 100644 --- a/core/src/main/java/bisq/core/payment/MoneyGramAccount.java +++ b/core/src/main/java/bisq/core/payment/MoneyGramAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.Country; import bisq.core.locale.CountryUtil; import bisq.core.locale.FiatCurrency; @@ -100,12 +101,16 @@ public final class MoneyGramAccount extends PaymentAccount { return new MoneyGramAccountPayload(paymentMethod.getId(), id); } - @NotNull @Override - public List getSupportedCurrencies() { + public @NotNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + @Override + public @NotNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + @Nullable public Country getCountry() { if (country == null) { diff --git a/core/src/main/java/bisq/core/payment/NationalBankAccount.java b/core/src/main/java/bisq/core/payment/NationalBankAccount.java index b4f3b8a6f8..eba88a758d 100644 --- a/core/src/main/java/bisq/core/payment/NationalBankAccount.java +++ b/core/src/main/java/bisq/core/payment/NationalBankAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.BankAccountPayload; @@ -48,6 +49,11 @@ public final class NationalBankAccount extends CountryBasedPaymentAccount implem return SUPPORTED_CURRENCIES; } + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + @Override public String getBankId() { return ((BankAccountPayload) paymentAccountPayload).getBankId(); diff --git a/core/src/main/java/bisq/core/payment/NequiAccount.java b/core/src/main/java/bisq/core/payment/NequiAccount.java index 30021dff6b..a08f6b7ff6 100644 --- a/core/src/main/java/bisq/core/payment/NequiAccount.java +++ b/core/src/main/java/bisq/core/payment/NequiAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.NequiAccountPayload; @@ -50,14 +51,17 @@ public final class NequiAccount extends CountryBasedPaymentAccount { return ((NequiAccountPayload) paymentAccountPayload).getMobileNr(); } + @Override public String getMessageForBuyer() { return "payment.nequi.info.buyer"; } + @Override public String getMessageForSeller() { return "payment.nequi.info.seller"; } + @Override public String getMessageForAccountCreation() { return "payment.nequi.info.account"; } @@ -66,4 +70,9 @@ public final class NequiAccount extends CountryBasedPaymentAccount { public @NonNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } } diff --git a/core/src/main/java/bisq/core/payment/OKPayAccount.java b/core/src/main/java/bisq/core/payment/OKPayAccount.java index 448d2c47b8..552eb80b6a 100644 --- a/core/src/main/java/bisq/core/payment/OKPayAccount.java +++ b/core/src/main/java/bisq/core/payment/OKPayAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.OKPayAccountPayload; @@ -71,12 +72,16 @@ public final class OKPayAccount extends PaymentAccount { return new OKPayAccountPayload(paymentMethod.getId(), id); } - @NotNull @Override - public List getSupportedCurrencies() { + public @NotNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + @Override + public @NotNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public void setAccountNr(String accountNr) { ((OKPayAccountPayload) paymentAccountPayload).setAccountNr(accountNr); } diff --git a/core/src/main/java/bisq/core/payment/PaxumAccount.java b/core/src/main/java/bisq/core/payment/PaxumAccount.java index 19e33f1001..d232d43895 100644 --- a/core/src/main/java/bisq/core/payment/PaxumAccount.java +++ b/core/src/main/java/bisq/core/payment/PaxumAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaxumAccountPayload; @@ -63,12 +64,16 @@ public final class PaxumAccount extends PaymentAccount { return new PaxumAccountPayload(paymentMethod.getId(), id); } - @NotNull @Override - public List getSupportedCurrencies() { + public @NotNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + @Override + public @NotNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public void setEmail(String accountId) { ((PaxumAccountPayload) paymentAccountPayload).setEmail(accountId); } diff --git a/core/src/main/java/bisq/core/payment/PaymentAccount.java b/core/src/main/java/bisq/core/payment/PaymentAccount.java index b162b3e1e0..5ac6139509 100644 --- a/core/src/main/java/bisq/core/payment/PaymentAccount.java +++ b/core/src/main/java/bisq/core/payment/PaymentAccount.java @@ -17,11 +17,22 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountForm; +import bisq.core.api.model.PaymentAccountFormField; +import bisq.core.locale.Country; +import bisq.core.locale.CountryUtil; +import bisq.core.locale.CurrencyUtil; +import bisq.core.locale.Res; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.PaymentMethod; +import bisq.core.payment.validation.BICValidator; +import bisq.core.payment.validation.EmailOrMobileNrValidator; +import bisq.core.payment.validation.EmailValidator; +import bisq.core.payment.validation.IBANValidator; +import bisq.core.payment.validation.LengthValidator; import bisq.core.proto.CoreProtoResolver; - +import bisq.core.util.validation.InputValidator.ValidationResult; import bisq.common.proto.ProtoUtil; import bisq.common.proto.persistable.PersistablePayload; import bisq.common.util.Utilities; @@ -31,6 +42,8 @@ import java.util.Date; import java.util.List; import java.util.Optional; import java.util.UUID; +import java.util.function.Function; +import java.util.function.Predicate; import java.util.stream.Collectors; import lombok.EqualsAndHashCode; @@ -44,6 +57,9 @@ import javax.annotation.Nullable; import static bisq.core.payment.payload.PaymentMethod.TRANSFERWISE_ID; import static com.google.common.base.Preconditions.checkNotNull; +import static java.util.Arrays.stream; +import static java.util.Collections.singletonList; +import static java.util.stream.Collectors.toList; @EqualsAndHashCode @ToString @@ -265,4 +281,394 @@ public abstract class PaymentAccount implements PersistablePayload { @NonNull public abstract List getSupportedCurrencies(); + + // ------------------------- PAYMENT ACCOUNT FORM ------------------------- + + @NonNull + public abstract List getInputFieldIds(); + + public PaymentAccountForm toForm() { + PaymentAccountForm form = new PaymentAccountForm(PaymentAccountForm.FormId.valueOf(paymentMethod.getId())); + for (PaymentAccountFormField.FieldId fieldId : getInputFieldIds()) { + PaymentAccountFormField field = getEmptyFormField(fieldId); + form.getFields().add(field); + } + return form; + } + + public void validateFormField(PaymentAccountForm form, PaymentAccountFormField.FieldId fieldId, String value) { + switch (fieldId) { + case ACCEPTED_COUNTRY_CODES: { + List countryCodes = PaymentAccount.commaDelimitedCodesToList.apply(value); + List supportedCountryCodes = CountryUtil.getCountryCodes(((CountryBasedPaymentAccount) this).getSupportedCountries()); + for (String countryCode : countryCodes) { + if (!supportedCountryCodes.contains(countryCode)) throw new IllegalArgumentException("Country is not supported by " + getPaymentMethod().getId() + ": " + value); + } + break; + } + case ACCOUNT_ID: + throw new IllegalArgumentException("Not implemented"); + case ACCOUNT_NAME: + processValidationResult(new LengthValidator(2, 100).validate(value)); + break; + case ACCOUNT_NR: + throw new IllegalArgumentException("Not implemented"); + case ACCOUNT_OWNER: + throw new IllegalArgumentException("Not implemented"); + case ACCOUNT_TYPE: + throw new IllegalArgumentException("Not implemented"); + case ANSWER: + throw new IllegalArgumentException("Not implemented"); + case BANK_ACCOUNT_NAME: + throw new IllegalArgumentException("Not implemented"); + case BANK_ACCOUNT_NUMBER: + throw new IllegalArgumentException("Not implemented"); + case BANK_ACCOUNT_TYPE: + throw new IllegalArgumentException("Not implemented"); + case BANK_ADDRESS: + case INTERMEDIARY_ADDRESS: + processValidationResult(new LengthValidator(1, 100).validate(value)); + break; + case BANK_BRANCH: + case INTERMEDIARY_BRANCH: + processValidationResult(new LengthValidator(2, 34).validate(value)); + break; + case BANK_BRANCH_CODE: + throw new IllegalArgumentException("Not implemented"); + case BANK_BRANCH_NAME: + throw new IllegalArgumentException("Not implemented"); + case BANK_CODE: + throw new IllegalArgumentException("Not implemented"); + case BANK_COUNTRY_CODE: + if (!CountryUtil.findCountryByCode(value).isPresent()) throw new IllegalArgumentException("Invalid country code: " + value); + break; + case BANK_ID: + throw new IllegalArgumentException("Not implemented"); + case BANK_NAME: + case INTERMEDIARY_NAME: + processValidationResult(new LengthValidator(2, 34).validate(value)); + break; + case BANK_SWIFT_CODE: + case INTERMEDIARY_SWIFT_CODE: + processValidationResult(new LengthValidator(11, 11).validate(value)); + break; + case BENEFICIARY_ACCOUNT_NR: + processValidationResult(new LengthValidator(2, 40).validate(value)); + break; + case BENEFICIARY_ADDRESS: + processValidationResult(new LengthValidator(1, 100).validate(value)); + break; + case BENEFICIARY_CITY: + processValidationResult(new LengthValidator(2, 34).validate(value)); + break; + case BENEFICIARY_NAME: + processValidationResult(new LengthValidator(2, 34).validate(value)); + break; + case BENEFICIARY_PHONE: + processValidationResult(new LengthValidator(2, 34).validate(value)); + break; + case BIC: + processValidationResult(new BICValidator().validate(value)); + break; + case BRANCH_ID: + throw new IllegalArgumentException("Not implemented"); + case CITY: + processValidationResult(new LengthValidator(2, 34).validate(value)); + break; + case CONTACT: + checkNotEmpty(value); + break; + case COUNTRY: + List supportedCountries = ((CountryBasedPaymentAccount) this).getSupportedCountries(); + if (supportedCountries == null || supportedCountries.isEmpty()) { + if (!CountryUtil.findCountryByCode(value).isPresent()) throw new IllegalArgumentException("Invalid country code: " + value); + } else { + System.out.println("BUT WE SUPPORT THESE COUNTRIES!"); + System.out.println(supportedCountries); + List supportedCountryCodes = CountryUtil.getCountryCodes(supportedCountries); + if (!supportedCountryCodes.contains(value)) throw new IllegalArgumentException("Country is not supported by " + getPaymentMethod().getId() + ": " + value); + } + break; + case EMAIL: + checkNotEmpty(value); + processValidationResult(new EmailValidator().validate(value)); + break; + case EMAIL_OR_MOBILE_NR: + checkNotEmpty(value); + processValidationResult(new EmailOrMobileNrValidator().validate(value)); + break; + case EXTRA_INFO: + break; + case HOLDER_ADDRESS: + throw new IllegalArgumentException("Not implemented"); + case HOLDER_EMAIL: + throw new IllegalArgumentException("Not implemented"); + case HOLDER_NAME: + processValidationResult(new LengthValidator(2, 100).validate(value)); + break; + case HOLDER_TAX_ID: + throw new IllegalArgumentException("Not implemented"); + case IBAN: + processValidationResult(new IBANValidator().validate(value)); + break; + case IFSC: + throw new IllegalArgumentException("Not implemented"); + case INTERMEDIARY_COUNTRY_CODE: + if (!CountryUtil.findCountryByCode(value).isPresent()) throw new IllegalArgumentException("Invalid country code: " + value); // TODO: value must be within supported countries unless all countries supported + break; + case MOBILE_NR: + throw new IllegalArgumentException("Not implemented"); + case NATIONAL_ACCOUNT_ID: + throw new IllegalArgumentException("Not implemented"); + case PAYID: + throw new IllegalArgumentException("Not implemented"); + case PIX_KEY: + throw new IllegalArgumentException("Not implemented"); + case POSTAL_ADDRESS: + throw new IllegalArgumentException("Not implemented"); + case PROMPT_PAY_ID: + throw new IllegalArgumentException("Not implemented"); + case QUESTION: + throw new IllegalArgumentException("Not implemented"); + case REQUIREMENTS: + throw new IllegalArgumentException("Not implemented"); + case SALT: + if (!value.equals("")) throw new IllegalArgumentException("Salt must be empty"); + break; + case SORT_CODE: + throw new IllegalArgumentException("Not implemented"); + case SPECIAL_INSTRUCTIONS: + break; + case STATE: + throw new IllegalArgumentException("Not implemented"); + case TRADE_CURRENCIES: + checkNotEmpty(value); + List currencyCodes = commaDelimitedCodesToList.apply(value); + Optional> tradeCurrencies = CurrencyUtil.getTradeCurrenciesInList(currencyCodes, getSupportedCurrencies()); + if (!tradeCurrencies.isPresent()) throw new IllegalArgumentException("No trade currencies were found in the " + getPaymentMethod().getDisplayString() + " account form"); + break; + case USER_NAME: + checkNotEmpty(value); + processValidationResult(new LengthValidator(3, 100).validate(value)); + break; + case VIRTUAL_PAYMENT_ADDRESS: + throw new IllegalArgumentException("Not implemented"); + default: + throw new RuntimeException("Unhandled form field: " + fieldId); + } + } + + protected void checkNotEmpty(String input) { + if (input == null || "".equals(input)) throw new IllegalArgumentException("Field must not be empty"); + } + + protected void processValidationResult(ValidationResult result) { + if (!result.isValid) throw new IllegalArgumentException(result.errorMessage); + } + + protected PaymentAccountFormField getEmptyFormField(PaymentAccountFormField.FieldId fieldId) { + PaymentAccountFormField field = new PaymentAccountFormField(fieldId); + switch (fieldId) { + case ACCEPTED_COUNTRY_CODES: + field.setComponent(PaymentAccountFormField.Component.SELECT_MULTIPLE); + field.setLabel("Accepted country codes"); + field.setSupportedCountries(((CountryBasedPaymentAccount) this).getSupportedCountries()); + break; + case ACCOUNT_ID: + throw new IllegalArgumentException("Not implemented"); + case ACCOUNT_NAME: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("Account name"); // TODO: pull all labels from language file + field.setMinLength(3); + field.setMaxLength(100); + break; + case ACCOUNT_NR: + throw new IllegalArgumentException("Not implemented"); + case ACCOUNT_OWNER: + throw new IllegalArgumentException("Not implemented"); + case ACCOUNT_TYPE: + throw new IllegalArgumentException("Not implemented"); + case ANSWER: + throw new IllegalArgumentException("Not implemented"); + case BANK_ACCOUNT_NAME: + throw new IllegalArgumentException("Not implemented"); + case BANK_ACCOUNT_NUMBER: + throw new IllegalArgumentException("Not implemented"); + case BANK_ACCOUNT_TYPE: + throw new IllegalArgumentException("Not implemented"); + case BANK_ADDRESS: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("Receiving Bank address"); + break; + case BANK_BRANCH: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("Receiving Bank branch"); + break; + case BANK_BRANCH_CODE: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("Receiving Bank SWIFT code"); // TODO: only used for swift? + break; + case BANK_BRANCH_NAME: + throw new IllegalArgumentException("Not implemented"); + case BANK_CODE: + throw new IllegalArgumentException("Not implemented"); + case BANK_COUNTRY_CODE: + field.setComponent(PaymentAccountFormField.Component.SELECT_ONE); + field.setLabel("Country of bank"); + break; + case BANK_ID: + throw new IllegalArgumentException("Not implemented"); + case BANK_NAME: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("Receiving Bank name"); + break; + case BANK_SWIFT_CODE: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("Receiving Bank SWIFT Code"); + break; + case BENEFICIARY_ACCOUNT_NR: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("Account No. (or IBAN)"); + break; + case BENEFICIARY_ADDRESS: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("Beneficiary address"); + break; + case BENEFICIARY_CITY: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("Beneficiary city"); + break; + case BENEFICIARY_NAME: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("Account owner full name"); + break; + case BENEFICIARY_PHONE: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("Beneficiary phone number"); + break; + case BIC: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("BIC"); + break; + case BRANCH_ID: + throw new IllegalArgumentException("Not implemented"); + case CITY: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel(Res.get("Contact")); + case CONTACT: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("City"); + case COUNTRY: + field.setComponent(PaymentAccountFormField.Component.SELECT_ONE); + field.setLabel("Country"); + field.setSupportedCountries(((CountryBasedPaymentAccount) this).getSupportedCountries()); + break; + case EMAIL: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setType("email"); + field.setLabel("Email"); + break; + case EMAIL_OR_MOBILE_NR: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("Email or mobile number"); + break; + case EXTRA_INFO: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("Optional additional information"); + break; + case HOLDER_ADDRESS: + throw new IllegalArgumentException("Not implemented"); + case HOLDER_EMAIL: + throw new IllegalArgumentException("Not implemented"); + case HOLDER_NAME: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("Account owner full name"); + field.setMinLength(2); + field.setMaxLength(100); + break; + case HOLDER_TAX_ID: + throw new IllegalArgumentException("Not implemented"); + case IBAN: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("IBAN"); + break; + case IFSC: + throw new IllegalArgumentException("Not implemented"); + case INTERMEDIARY_ADDRESS: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("Intermediary Bank address"); + break; + case INTERMEDIARY_BRANCH: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("Intermediary Bank branch"); + break; + case INTERMEDIARY_COUNTRY_CODE: + field.setComponent(PaymentAccountFormField.Component.SELECT_ONE); + field.setLabel("Intermediary Bank country"); + break; + case INTERMEDIARY_NAME: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("Intermediary Bank name"); + break; + case INTERMEDIARY_SWIFT_CODE: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("Intermediary Bank SWIFT Code"); // TODO: swift only? + break; + case MOBILE_NR: + throw new IllegalArgumentException("Not implemented"); + case NATIONAL_ACCOUNT_ID: + throw new IllegalArgumentException("Not implemented"); + case PAYID: + throw new IllegalArgumentException("Not implemented"); + case PIX_KEY: + throw new IllegalArgumentException("Not implemented"); + case POSTAL_ADDRESS: + throw new IllegalArgumentException("Not implemented"); + case PROMPT_PAY_ID: + throw new IllegalArgumentException("Not implemented"); + case QUESTION: + throw new IllegalArgumentException("Not implemented"); + case REQUIREMENTS: + throw new IllegalArgumentException("Not implemented"); + case SALT: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("Salt"); + break; + case SORT_CODE: + throw new IllegalArgumentException("Not implemented"); + case SPECIAL_INSTRUCTIONS: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("Special instructions"); + break; + case STATE: + throw new IllegalArgumentException("Not implemented"); + case TRADE_CURRENCIES: + field.setComponent(PaymentAccountFormField.Component.SELECT_MULTIPLE); + field.setLabel("Supported currencies"); + field.setSupportedCurrencies(getSupportedCurrencies()); + break; + case USER_NAME: + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("User name"); + field.setMinLength(3); + field.setMaxLength(100); + break; + case VIRTUAL_PAYMENT_ADDRESS: + throw new IllegalArgumentException("Not implemented"); + default: + throw new RuntimeException("Unhandled form field: " + field); + } + if ("".equals(field.getValue())) field.setValue(""); + return field; + } + + private static final Predicate isCommaDelimitedCurrencyList = (s) -> s != null && s.contains(","); + public static final Function> commaDelimitedCodesToList = (s) -> { + if (isCommaDelimitedCurrencyList.test(s)) + return stream(s.split(",")).map(a -> a.trim().toUpperCase()).collect(toList()); + else if (s != null && !s.isEmpty()) + return singletonList(s.trim().toUpperCase()); + else + return new ArrayList<>(); + }; } diff --git a/core/src/main/java/bisq/core/payment/PayseraAccount.java b/core/src/main/java/bisq/core/payment/PayseraAccount.java index 078e7d5e00..0d8fc82218 100644 --- a/core/src/main/java/bisq/core/payment/PayseraAccount.java +++ b/core/src/main/java/bisq/core/payment/PayseraAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaymentAccountPayload; @@ -77,12 +78,16 @@ public final class PayseraAccount extends PaymentAccount { return new PayseraAccountPayload(paymentMethod.getId(), id); } - @NotNull @Override - public List getSupportedCurrencies() { + public @NotNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + @Override + public @NotNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public void setEmail(String accountId) { ((PayseraAccountPayload) paymentAccountPayload).setEmail(accountId); } diff --git a/core/src/main/java/bisq/core/payment/PerfectMoneyAccount.java b/core/src/main/java/bisq/core/payment/PerfectMoneyAccount.java index cafdfec4e1..c6a83fcedf 100644 --- a/core/src/main/java/bisq/core/payment/PerfectMoneyAccount.java +++ b/core/src/main/java/bisq/core/payment/PerfectMoneyAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaymentAccountPayload; @@ -48,6 +49,11 @@ public final class PerfectMoneyAccount extends PaymentAccount { return SUPPORTED_CURRENCIES; } + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public void setAccountNr(String accountNr) { ((PerfectMoneyAccountPayload) paymentAccountPayload).setAccountNr(accountNr); } diff --git a/core/src/main/java/bisq/core/payment/PixAccount.java b/core/src/main/java/bisq/core/payment/PixAccount.java index 36f221c0db..fe20ad9e6d 100644 --- a/core/src/main/java/bisq/core/payment/PixAccount.java +++ b/core/src/main/java/bisq/core/payment/PixAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaymentAccountPayload; @@ -50,14 +51,17 @@ public final class PixAccount extends CountryBasedPaymentAccount { return ((PixAccountPayload) paymentAccountPayload).getPixKey(); } + @Override public String getMessageForBuyer() { return "payment.pix.info.buyer"; } + @Override public String getMessageForSeller() { return "payment.pix.info.seller"; } + @Override public String getMessageForAccountCreation() { return "payment.pix.info.account"; } @@ -66,4 +70,9 @@ public final class PixAccount extends CountryBasedPaymentAccount { public @NonNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } } diff --git a/core/src/main/java/bisq/core/payment/PopmoneyAccount.java b/core/src/main/java/bisq/core/payment/PopmoneyAccount.java index 2c9f3892d1..c2642cf26c 100644 --- a/core/src/main/java/bisq/core/payment/PopmoneyAccount.java +++ b/core/src/main/java/bisq/core/payment/PopmoneyAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaymentAccountPayload; @@ -49,6 +50,11 @@ public final class PopmoneyAccount extends PaymentAccount { return SUPPORTED_CURRENCIES; } + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public void setAccountId(String accountId) { ((PopmoneyAccountPayload) paymentAccountPayload).setAccountId(accountId); } diff --git a/core/src/main/java/bisq/core/payment/PromptPayAccount.java b/core/src/main/java/bisq/core/payment/PromptPayAccount.java index 6c3eb9b435..6167d70a34 100644 --- a/core/src/main/java/bisq/core/payment/PromptPayAccount.java +++ b/core/src/main/java/bisq/core/payment/PromptPayAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaymentAccountPayload; @@ -48,6 +49,11 @@ public final class PromptPayAccount extends PaymentAccount { return SUPPORTED_CURRENCIES; } + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public void setPromptPayId(String promptPayId) { ((PromptPayAccountPayload) paymentAccountPayload).setPromptPayId(promptPayId); } diff --git a/core/src/main/java/bisq/core/payment/RevolutAccount.java b/core/src/main/java/bisq/core/payment/RevolutAccount.java index 59b610abe3..1a616fc228 100644 --- a/core/src/main/java/bisq/core/payment/RevolutAccount.java +++ b/core/src/main/java/bisq/core/payment/RevolutAccount.java @@ -17,20 +17,27 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.PaymentMethod; import bisq.core.payment.payload.RevolutAccountPayload; - import java.util.List; - +import java.util.stream.Collectors; import lombok.EqualsAndHashCode; import lombok.NonNull; @EqualsAndHashCode(callSuper = true) public final class RevolutAccount extends PaymentAccount { + private static final List INPUT_FIELD_IDS = List.of( + PaymentAccountFormField.FieldId.USER_NAME, + PaymentAccountFormField.FieldId.TRADE_CURRENCIES, + PaymentAccountFormField.FieldId.ACCOUNT_NAME, + PaymentAccountFormField.FieldId.SALT + ); + // https://www.revolut.com/help/getting-started/exchanging-currencies/what-fiat-currencies-are-supported-for-holding-and-exchange public static final List SUPPORTED_CURRENCIES = List.of( new FiatCurrency("AED"), @@ -108,8 +115,20 @@ public final class RevolutAccount extends PaymentAccount { revolutAccountPayload().maybeApplyUserNameToAccountId(); } + @Override + public @NonNull List getInputFieldIds() { + return INPUT_FIELD_IDS; + } + @Override public @NonNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + + @Override + protected PaymentAccountFormField getEmptyFormField(PaymentAccountFormField.FieldId fieldId) { + var field = super.getEmptyFormField(fieldId); + if (field.getId() == PaymentAccountFormField.FieldId.TRADE_CURRENCIES) field.setValue(String.join(",", getSupportedCurrencies().stream().map(TradeCurrency::getCode).collect(Collectors.toList()))); + return field; + } } diff --git a/core/src/main/java/bisq/core/payment/SameBankAccount.java b/core/src/main/java/bisq/core/payment/SameBankAccount.java index e08c683cc1..b0f276131a 100644 --- a/core/src/main/java/bisq/core/payment/SameBankAccount.java +++ b/core/src/main/java/bisq/core/payment/SameBankAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.BankAccountPayload; @@ -48,6 +49,11 @@ public final class SameBankAccount extends CountryBasedPaymentAccount implements return SUPPORTED_CURRENCIES; } + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + @Override public String getBankId() { return ((BankAccountPayload) paymentAccountPayload).getBankId(); diff --git a/core/src/main/java/bisq/core/payment/SatispayAccount.java b/core/src/main/java/bisq/core/payment/SatispayAccount.java index 7a40bac6ae..82773a9606 100644 --- a/core/src/main/java/bisq/core/payment/SatispayAccount.java +++ b/core/src/main/java/bisq/core/payment/SatispayAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaymentAccountPayload; @@ -58,14 +59,17 @@ public final class SatispayAccount extends CountryBasedPaymentAccount { return ((SatispayAccountPayload) paymentAccountPayload).getMobileNr(); } + @Override public String getMessageForBuyer() { return "payment.satispay.info.buyer"; } + @Override public String getMessageForSeller() { return "payment.satispay.info.seller"; } + @Override public String getMessageForAccountCreation() { return "payment.satispay.info.account"; } @@ -74,4 +78,9 @@ public final class SatispayAccount extends CountryBasedPaymentAccount { public @NonNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } } diff --git a/core/src/main/java/bisq/core/payment/SepaAccount.java b/core/src/main/java/bisq/core/payment/SepaAccount.java index be1a93a732..2f35ef48cf 100644 --- a/core/src/main/java/bisq/core/payment/SepaAccount.java +++ b/core/src/main/java/bisq/core/payment/SepaAccount.java @@ -17,15 +17,18 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountForm; +import bisq.core.api.model.PaymentAccountFormField; +import bisq.core.locale.Country; import bisq.core.locale.CountryUtil; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.PaymentMethod; import bisq.core.payment.payload.SepaAccountPayload; - +import bisq.core.payment.validation.SepaIBANValidator; import java.util.List; - +import javax.annotation.Nullable; import lombok.EqualsAndHashCode; import org.jetbrains.annotations.NotNull; @@ -33,6 +36,16 @@ import org.jetbrains.annotations.NotNull; @EqualsAndHashCode(callSuper = true) public final class SepaAccount extends CountryBasedPaymentAccount implements BankAccount { + private static final List INPUT_FIELD_IDS = List.of( + PaymentAccountFormField.FieldId.ACCOUNT_NAME, + PaymentAccountFormField.FieldId.HOLDER_NAME, + PaymentAccountFormField.FieldId.IBAN, + PaymentAccountFormField.FieldId.BIC, + PaymentAccountFormField.FieldId.COUNTRY, + PaymentAccountFormField.FieldId.ACCEPTED_COUNTRY_CODES, + PaymentAccountFormField.FieldId.SALT + ); + public static final List SUPPORTED_CURRENCIES = List.of(new FiatCurrency("EUR")); public SepaAccount() { @@ -78,6 +91,10 @@ public final class SepaAccount extends CountryBasedPaymentAccount implements Ban public List getAcceptedCountryCodes() { return ((SepaAccountPayload) paymentAccountPayload).getAcceptedCountryCodes(); } + + public void setAcceptedCountryCodes(List acceptedCountryCodes) { + ((SepaAccountPayload) paymentAccountPayload).setAcceptedCountryCodes(acceptedCountryCodes); + } public void addAcceptedCountry(String countryCode) { ((SepaAccountPayload) paymentAccountPayload).addAcceptedCountry(countryCode); @@ -99,9 +116,44 @@ public final class SepaAccount extends CountryBasedPaymentAccount implements Ban ((SepaAccountPayload) paymentAccountPayload).revertChanges(); } - @NotNull @Override - public List getSupportedCurrencies() { + public @NotNull List getInputFieldIds() { + return INPUT_FIELD_IDS; + } + + @Override + public @NotNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + + @Override + @Nullable + public List getSupportedCountries() { + return CountryUtil.getAllSepaCountries(); + } + + @Override + public void validateFormField(PaymentAccountForm form, PaymentAccountFormField.FieldId fieldId, String value) { + switch (fieldId) { + case IBAN: + processValidationResult(new SepaIBANValidator().validate(value)); + break; + default: + super.validateFormField(form, fieldId, value); + } + } + + @Override + protected PaymentAccountFormField getEmptyFormField(PaymentAccountFormField.FieldId fieldId) { + var field = super.getEmptyFormField(fieldId); + switch (fieldId) { + case ACCEPTED_COUNTRY_CODES: + field.setSupportedSepaEuroCountries(CountryUtil.getAllSepaEuroCountries()); + field.setSupportedSepaNonEuroCountries(CountryUtil.getAllSepaNonEuroCountries()); + break; + default: + // no action + } + return field; + } } diff --git a/core/src/main/java/bisq/core/payment/SepaInstantAccount.java b/core/src/main/java/bisq/core/payment/SepaInstantAccount.java index 6ad8669e8e..9102de77d2 100644 --- a/core/src/main/java/bisq/core/payment/SepaInstantAccount.java +++ b/core/src/main/java/bisq/core/payment/SepaInstantAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.CountryUtil; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; @@ -99,9 +100,13 @@ public final class SepaInstantAccount extends CountryBasedPaymentAccount impleme ((SepaInstantAccountPayload) paymentAccountPayload).revertChanges(); } - @NotNull @Override - public List getSupportedCurrencies() { + public @NotNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + + @Override + public @NotNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } } diff --git a/core/src/main/java/bisq/core/payment/SpecificBanksAccount.java b/core/src/main/java/bisq/core/payment/SpecificBanksAccount.java index 4950b98d6c..e8ce48e250 100644 --- a/core/src/main/java/bisq/core/payment/SpecificBanksAccount.java +++ b/core/src/main/java/bisq/core/payment/SpecificBanksAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaymentAccountPayload; @@ -48,6 +49,11 @@ public final class SpecificBanksAccount extends CountryBasedPaymentAccount imple return SUPPORTED_CURRENCIES; } + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + // TODO change to List public ArrayList getAcceptedBanks() { return ((SpecificBanksAccountPayload) paymentAccountPayload).getAcceptedBanks(); diff --git a/core/src/main/java/bisq/core/payment/StrikeAccount.java b/core/src/main/java/bisq/core/payment/StrikeAccount.java index 6ae4933b16..00e7116a12 100644 --- a/core/src/main/java/bisq/core/payment/StrikeAccount.java +++ b/core/src/main/java/bisq/core/payment/StrikeAccount.java @@ -17,14 +17,16 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; +import bisq.core.locale.Country; +import bisq.core.locale.CountryUtil; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.PaymentMethod; import bisq.core.payment.payload.StrikeAccountPayload; - import java.util.List; - +import javax.annotation.Nullable; import lombok.EqualsAndHashCode; import org.jetbrains.annotations.NotNull; @@ -33,6 +35,14 @@ import org.jetbrains.annotations.NotNull; public final class StrikeAccount extends CountryBasedPaymentAccount { public static final List SUPPORTED_CURRENCIES = List.of(new FiatCurrency("USD")); + public static final List SUPPORTED_COUNTRIES = CountryUtil.getCountries(List.of("US")); + + private static final List INPUT_FIELD_IDS = List.of( + PaymentAccountFormField.FieldId.ACCOUNT_NAME, + PaymentAccountFormField.FieldId.COUNTRY, + PaymentAccountFormField.FieldId.HOLDER_NAME, + PaymentAccountFormField.FieldId.SALT + ); public StrikeAccount() { super(PaymentMethod.STRIKE); @@ -53,21 +63,35 @@ public final class StrikeAccount extends CountryBasedPaymentAccount { return ((StrikeAccountPayload) paymentAccountPayload).getHolderName(); } + @Override public String getMessageForBuyer() { return "payment.strike.info.buyer"; } + @Override public String getMessageForSeller() { return "payment.strike.info.seller"; } + @Override public String getMessageForAccountCreation() { return "payment.strike.info.account"; } - @NotNull @Override - public List getSupportedCurrencies() { + public @NotNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + + @Override + @Nullable + public @NotNull List getSupportedCountries() { + System.out.println("STIKE RETURNING SUPPORTED COUNTRIES: " + SUPPORTED_COUNTRIES); + return SUPPORTED_COUNTRIES; + } + + @Override + public @NotNull List getInputFieldIds() { + return INPUT_FIELD_IDS; + } } diff --git a/core/src/main/java/bisq/core/payment/SwiftAccount.java b/core/src/main/java/bisq/core/payment/SwiftAccount.java index 683ee45e43..20dfd671a1 100644 --- a/core/src/main/java/bisq/core/payment/SwiftAccount.java +++ b/core/src/main/java/bisq/core/payment/SwiftAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.PaymentMethod; @@ -36,6 +37,27 @@ public final class SwiftAccount extends PaymentAccount { public static final List SUPPORTED_CURRENCIES = new ArrayList<>(getAllSortedFiatCurrencies(comparing(TradeCurrency::getCode))); + private static final List INPUT_FIELD_IDS = List.of( + PaymentAccountFormField.FieldId.ACCOUNT_NAME, + PaymentAccountFormField.FieldId.BANK_SWIFT_CODE, + PaymentAccountFormField.FieldId.BANK_COUNTRY_CODE, + PaymentAccountFormField.FieldId.BANK_NAME, + PaymentAccountFormField.FieldId.BANK_BRANCH, + PaymentAccountFormField.FieldId.BANK_ADDRESS, + PaymentAccountFormField.FieldId.INTERMEDIARY_SWIFT_CODE, + PaymentAccountFormField.FieldId.INTERMEDIARY_COUNTRY_CODE, + PaymentAccountFormField.FieldId.INTERMEDIARY_NAME, + PaymentAccountFormField.FieldId.INTERMEDIARY_BRANCH, + PaymentAccountFormField.FieldId.INTERMEDIARY_ADDRESS, + PaymentAccountFormField.FieldId.BENEFICIARY_NAME, + PaymentAccountFormField.FieldId.BENEFICIARY_ACCOUNT_NR, + PaymentAccountFormField.FieldId.BENEFICIARY_ADDRESS, + PaymentAccountFormField.FieldId.BENEFICIARY_CITY, + PaymentAccountFormField.FieldId.BENEFICIARY_PHONE, + PaymentAccountFormField.FieldId.SPECIAL_INSTRUCTIONS, + PaymentAccountFormField.FieldId.SALT + ); + public SwiftAccount() { super(PaymentMethod.SWIFT); tradeCurrencies.addAll(SUPPORTED_CURRENCIES); @@ -50,14 +72,17 @@ public final class SwiftAccount extends PaymentAccount { return ((SwiftAccountPayload) this.paymentAccountPayload); } + @Override public String getMessageForBuyer() { return "payment.swift.info.buyer"; } + @Override public String getMessageForSeller() { return "payment.swift.info.seller"; } + @Override public String getMessageForAccountCreation() { return "payment.swift.info.account"; } @@ -66,4 +91,9 @@ public final class SwiftAccount extends PaymentAccount { public @NonNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + + @Override + public @NonNull List getInputFieldIds() { + return INPUT_FIELD_IDS; + } } diff --git a/core/src/main/java/bisq/core/payment/SwishAccount.java b/core/src/main/java/bisq/core/payment/SwishAccount.java index 0292e27e03..1ab95f5d5f 100644 --- a/core/src/main/java/bisq/core/payment/SwishAccount.java +++ b/core/src/main/java/bisq/core/payment/SwishAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaymentAccountPayload; @@ -48,6 +49,11 @@ public final class SwishAccount extends PaymentAccount { return SUPPORTED_CURRENCIES; } + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public void setMobileNr(String mobileNr) { ((SwishAccountPayload) paymentAccountPayload).setMobileNr(mobileNr); } diff --git a/core/src/main/java/bisq/core/payment/TikkieAccount.java b/core/src/main/java/bisq/core/payment/TikkieAccount.java index 21bd984a9b..a89b3820f0 100644 --- a/core/src/main/java/bisq/core/payment/TikkieAccount.java +++ b/core/src/main/java/bisq/core/payment/TikkieAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaymentAccountPayload; @@ -53,21 +54,28 @@ public final class TikkieAccount extends CountryBasedPaymentAccount { return ((TikkieAccountPayload) paymentAccountPayload).getIban(); } + @Override public String getMessageForBuyer() { return "payment.tikkie.info.buyer"; } + @Override public String getMessageForSeller() { return "payment.tikkie.info.seller"; } + @Override public String getMessageForAccountCreation() { return "payment.tikkie.info.account"; } - @NotNull @Override - public List getSupportedCurrencies() { + public @NotNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + + @Override + public @NotNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } } diff --git a/core/src/main/java/bisq/core/payment/TransferwiseAccount.java b/core/src/main/java/bisq/core/payment/TransferwiseAccount.java index ad5efdc6a7..4ede998ee6 100644 --- a/core/src/main/java/bisq/core/payment/TransferwiseAccount.java +++ b/core/src/main/java/bisq/core/payment/TransferwiseAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaymentAccountPayload; @@ -24,14 +25,20 @@ import bisq.core.payment.payload.PaymentMethod; import bisq.core.payment.payload.TransferwiseAccountPayload; import java.util.List; - +import java.util.Map; import lombok.EqualsAndHashCode; - -import org.jetbrains.annotations.NotNull; +import lombok.NonNull; @EqualsAndHashCode(callSuper = true) public final class TransferwiseAccount extends PaymentAccount { + private static final List INPUT_FIELD_IDS = List.of( + PaymentAccountFormField.FieldId.EMAIL, + PaymentAccountFormField.FieldId.TRADE_CURRENCIES, + PaymentAccountFormField.FieldId.ACCOUNT_NAME, + PaymentAccountFormField.FieldId.SALT + ); + // https://github.com/bisq-network/proposals/issues/243 public static final List SUPPORTED_CURRENCIES = List.of( new FiatCurrency("AED"), @@ -87,9 +94,13 @@ public final class TransferwiseAccount extends PaymentAccount { return new TransferwiseAccountPayload(paymentMethod.getId(), id); } - @NotNull @Override - public List getSupportedCurrencies() { + public @NonNull List getInputFieldIds() { + return INPUT_FIELD_IDS; + } + + @Override + public @NonNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } @@ -100,4 +111,11 @@ public final class TransferwiseAccount extends PaymentAccount { public String getEmail() { return ((TransferwiseAccountPayload) paymentAccountPayload).getEmail(); } + + @Override + protected PaymentAccountFormField getEmptyFormField(PaymentAccountFormField.FieldId fieldId) { + var field = super.getEmptyFormField(fieldId); + if (field.getId() == PaymentAccountFormField.FieldId.TRADE_CURRENCIES) field.setLabel("Currencies for receiving funds"); + return field; + } } diff --git a/core/src/main/java/bisq/core/payment/TransferwiseUsdAccount.java b/core/src/main/java/bisq/core/payment/TransferwiseUsdAccount.java index b27d760c2e..99c4e8d836 100644 --- a/core/src/main/java/bisq/core/payment/TransferwiseUsdAccount.java +++ b/core/src/main/java/bisq/core/payment/TransferwiseUsdAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaymentAccountPayload; @@ -69,21 +70,28 @@ public final class TransferwiseUsdAccount extends CountryBasedPaymentAccount { return ((TransferwiseUsdAccountPayload) paymentAccountPayload).getBeneficiaryAddress(); } + @Override public String getMessageForBuyer() { return "payment.transferwiseUsd.info.buyer"; } + @Override public String getMessageForSeller() { return "payment.transferwiseUsd.info.seller"; } + @Override public String getMessageForAccountCreation() { return "payment.transferwiseUsd.info.account"; } - @NotNull @Override - public List getSupportedCurrencies() { + public @NotNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + + @Override + public @NotNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } } diff --git a/core/src/main/java/bisq/core/payment/USPostalMoneyOrderAccount.java b/core/src/main/java/bisq/core/payment/USPostalMoneyOrderAccount.java index 443a468760..78450cc3ed 100644 --- a/core/src/main/java/bisq/core/payment/USPostalMoneyOrderAccount.java +++ b/core/src/main/java/bisq/core/payment/USPostalMoneyOrderAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaymentAccountPayload; @@ -48,6 +49,11 @@ public final class USPostalMoneyOrderAccount extends PaymentAccount { return SUPPORTED_CURRENCIES; } + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public void setPostalAddress(String postalAddress) { ((USPostalMoneyOrderAccountPayload) paymentAccountPayload).setPostalAddress(postalAddress); } diff --git a/core/src/main/java/bisq/core/payment/UpholdAccount.java b/core/src/main/java/bisq/core/payment/UpholdAccount.java index a64441e90f..72340cb841 100644 --- a/core/src/main/java/bisq/core/payment/UpholdAccount.java +++ b/core/src/main/java/bisq/core/payment/UpholdAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaymentAccountPayload; @@ -70,12 +71,16 @@ public final class UpholdAccount extends PaymentAccount { return new UpholdAccountPayload(paymentMethod.getId(), id); } - @NotNull @Override - public List getSupportedCurrencies() { + public @NotNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + @Override + public @NotNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public void setAccountId(String accountId) { ((UpholdAccountPayload) paymentAccountPayload).setAccountId(accountId); } diff --git a/core/src/main/java/bisq/core/payment/VenmoAccount.java b/core/src/main/java/bisq/core/payment/VenmoAccount.java index 568bab0221..e6b868a357 100644 --- a/core/src/main/java/bisq/core/payment/VenmoAccount.java +++ b/core/src/main/java/bisq/core/payment/VenmoAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaymentAccountPayload; @@ -51,6 +52,11 @@ public final class VenmoAccount extends PaymentAccount { return SUPPORTED_CURRENCIES; } + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public void setVenmoUserName(String venmoUserName) { ((VenmoAccountPayload) paymentAccountPayload).setVenmoUserName(venmoUserName); } diff --git a/core/src/main/java/bisq/core/payment/VerseAccount.java b/core/src/main/java/bisq/core/payment/VerseAccount.java index 63bd53afc1..c32f93de82 100644 --- a/core/src/main/java/bisq/core/payment/VerseAccount.java +++ b/core/src/main/java/bisq/core/payment/VerseAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaymentAccountPayload; @@ -57,14 +58,17 @@ public final class VerseAccount extends PaymentAccount { return ((VerseAccountPayload) paymentAccountPayload).getHolderName(); } + @Override public String getMessageForBuyer() { return "payment.verse.info.buyer"; } + @Override public String getMessageForSeller() { return "payment.verse.info.seller"; } + @Override public String getMessageForAccountCreation() { return "payment.verse.info.account"; } @@ -73,4 +77,9 @@ public final class VerseAccount extends PaymentAccount { public @NonNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } + + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } } diff --git a/core/src/main/java/bisq/core/payment/WeChatPayAccount.java b/core/src/main/java/bisq/core/payment/WeChatPayAccount.java index 8b76b4ca38..bae5a2f616 100644 --- a/core/src/main/java/bisq/core/payment/WeChatPayAccount.java +++ b/core/src/main/java/bisq/core/payment/WeChatPayAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.FiatCurrency; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaymentAccountPayload; @@ -48,6 +49,11 @@ public final class WeChatPayAccount extends PaymentAccount { return SUPPORTED_CURRENCIES; } + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public void setAccountNr(String accountNr) { ((WeChatPayAccountPayload) paymentAccountPayload).setAccountNr(accountNr); } diff --git a/core/src/main/java/bisq/core/payment/WesternUnionAccount.java b/core/src/main/java/bisq/core/payment/WesternUnionAccount.java index a268af2786..a1ab90e497 100644 --- a/core/src/main/java/bisq/core/payment/WesternUnionAccount.java +++ b/core/src/main/java/bisq/core/payment/WesternUnionAccount.java @@ -17,6 +17,7 @@ package bisq.core.payment; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.TradeCurrency; import bisq.core.payment.payload.PaymentAccountPayload; @@ -45,6 +46,11 @@ public final class WesternUnionAccount extends CountryBasedPaymentAccount { return SUPPORTED_CURRENCIES; } + @Override + public @NonNull List getInputFieldIds() { + throw new RuntimeException("Not implemented"); + } + public String getEmail() { return ((WesternUnionAccountPayload) paymentAccountPayload).getEmail(); } diff --git a/core/src/main/java/bisq/core/payment/payload/AchTransferAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/AchTransferAccountPayload.java index 0e7b697097..3f234c4778 100644 --- a/core/src/main/java/bisq/core/payment/payload/AchTransferAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/AchTransferAccountPayload.java @@ -20,8 +20,9 @@ package bisq.core.payment.payload; import bisq.core.locale.Res; import com.google.protobuf.Message; - +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; @@ -50,6 +51,7 @@ public final class AchTransferAccountPayload extends BankAccountPayload { private AchTransferAccountPayload(String paymentMethodName, String id, String countryCode, + List acceptedCountryCodes, String holderName, String bankName, String branchId, @@ -61,6 +63,7 @@ public final class AchTransferAccountPayload extends BankAccountPayload { super(paymentMethodName, id, countryCode, + acceptedCountryCodes, holderName, bankName, branchId, @@ -98,6 +101,7 @@ public final class AchTransferAccountPayload extends BankAccountPayload { return new AchTransferAccountPayload(proto.getPaymentMethodId(), proto.getId(), countryBasedPaymentAccountPayload.getCountryCode(), + new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()), bankAccountPayloadPB.getHolderName(), bankAccountPayloadPB.getBankName().isEmpty() ? null : bankAccountPayloadPB.getBankName(), bankAccountPayloadPB.getBranchId().isEmpty() ? null : bankAccountPayloadPB.getBranchId(), diff --git a/core/src/main/java/bisq/core/payment/payload/BankAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/BankAccountPayload.java index ed398684d8..15e02475d6 100644 --- a/core/src/main/java/bisq/core/payment/payload/BankAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/BankAccountPayload.java @@ -22,7 +22,7 @@ import bisq.core.locale.CountryUtil; import bisq.core.locale.Res; import java.nio.charset.StandardCharsets; - +import java.util.List; import java.util.Map; import java.util.Optional; @@ -63,6 +63,7 @@ public abstract class BankAccountPayload extends CountryBasedPaymentAccountPaylo protected BankAccountPayload(String paymentMethodName, String id, String countryCode, + List acceptedCountryCodes, String holderName, @Nullable String bankName, @Nullable String branchId, @@ -76,6 +77,7 @@ public abstract class BankAccountPayload extends CountryBasedPaymentAccountPaylo super(paymentMethodName, id, countryCode, + acceptedCountryCodes, maxTradePeriod, excludeFromJsonDataMap); diff --git a/core/src/main/java/bisq/core/payment/payload/BizumAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/BizumAccountPayload.java index 15f5d5230e..5e2a0401c7 100644 --- a/core/src/main/java/bisq/core/payment/payload/BizumAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/BizumAccountPayload.java @@ -22,8 +22,9 @@ import bisq.core.locale.Res; import com.google.protobuf.Message; import java.nio.charset.StandardCharsets; - +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; @@ -47,12 +48,14 @@ public final class BizumAccountPayload extends CountryBasedPaymentAccountPayload private BizumAccountPayload(String paymentMethod, String id, String countryCode, + List acceptedCountryCodes, String mobileNr, long maxTradePeriod, Map excludeFromJsonDataMap) { super(paymentMethod, id, countryCode, + acceptedCountryCodes, maxTradePeriod, excludeFromJsonDataMap); @@ -77,6 +80,7 @@ public final class BizumAccountPayload extends CountryBasedPaymentAccountPayload return new BizumAccountPayload(proto.getPaymentMethodId(), proto.getId(), countryBasedPaymentAccountPayload.getCountryCode(), + new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()), paytmAccountPayloadPB.getMobileNr(), proto.getMaxTradePeriod(), new HashMap<>(proto.getExcludeFromJsonDataMap())); diff --git a/core/src/main/java/bisq/core/payment/payload/CashDepositAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/CashDepositAccountPayload.java index f06b429031..4ed78f7e99 100644 --- a/core/src/main/java/bisq/core/payment/payload/CashDepositAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/CashDepositAccountPayload.java @@ -22,8 +22,9 @@ import bisq.core.locale.CountryUtil; import bisq.core.locale.Res; import com.google.protobuf.Message; - +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Optional; @@ -58,6 +59,7 @@ public class CashDepositAccountPayload extends BankAccountPayload { private CashDepositAccountPayload(String paymentMethodName, String id, String countryCode, + List acceptedCountryCodes, String holderName, @Nullable String holderEmail, @Nullable String bankName, @@ -73,6 +75,7 @@ public class CashDepositAccountPayload extends BankAccountPayload { super(paymentMethodName, id, countryCode, + acceptedCountryCodes, holderName, bankName, branchId, @@ -117,6 +120,7 @@ public class CashDepositAccountPayload extends BankAccountPayload { return new CashDepositAccountPayload(proto.getPaymentMethodId(), proto.getId(), countryBasedPaymentAccountPayload.getCountryCode(), + new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()), cashDepositAccountPayload.getHolderName(), cashDepositAccountPayload.getHolderEmail().isEmpty() ? null : cashDepositAccountPayload.getHolderEmail(), cashDepositAccountPayload.getBankName().isEmpty() ? null : cashDepositAccountPayload.getBankName(), diff --git a/core/src/main/java/bisq/core/payment/payload/CountryBasedPaymentAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/CountryBasedPaymentAccountPayload.java index b6c24f0bf5..22b7c95d1d 100644 --- a/core/src/main/java/bisq/core/payment/payload/CountryBasedPaymentAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/CountryBasedPaymentAccountPayload.java @@ -20,7 +20,8 @@ package bisq.core.payment.payload; import org.apache.commons.lang3.ArrayUtils; import java.nio.charset.StandardCharsets; - +import java.util.ArrayList; +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; @@ -36,6 +37,7 @@ import lombok.extern.slf4j.Slf4j; @Slf4j public abstract class CountryBasedPaymentAccountPayload extends PaymentAccountPayload { protected String countryCode = ""; + protected List acceptedCountryCodes = new ArrayList(); CountryBasedPaymentAccountPayload(String paymentMethodName, String id) { super(paymentMethodName, id); @@ -44,6 +46,7 @@ public abstract class CountryBasedPaymentAccountPayload extends PaymentAccountPa protected CountryBasedPaymentAccountPayload(String paymentMethodName, String id, String countryCode, + List acceptedCountryCodes, long maxTradePeriod, Map excludeFromJsonDataMap) { super(paymentMethodName, @@ -52,18 +55,22 @@ public abstract class CountryBasedPaymentAccountPayload extends PaymentAccountPa excludeFromJsonDataMap); this.countryCode = countryCode; + this.acceptedCountryCodes = acceptedCountryCodes; } @Override protected protobuf.PaymentAccountPayload.Builder getPaymentAccountPayloadBuilder() { protobuf.CountryBasedPaymentAccountPayload.Builder builder = protobuf.CountryBasedPaymentAccountPayload.newBuilder() - .setCountryCode(countryCode); + .setCountryCode(countryCode) + .addAllAcceptedCountryCodes(acceptedCountryCodes); return super.getPaymentAccountPayloadBuilder() .setCountryBasedPaymentAccountPayload(builder); } + @Override public abstract String getPaymentDetails(); + @Override public abstract String getPaymentDetailsForTradePopup(); @Override diff --git a/core/src/main/java/bisq/core/payment/payload/DomesticWireTransferAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/DomesticWireTransferAccountPayload.java index 5d1fb76fda..65ebe63442 100644 --- a/core/src/main/java/bisq/core/payment/payload/DomesticWireTransferAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/DomesticWireTransferAccountPayload.java @@ -18,11 +18,13 @@ package bisq.core.payment.payload; import bisq.core.locale.BankUtil; +import bisq.core.locale.Country; import bisq.core.locale.Res; import com.google.protobuf.Message; - +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; @@ -51,6 +53,7 @@ public final class DomesticWireTransferAccountPayload extends BankAccountPayload private DomesticWireTransferAccountPayload(String paymentMethodName, String id, String countryCode, + List acceptedCountryCodes, String holderName, String bankName, String branchId, @@ -61,6 +64,7 @@ public final class DomesticWireTransferAccountPayload extends BankAccountPayload super(paymentMethodName, id, countryCode, + acceptedCountryCodes, holderName, bankName, branchId, @@ -98,6 +102,7 @@ public final class DomesticWireTransferAccountPayload extends BankAccountPayload return new DomesticWireTransferAccountPayload(proto.getPaymentMethodId(), proto.getId(), countryBasedPaymentAccountPayload.getCountryCode(), + new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()), bankAccountPayloadPB.getHolderName(), bankAccountPayloadPB.getBankName().isEmpty() ? null : bankAccountPayloadPB.getBankName(), bankAccountPayloadPB.getBranchId().isEmpty() ? null : bankAccountPayloadPB.getBranchId(), diff --git a/core/src/main/java/bisq/core/payment/payload/F2FAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/F2FAccountPayload.java index 07f7259c19..6c09b31bca 100644 --- a/core/src/main/java/bisq/core/payment/payload/F2FAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/F2FAccountPayload.java @@ -24,8 +24,9 @@ import com.google.protobuf.Message; import org.apache.commons.lang3.ArrayUtils; import java.nio.charset.StandardCharsets; - +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; @@ -56,6 +57,7 @@ public final class F2FAccountPayload extends CountryBasedPaymentAccountPayload { private F2FAccountPayload(String paymentMethodName, String id, String countryCode, + List acceptedCountryCodes, String contact, String city, String extraInfo, @@ -64,6 +66,7 @@ public final class F2FAccountPayload extends CountryBasedPaymentAccountPayload { super(paymentMethodName, id, countryCode, + acceptedCountryCodes, maxTradePeriod, excludeFromJsonDataMap); this.contact = contact; @@ -91,6 +94,7 @@ public final class F2FAccountPayload extends CountryBasedPaymentAccountPayload { return new F2FAccountPayload(proto.getPaymentMethodId(), proto.getId(), countryBasedPaymentAccountPayload.getCountryCode(), + new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()), f2fAccountPayloadPB.getContact(), f2fAccountPayloadPB.getCity(), f2fAccountPayloadPB.getExtraInfo(), diff --git a/core/src/main/java/bisq/core/payment/payload/IfscBasedAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/IfscBasedAccountPayload.java index 12945c335f..c707474587 100644 --- a/core/src/main/java/bisq/core/payment/payload/IfscBasedAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/IfscBasedAccountPayload.java @@ -6,7 +6,7 @@ import bisq.core.locale.CountryUtil; import bisq.core.locale.Res; import java.nio.charset.StandardCharsets; - +import java.util.List; import java.util.Map; import java.util.Optional; @@ -37,6 +37,7 @@ public abstract class IfscBasedAccountPayload extends CountryBasedPaymentAccount protected IfscBasedAccountPayload(String paymentMethodName, String id, String countryCode, + List acceptedCountryCodes, String holderName, String accountNr, String ifsc, @@ -45,6 +46,7 @@ public abstract class IfscBasedAccountPayload extends CountryBasedPaymentAccount super(paymentMethodName, id, countryCode, + acceptedCountryCodes, maxTradePeriod, excludeFromJsonDataMap); diff --git a/core/src/main/java/bisq/core/payment/payload/ImpsAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/ImpsAccountPayload.java index 17d5780d93..9dcc1fb0ed 100644 --- a/core/src/main/java/bisq/core/payment/payload/ImpsAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/ImpsAccountPayload.java @@ -22,8 +22,9 @@ import bisq.core.locale.Res; import com.google.protobuf.Message; import java.nio.charset.StandardCharsets; - +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; @@ -46,6 +47,7 @@ public final class ImpsAccountPayload extends IfscBasedAccountPayload { private ImpsAccountPayload(String paymentMethod, String id, String countryCode, + List acceptedCountryCodes, String holderName, String accountNr, String ifsc, @@ -54,6 +56,7 @@ public final class ImpsAccountPayload extends IfscBasedAccountPayload { super(paymentMethod, id, countryCode, + acceptedCountryCodes, holderName, accountNr, ifsc, @@ -83,6 +86,7 @@ public final class ImpsAccountPayload extends IfscBasedAccountPayload { return new ImpsAccountPayload(proto.getPaymentMethodId(), proto.getId(), countryBasedPaymentAccountPayload.getCountryCode(), + new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()), ifscBasedAccountPayloadPB.getHolderName(), ifscBasedAccountPayloadPB.getAccountNr(), ifscBasedAccountPayloadPB.getIfsc(), diff --git a/core/src/main/java/bisq/core/payment/payload/NationalBankAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/NationalBankAccountPayload.java index c7589df8a3..ff6a356dc6 100644 --- a/core/src/main/java/bisq/core/payment/payload/NationalBankAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/NationalBankAccountPayload.java @@ -20,8 +20,9 @@ package bisq.core.payment.payload; import bisq.core.locale.Res; import com.google.protobuf.Message; - +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; @@ -45,6 +46,7 @@ public final class NationalBankAccountPayload extends BankAccountPayload { private NationalBankAccountPayload(String paymentMethodName, String id, String countryCode, + List acceptedCountryCodes, String holderName, String bankName, String branchId, @@ -58,6 +60,7 @@ public final class NationalBankAccountPayload extends BankAccountPayload { super(paymentMethodName, id, countryCode, + acceptedCountryCodes, holderName, bankName, branchId, @@ -92,6 +95,7 @@ public final class NationalBankAccountPayload extends BankAccountPayload { return new NationalBankAccountPayload(proto.getPaymentMethodId(), proto.getId(), countryBasedPaymentAccountPayload.getCountryCode(), + new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()), bankAccountPayloadPB.getHolderName(), bankAccountPayloadPB.getBankName().isEmpty() ? null : bankAccountPayloadPB.getBankName(), bankAccountPayloadPB.getBranchId().isEmpty() ? null : bankAccountPayloadPB.getBranchId(), diff --git a/core/src/main/java/bisq/core/payment/payload/NeftAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/NeftAccountPayload.java index fa173eb295..4726a667e7 100644 --- a/core/src/main/java/bisq/core/payment/payload/NeftAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/NeftAccountPayload.java @@ -22,8 +22,9 @@ import bisq.core.locale.Res; import com.google.protobuf.Message; import java.nio.charset.StandardCharsets; - +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; @@ -46,6 +47,7 @@ public final class NeftAccountPayload extends IfscBasedAccountPayload { private NeftAccountPayload(String paymentMethod, String id, String countryCode, + List acceptedCountryCodes, String holderName, String accountNr, String ifsc, @@ -54,6 +56,7 @@ public final class NeftAccountPayload extends IfscBasedAccountPayload { super(paymentMethod, id, countryCode, + acceptedCountryCodes, holderName, accountNr, ifsc, @@ -83,6 +86,7 @@ public final class NeftAccountPayload extends IfscBasedAccountPayload { return new NeftAccountPayload(proto.getPaymentMethodId(), proto.getId(), countryBasedPaymentAccountPayload.getCountryCode(), + new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()), ifscBasedAccountPayloadPB.getHolderName(), ifscBasedAccountPayloadPB.getAccountNr(), ifscBasedAccountPayloadPB.getIfsc(), diff --git a/core/src/main/java/bisq/core/payment/payload/NequiAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/NequiAccountPayload.java index 6fca432521..25628ed972 100644 --- a/core/src/main/java/bisq/core/payment/payload/NequiAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/NequiAccountPayload.java @@ -17,13 +17,15 @@ package bisq.core.payment.payload; +import bisq.core.locale.Country; import bisq.core.locale.Res; import com.google.protobuf.Message; import java.nio.charset.StandardCharsets; - +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; @@ -47,12 +49,14 @@ public final class NequiAccountPayload extends CountryBasedPaymentAccountPayload private NequiAccountPayload(String paymentMethod, String id, String countryCode, + List acceptedCountryCodes, String mobileNr, long maxTradePeriod, Map excludeFromJsonDataMap) { super(paymentMethod, id, countryCode, + acceptedCountryCodes, maxTradePeriod, excludeFromJsonDataMap); @@ -77,6 +81,7 @@ public final class NequiAccountPayload extends CountryBasedPaymentAccountPayload return new NequiAccountPayload(proto.getPaymentMethodId(), proto.getId(), countryBasedPaymentAccountPayload.getCountryCode(), + new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()), paytmAccountPayloadPB.getMobileNr(), proto.getMaxTradePeriod(), new HashMap<>(proto.getExcludeFromJsonDataMap())); diff --git a/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java b/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java index 2ec8f7140b..86c7215b82 100644 --- a/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java +++ b/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java @@ -245,7 +245,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable paymentMethods = new ArrayList<>(Arrays.asList( + public final static List paymentMethods = new ArrayList<>(Arrays.asList( // EUR HAL_CASH = new PaymentMethod(HAL_CASH_ID, DAY, DEFAULT_TRADE_LIMIT_LOW_RISK, getAssetCodes(HalCashAccount.SUPPORTED_CURRENCIES)), SEPA = new PaymentMethod(SEPA_ID, 6 * DAY, DEFAULT_TRADE_LIMIT_HIGH_RISK, getAssetCodes(SepaAccount.SUPPORTED_CURRENCIES)), @@ -325,6 +325,19 @@ public final class PaymentMethod implements PersistablePayload, Comparable getPaymentMethods() { + List paymentMethodIds = List.of( + REVOLUT_ID, + SEPA_ID, + TRANSFERWISE_ID, + CLEAR_X_CHANGE_ID, + SWIFT_ID, + F2F_ID, + STRIKE_ID); + return paymentMethods.stream().filter(paymentMethod -> paymentMethodIds.contains(paymentMethod.getId())).collect(Collectors.toList()); + } + private static List getAssetCodes(List tradeCurrencies) { return tradeCurrencies.stream().map(TradeCurrency::getCode).collect(Collectors.toList()); } diff --git a/core/src/main/java/bisq/core/payment/payload/PaytmAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/PaytmAccountPayload.java index 68c7878fce..508644bd27 100644 --- a/core/src/main/java/bisq/core/payment/payload/PaytmAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/PaytmAccountPayload.java @@ -22,8 +22,9 @@ import bisq.core.locale.Res; import com.google.protobuf.Message; import java.nio.charset.StandardCharsets; - +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; @@ -47,12 +48,14 @@ public final class PaytmAccountPayload extends CountryBasedPaymentAccountPayload private PaytmAccountPayload(String paymentMethod, String id, String countryCode, + List acceptedCountryCodes, String emailOrMobileNr, long maxTradePeriod, Map excludeFromJsonDataMap) { super(paymentMethod, id, countryCode, + acceptedCountryCodes, maxTradePeriod, excludeFromJsonDataMap); @@ -77,6 +80,7 @@ public final class PaytmAccountPayload extends CountryBasedPaymentAccountPayload return new PaytmAccountPayload(proto.getPaymentMethodId(), proto.getId(), countryBasedPaymentAccountPayload.getCountryCode(), + new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()), paytmAccountPayloadPB.getEmailOrMobileNr(), proto.getMaxTradePeriod(), new HashMap<>(proto.getExcludeFromJsonDataMap())); diff --git a/core/src/main/java/bisq/core/payment/payload/PixAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/PixAccountPayload.java index 7c307abeec..e0ed830041 100644 --- a/core/src/main/java/bisq/core/payment/payload/PixAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/PixAccountPayload.java @@ -22,8 +22,9 @@ import bisq.core.locale.Res; import com.google.protobuf.Message; import java.nio.charset.StandardCharsets; - +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; @@ -47,12 +48,14 @@ public final class PixAccountPayload extends CountryBasedPaymentAccountPayload { private PixAccountPayload(String paymentMethod, String id, String countryCode, + List acceptedCountryCodes, String pixKey, long maxTradePeriod, Map excludeFromJsonDataMap) { super(paymentMethod, id, countryCode, + acceptedCountryCodes, maxTradePeriod, excludeFromJsonDataMap); @@ -77,6 +80,7 @@ public final class PixAccountPayload extends CountryBasedPaymentAccountPayload { return new PixAccountPayload(proto.getPaymentMethodId(), proto.getId(), countryBasedPaymentAccountPayload.getCountryCode(), + new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()), paytmAccountPayloadPB.getPixKey(), proto.getMaxTradePeriod(), new HashMap<>(proto.getExcludeFromJsonDataMap())); diff --git a/core/src/main/java/bisq/core/payment/payload/RtgsAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/RtgsAccountPayload.java index 177e521e16..c5ea0944a4 100644 --- a/core/src/main/java/bisq/core/payment/payload/RtgsAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/RtgsAccountPayload.java @@ -22,8 +22,9 @@ import bisq.core.locale.Res; import com.google.protobuf.Message; import java.nio.charset.StandardCharsets; - +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; @@ -46,6 +47,7 @@ public final class RtgsAccountPayload extends IfscBasedAccountPayload { private RtgsAccountPayload(String paymentMethod, String id, String countryCode, + List acceptedCountryCodes, String holderName, String accountNr, String ifsc, @@ -54,6 +56,7 @@ public final class RtgsAccountPayload extends IfscBasedAccountPayload { super(paymentMethod, id, countryCode, + acceptedCountryCodes, holderName, accountNr, ifsc, @@ -83,6 +86,7 @@ public final class RtgsAccountPayload extends IfscBasedAccountPayload { return new RtgsAccountPayload(proto.getPaymentMethodId(), proto.getId(), countryBasedPaymentAccountPayload.getCountryCode(), + new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()), ifscBasedAccountPayloadPB.getHolderName(), ifscBasedAccountPayloadPB.getAccountNr(), ifscBasedAccountPayloadPB.getIfsc(), diff --git a/core/src/main/java/bisq/core/payment/payload/SameBankAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/SameBankAccountPayload.java index f7db972fcc..afc9db01d1 100644 --- a/core/src/main/java/bisq/core/payment/payload/SameBankAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/SameBankAccountPayload.java @@ -20,8 +20,9 @@ package bisq.core.payment.payload; import bisq.core.locale.Res; import com.google.protobuf.Message; - +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; @@ -45,6 +46,7 @@ public final class SameBankAccountPayload extends BankAccountPayload { private SameBankAccountPayload(String paymentMethodName, String id, String countryCode, + List acceptedCountryCodes, String holderName, String bankName, String branchId, @@ -58,6 +60,7 @@ public final class SameBankAccountPayload extends BankAccountPayload { super(paymentMethodName, id, countryCode, + acceptedCountryCodes, holderName, bankName, branchId, @@ -92,6 +95,7 @@ public final class SameBankAccountPayload extends BankAccountPayload { return new SameBankAccountPayload(proto.getPaymentMethodId(), proto.getId(), countryBasedPaymentAccountPayload.getCountryCode(), + new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()), bankAccountPayload.getHolderName(), bankAccountPayload.getBankName().isEmpty() ? null : bankAccountPayload.getBankName(), bankAccountPayload.getBranchId().isEmpty() ? null : bankAccountPayload.getBranchId(), diff --git a/core/src/main/java/bisq/core/payment/payload/SatispayAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/SatispayAccountPayload.java index 0e4782ee43..956f115782 100644 --- a/core/src/main/java/bisq/core/payment/payload/SatispayAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/SatispayAccountPayload.java @@ -17,13 +17,15 @@ package bisq.core.payment.payload; +import bisq.core.locale.Country; import bisq.core.locale.Res; import com.google.protobuf.Message; import java.nio.charset.StandardCharsets; - +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; @@ -48,6 +50,7 @@ public final class SatispayAccountPayload extends CountryBasedPaymentAccountPayl private SatispayAccountPayload(String paymentMethod, String id, String countryCode, + List acceptedCountryCodes, String holderName, String mobileNr, long maxTradePeriod, @@ -55,6 +58,7 @@ public final class SatispayAccountPayload extends CountryBasedPaymentAccountPayl super(paymentMethod, id, countryCode, + acceptedCountryCodes, maxTradePeriod, excludeFromJsonDataMap); @@ -81,6 +85,7 @@ public final class SatispayAccountPayload extends CountryBasedPaymentAccountPayl return new SatispayAccountPayload(proto.getPaymentMethodId(), proto.getId(), countryBasedPaymentAccountPayload.getCountryCode(), + new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()), accountPayloadPB.getHolderName(), accountPayloadPB.getMobileNr(), proto.getMaxTradePeriod(), diff --git a/core/src/main/java/bisq/core/payment/payload/SepaAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/SepaAccountPayload.java index 6c283209e7..8d6bb18bd6 100644 --- a/core/src/main/java/bisq/core/payment/payload/SepaAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/SepaAccountPayload.java @@ -53,7 +53,6 @@ public final class SepaAccountPayload extends CountryBasedPaymentAccountPayload private String email = ""; // not used anymore but need to keep it for backward compatibility, must not be null but empty string, otherwise hash check fails for contract // Don't use a set here as we need a deterministic ordering, otherwise the contract hash does not match - private final List acceptedCountryCodes; private final List persistedAcceptedCountryCodes = new ArrayList<>(); public SepaAccountPayload(String paymentMethod, String id, List acceptedCountries) { @@ -73,16 +72,17 @@ public final class SepaAccountPayload extends CountryBasedPaymentAccountPayload private SepaAccountPayload(String paymentMethodName, String id, String countryCode, + List acceptedCountryCodes, String holderName, String iban, String bic, String email, - List acceptedCountryCodes, long maxTradePeriod, Map excludeFromJsonDataMap) { super(paymentMethodName, id, countryCode, + acceptedCountryCodes, maxTradePeriod, excludeFromJsonDataMap); @@ -101,8 +101,7 @@ public final class SepaAccountPayload extends CountryBasedPaymentAccountPayload .setHolderName(holderName) .setIban(iban) .setBic(bic) - .setEmail(email) - .addAllAcceptedCountryCodes(acceptedCountryCodes); + .setEmail(email); final protobuf.CountryBasedPaymentAccountPayload.Builder countryBasedPaymentAccountPayload = getPaymentAccountPayloadBuilder() .getCountryBasedPaymentAccountPayloadBuilder() .setSepaAccountPayload(builder); @@ -117,11 +116,11 @@ public final class SepaAccountPayload extends CountryBasedPaymentAccountPayload return new SepaAccountPayload(proto.getPaymentMethodId(), proto.getId(), countryBasedPaymentAccountPayload.getCountryCode(), + new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()), sepaAccountPayloadPB.getHolderName(), sepaAccountPayloadPB.getIban(), sepaAccountPayloadPB.getBic(), sepaAccountPayloadPB.getEmail(), - new ArrayList<>(sepaAccountPayloadPB.getAcceptedCountryCodesList()), proto.getMaxTradePeriod(), new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -131,6 +130,12 @@ public final class SepaAccountPayload extends CountryBasedPaymentAccountPayload // API /////////////////////////////////////////////////////////////////////////////////////////// + @Override + public void setAcceptedCountryCodes(List acceptedCountryCodes) { + this.acceptedCountryCodes.clear(); + for (String countryCode : acceptedCountryCodes) this.acceptedCountryCodes.add(countryCode); + } + public void addAcceptedCountry(String countryCode) { if (!acceptedCountryCodes.contains(countryCode)) acceptedCountryCodes.add(countryCode); diff --git a/core/src/main/java/bisq/core/payment/payload/SepaInstantAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/SepaInstantAccountPayload.java index e631da5924..27872f648b 100644 --- a/core/src/main/java/bisq/core/payment/payload/SepaInstantAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/SepaInstantAccountPayload.java @@ -52,7 +52,6 @@ public final class SepaInstantAccountPayload extends CountryBasedPaymentAccountP private String bic = ""; // Don't use a set here as we need a deterministic ordering, otherwise the contract hash does not match - private final List acceptedCountryCodes; private final List persistedAcceptedCountryCodes = new ArrayList<>(); public SepaInstantAccountPayload(String paymentMethod, String id, List acceptedCountries) { @@ -72,22 +71,22 @@ public final class SepaInstantAccountPayload extends CountryBasedPaymentAccountP private SepaInstantAccountPayload(String paymentMethodName, String id, String countryCode, + List acceptedCountryCodes, String holderName, String iban, String bic, - List acceptedCountryCodes, long maxTradePeriod, Map excludeFromJsonDataMap) { super(paymentMethodName, id, countryCode, + acceptedCountryCodes, maxTradePeriod, excludeFromJsonDataMap); this.holderName = holderName; this.iban = iban; this.bic = bic; - this.acceptedCountryCodes = acceptedCountryCodes; persistedAcceptedCountryCodes.addAll(acceptedCountryCodes); } @@ -97,8 +96,7 @@ public final class SepaInstantAccountPayload extends CountryBasedPaymentAccountP protobuf.SepaInstantAccountPayload.newBuilder() .setHolderName(holderName) .setIban(iban) - .setBic(bic) - .addAllAcceptedCountryCodes(acceptedCountryCodes); + .setBic(bic); final protobuf.CountryBasedPaymentAccountPayload.Builder countryBasedPaymentAccountPayload = getPaymentAccountPayloadBuilder() .getCountryBasedPaymentAccountPayloadBuilder() .setSepaInstantAccountPayload(builder); @@ -113,10 +111,10 @@ public final class SepaInstantAccountPayload extends CountryBasedPaymentAccountP return new SepaInstantAccountPayload(proto.getPaymentMethodId(), proto.getId(), countryBasedPaymentAccountPayload.getCountryCode(), + new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()), sepaInstantAccountPayloadPB.getHolderName(), sepaInstantAccountPayloadPB.getIban(), sepaInstantAccountPayloadPB.getBic(), - new ArrayList<>(sepaInstantAccountPayloadPB.getAcceptedCountryCodesList()), proto.getMaxTradePeriod(), new HashMap<>(proto.getExcludeFromJsonDataMap())); } diff --git a/core/src/main/java/bisq/core/payment/payload/SpecificBanksAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/SpecificBanksAccountPayload.java index 23d53534a1..7c989d2c52 100644 --- a/core/src/main/java/bisq/core/payment/payload/SpecificBanksAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/SpecificBanksAccountPayload.java @@ -25,6 +25,7 @@ import com.google.common.base.Joiner; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; @@ -52,6 +53,7 @@ public final class SpecificBanksAccountPayload extends BankAccountPayload { private SpecificBanksAccountPayload(String paymentMethodName, String id, String countryCode, + List acceptedCountryCodes, String holderName, String bankName, String branchId, @@ -66,6 +68,7 @@ public final class SpecificBanksAccountPayload extends BankAccountPayload { super(paymentMethodName, id, countryCode, + acceptedCountryCodes, holderName, bankName, branchId, @@ -106,6 +109,7 @@ public final class SpecificBanksAccountPayload extends BankAccountPayload { return new SpecificBanksAccountPayload(proto.getPaymentMethodId(), proto.getId(), countryBasedPaymentAccountPayload.getCountryCode(), + new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()), bankAccountPayload.getHolderName(), bankAccountPayload.getBankName().isEmpty() ? null : bankAccountPayload.getBankName(), bankAccountPayload.getBranchId().isEmpty() ? null : bankAccountPayload.getBranchId(), diff --git a/core/src/main/java/bisq/core/payment/payload/StrikeAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/StrikeAccountPayload.java index d9744af049..ab68a202c7 100644 --- a/core/src/main/java/bisq/core/payment/payload/StrikeAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/StrikeAccountPayload.java @@ -22,8 +22,9 @@ import bisq.core.locale.Res; import com.google.protobuf.Message; import java.nio.charset.StandardCharsets; - +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; @@ -47,12 +48,14 @@ public final class StrikeAccountPayload extends CountryBasedPaymentAccountPayloa private StrikeAccountPayload(String paymentMethod, String id, String countryCode, + List acceptedCountryCodes, String holderName, long maxTradePeriod, Map excludeFromJsonDataMap) { super(paymentMethod, id, countryCode, + acceptedCountryCodes, maxTradePeriod, excludeFromJsonDataMap); @@ -77,6 +80,7 @@ public final class StrikeAccountPayload extends CountryBasedPaymentAccountPayloa return new StrikeAccountPayload(proto.getPaymentMethodId(), proto.getId(), countryBasedPaymentAccountPayload.getCountryCode(), + new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()), accountPayloadPB.getHolderName(), proto.getMaxTradePeriod(), new HashMap<>(proto.getExcludeFromJsonDataMap())); diff --git a/core/src/main/java/bisq/core/payment/payload/TikkieAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/TikkieAccountPayload.java index ce13e00198..b593c4a24e 100644 --- a/core/src/main/java/bisq/core/payment/payload/TikkieAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/TikkieAccountPayload.java @@ -22,8 +22,9 @@ import bisq.core.locale.Res; import com.google.protobuf.Message; import java.nio.charset.StandardCharsets; - +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; @@ -47,12 +48,14 @@ public final class TikkieAccountPayload extends CountryBasedPaymentAccountPayloa private TikkieAccountPayload(String paymentMethod, String id, String countryCode, + List acceptedCountryCodes, String iban, long maxTradePeriod, Map excludeFromJsonDataMap) { super(paymentMethod, id, countryCode, + acceptedCountryCodes, maxTradePeriod, excludeFromJsonDataMap); @@ -77,6 +80,7 @@ public final class TikkieAccountPayload extends CountryBasedPaymentAccountPayloa return new TikkieAccountPayload(proto.getPaymentMethodId(), proto.getId(), countryBasedPaymentAccountPayload.getCountryCode(), + new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()), accountPayloadPB.getIban(), proto.getMaxTradePeriod(), new HashMap<>(proto.getExcludeFromJsonDataMap())); diff --git a/core/src/main/java/bisq/core/payment/payload/TransferwiseUsdAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/TransferwiseUsdAccountPayload.java index 6fc4f025e7..80030397bb 100644 --- a/core/src/main/java/bisq/core/payment/payload/TransferwiseUsdAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/TransferwiseUsdAccountPayload.java @@ -22,8 +22,9 @@ import bisq.core.locale.Res; import com.google.protobuf.Message; import java.nio.charset.StandardCharsets; - +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; @@ -49,6 +50,7 @@ public final class TransferwiseUsdAccountPayload extends CountryBasedPaymentAcco private TransferwiseUsdAccountPayload(String paymentMethod, String id, String countryCode, + List acceptedCountryCodes, String email, String holderName, String beneficiaryAddress, @@ -57,6 +59,7 @@ public final class TransferwiseUsdAccountPayload extends CountryBasedPaymentAcco super(paymentMethod, id, countryCode, + acceptedCountryCodes, maxTradePeriod, excludeFromJsonDataMap); @@ -85,6 +88,7 @@ public final class TransferwiseUsdAccountPayload extends CountryBasedPaymentAcco return new TransferwiseUsdAccountPayload(proto.getPaymentMethodId(), proto.getId(), countryBasedPaymentAccountPayload.getCountryCode(), + new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()), accountPayloadPB.getEmail(), accountPayloadPB.getHolderName(), accountPayloadPB.getBeneficiaryAddress(), diff --git a/core/src/main/java/bisq/core/payment/payload/UpiAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/UpiAccountPayload.java index 4a46c856ae..ab3fba2a62 100644 --- a/core/src/main/java/bisq/core/payment/payload/UpiAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/UpiAccountPayload.java @@ -22,8 +22,9 @@ import bisq.core.locale.Res; import com.google.protobuf.Message; import java.nio.charset.StandardCharsets; - +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; @@ -47,12 +48,14 @@ public final class UpiAccountPayload extends CountryBasedPaymentAccountPayload { private UpiAccountPayload(String paymentMethod, String id, String countryCode, + List acceptedCountryCodes, String virtualPaymentAddress, long maxTradePeriod, Map excludeFromJsonDataMap) { super(paymentMethod, id, countryCode, + acceptedCountryCodes, maxTradePeriod, excludeFromJsonDataMap); @@ -77,6 +80,7 @@ public final class UpiAccountPayload extends CountryBasedPaymentAccountPayload { return new UpiAccountPayload(proto.getPaymentMethodId(), proto.getId(), countryBasedPaymentAccountPayload.getCountryCode(), + new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()), upiAccountPayloadPB.getVirtualPaymentAddress(), proto.getMaxTradePeriod(), new HashMap<>(proto.getExcludeFromJsonDataMap())); diff --git a/core/src/main/java/bisq/core/payment/payload/WesternUnionAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/WesternUnionAccountPayload.java index 5c953f3956..7da2f60bed 100644 --- a/core/src/main/java/bisq/core/payment/payload/WesternUnionAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/WesternUnionAccountPayload.java @@ -24,8 +24,9 @@ import bisq.core.locale.Res; import com.google.protobuf.Message; import java.nio.charset.StandardCharsets; - +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; @@ -57,6 +58,7 @@ public class WesternUnionAccountPayload extends CountryBasedPaymentAccountPayloa private WesternUnionAccountPayload(String paymentMethodName, String id, String countryCode, + List acceptedCountryCodes, String holderName, String city, String state, @@ -66,6 +68,7 @@ public class WesternUnionAccountPayload extends CountryBasedPaymentAccountPayloa super(paymentMethodName, id, countryCode, + acceptedCountryCodes, maxTradePeriod, excludeFromJsonDataMap); this.holderName = holderName; @@ -97,6 +100,7 @@ public class WesternUnionAccountPayload extends CountryBasedPaymentAccountPayloa return new WesternUnionAccountPayload(proto.getPaymentMethodId(), proto.getId(), countryBasedPaymentAccountPayload.getCountryCode(), + new ArrayList<>(countryBasedPaymentAccountPayload.getAcceptedCountryCodesList()), westernUnionAccountPayload.getHolderName(), westernUnionAccountPayload.getCity(), westernUnionAccountPayload.getState(), diff --git a/desktop/src/main/java/bisq/desktop/util/validation/AccountNrValidator.java b/core/src/main/java/bisq/core/payment/validation/AccountNrValidator.java similarity index 99% rename from desktop/src/main/java/bisq/desktop/util/validation/AccountNrValidator.java rename to core/src/main/java/bisq/core/payment/validation/AccountNrValidator.java index a7b33bdc70..b1c2f4d47b 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/AccountNrValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/AccountNrValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.locale.BankUtil; import bisq.core.locale.Res; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/AdvancedCashValidator.java b/core/src/main/java/bisq/core/payment/validation/AdvancedCashValidator.java similarity index 96% rename from desktop/src/main/java/bisq/desktop/util/validation/AdvancedCashValidator.java rename to core/src/main/java/bisq/core/payment/validation/AdvancedCashValidator.java index 07e687289d..c8c22a4649 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/AdvancedCashValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/AdvancedCashValidator.java @@ -1,4 +1,4 @@ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.locale.Res; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/AliPayValidator.java b/core/src/main/java/bisq/core/payment/validation/AliPayValidator.java similarity index 97% rename from desktop/src/main/java/bisq/desktop/util/validation/AliPayValidator.java rename to core/src/main/java/bisq/core/payment/validation/AliPayValidator.java index 3b76dd0bf5..92dcc1f6b4 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/AliPayValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/AliPayValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/AustraliaPayidAccountNameValidator.java b/core/src/main/java/bisq/core/payment/validation/AustraliaPayidAccountNameValidator.java similarity index 97% rename from desktop/src/main/java/bisq/desktop/util/validation/AustraliaPayidAccountNameValidator.java rename to core/src/main/java/bisq/core/payment/validation/AustraliaPayidAccountNameValidator.java index c43f4f746f..4f56d30688 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/AustraliaPayidAccountNameValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/AustraliaPayidAccountNameValidator.java @@ -16,7 +16,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.util.validation.InputValidator; import bisq.core.util.validation.RegexValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/AustraliaPayidValidator.java b/core/src/main/java/bisq/core/payment/validation/AustraliaPayidValidator.java similarity index 98% rename from desktop/src/main/java/bisq/desktop/util/validation/AustraliaPayidValidator.java rename to core/src/main/java/bisq/core/payment/validation/AustraliaPayidValidator.java index 025ac3faa1..d1a9076342 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/AustraliaPayidValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/AustraliaPayidValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/BICValidator.java b/core/src/main/java/bisq/core/payment/validation/BICValidator.java similarity index 98% rename from desktop/src/main/java/bisq/desktop/util/validation/BICValidator.java rename to core/src/main/java/bisq/core/payment/validation/BICValidator.java index cd57af0fcf..94015a3937 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/BICValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/BICValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.locale.Res; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/BankIdValidator.java b/core/src/main/java/bisq/core/payment/validation/BankIdValidator.java similarity index 97% rename from desktop/src/main/java/bisq/desktop/util/validation/BankIdValidator.java rename to core/src/main/java/bisq/core/payment/validation/BankIdValidator.java index 7bf9579f7e..823e553c45 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/BankIdValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/BankIdValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.locale.BankUtil; import bisq.core.locale.Res; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/BankValidator.java b/core/src/main/java/bisq/core/payment/validation/BankValidator.java similarity index 96% rename from desktop/src/main/java/bisq/desktop/util/validation/BankValidator.java rename to core/src/main/java/bisq/core/payment/validation/BankValidator.java index 9eba84404f..fabaaed684 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/BankValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/BankValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/BranchIdValidator.java b/core/src/main/java/bisq/core/payment/validation/BranchIdValidator.java similarity index 98% rename from desktop/src/main/java/bisq/desktop/util/validation/BranchIdValidator.java rename to core/src/main/java/bisq/core/payment/validation/BranchIdValidator.java index 0e049f6401..71bba899db 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/BranchIdValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/BranchIdValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.locale.BankUtil; import bisq.core.locale.Res; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/BtcValidator.java b/core/src/main/java/bisq/core/payment/validation/BtcValidator.java similarity index 99% rename from desktop/src/main/java/bisq/desktop/util/validation/BtcValidator.java rename to core/src/main/java/bisq/core/payment/validation/BtcValidator.java index 5bd7f44b58..0d03ecf69c 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/BtcValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/BtcValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.btc.wallet.Restrictions; import bisq.core.locale.Res; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/CapitualValidator.java b/core/src/main/java/bisq/core/payment/validation/CapitualValidator.java similarity index 94% rename from desktop/src/main/java/bisq/desktop/util/validation/CapitualValidator.java rename to core/src/main/java/bisq/core/payment/validation/CapitualValidator.java index f94b933340..19c310a8c2 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/CapitualValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/CapitualValidator.java @@ -1,4 +1,4 @@ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.locale.Res; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/ChaseQuickPayValidator.java b/core/src/main/java/bisq/core/payment/validation/ChaseQuickPayValidator.java similarity index 97% rename from desktop/src/main/java/bisq/desktop/util/validation/ChaseQuickPayValidator.java rename to core/src/main/java/bisq/core/payment/validation/ChaseQuickPayValidator.java index df27df8c5d..218d0f9a5b 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/ChaseQuickPayValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/ChaseQuickPayValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/CountryCallingCodes.java b/core/src/main/java/bisq/core/payment/validation/CountryCallingCodes.java similarity index 99% rename from desktop/src/main/java/bisq/desktop/util/validation/CountryCallingCodes.java rename to core/src/main/java/bisq/core/payment/validation/CountryCallingCodes.java index 7fc60e5337..f1e0e83f46 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/CountryCallingCodes.java +++ b/core/src/main/java/bisq/core/payment/validation/CountryCallingCodes.java @@ -1,4 +1,4 @@ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import java.util.Map; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/ClearXchangeValidator.java b/core/src/main/java/bisq/core/payment/validation/EmailOrMobileNrValidator.java similarity index 92% rename from desktop/src/main/java/bisq/desktop/util/validation/ClearXchangeValidator.java rename to core/src/main/java/bisq/core/payment/validation/EmailOrMobileNrValidator.java index cf4b5858e2..ceb6505470 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/ClearXchangeValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/EmailOrMobileNrValidator.java @@ -15,11 +15,11 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.util.validation.InputValidator; -public final class ClearXchangeValidator extends InputValidator { +public final class EmailOrMobileNrValidator extends InputValidator { private final EmailValidator emailValidator; @@ -27,7 +27,7 @@ public final class ClearXchangeValidator extends InputValidator { // Public methods /////////////////////////////////////////////////////////////////////////////////////////// - public ClearXchangeValidator() { + public EmailOrMobileNrValidator() { emailValidator = new EmailValidator(); } diff --git a/desktop/src/main/java/bisq/desktop/util/validation/EmailValidator.java b/core/src/main/java/bisq/core/payment/validation/EmailValidator.java similarity index 99% rename from desktop/src/main/java/bisq/desktop/util/validation/EmailValidator.java rename to core/src/main/java/bisq/core/payment/validation/EmailValidator.java index c6ce039532..eb49e0fc24 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/EmailValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/EmailValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.locale.Res; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/F2FValidator.java b/core/src/main/java/bisq/core/payment/validation/F2FValidator.java similarity index 97% rename from desktop/src/main/java/bisq/desktop/util/validation/F2FValidator.java rename to core/src/main/java/bisq/core/payment/validation/F2FValidator.java index 8703e8085b..00be30d76e 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/F2FValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/F2FValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/FiatVolumeValidator.java b/core/src/main/java/bisq/core/payment/validation/FiatVolumeValidator.java similarity index 91% rename from desktop/src/main/java/bisq/desktop/util/validation/FiatVolumeValidator.java rename to core/src/main/java/bisq/core/payment/validation/FiatVolumeValidator.java index 1674c96574..c09e14a142 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/FiatVolumeValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/FiatVolumeValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.util.validation.MonetaryValidator; @@ -23,12 +23,12 @@ import javax.inject.Inject; public class FiatVolumeValidator extends MonetaryValidator { @Override - protected double getMinValue() { + public double getMinValue() { return 0.01; } @Override - protected double getMaxValue() { + public double getMaxValue() { // Hard to say what the max value should be (zimbabwe dollar....)? // Lets set it to Double.MAX_VALUE until we find some reasonable number return Double.MAX_VALUE; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/HalCashValidator.java b/core/src/main/java/bisq/core/payment/validation/HalCashValidator.java similarity index 97% rename from desktop/src/main/java/bisq/desktop/util/validation/HalCashValidator.java rename to core/src/main/java/bisq/core/payment/validation/HalCashValidator.java index d4930021fe..fe13bcfa71 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/HalCashValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/HalCashValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/IBANValidator.java b/core/src/main/java/bisq/core/payment/validation/IBANValidator.java similarity index 99% rename from desktop/src/main/java/bisq/desktop/util/validation/IBANValidator.java rename to core/src/main/java/bisq/core/payment/validation/IBANValidator.java index cb44e5d827..503b03633c 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/IBANValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/IBANValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.locale.Res; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/InteracETransferAnswerValidator.java b/core/src/main/java/bisq/core/payment/validation/InteracETransferAnswerValidator.java similarity index 96% rename from desktop/src/main/java/bisq/desktop/util/validation/InteracETransferAnswerValidator.java rename to core/src/main/java/bisq/core/payment/validation/InteracETransferAnswerValidator.java index aa28b5d734..7f697bdae0 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/InteracETransferAnswerValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/InteracETransferAnswerValidator.java @@ -1,4 +1,4 @@ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.locale.Res; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/InteracETransferQuestionValidator.java b/core/src/main/java/bisq/core/payment/validation/InteracETransferQuestionValidator.java similarity index 96% rename from desktop/src/main/java/bisq/desktop/util/validation/InteracETransferQuestionValidator.java rename to core/src/main/java/bisq/core/payment/validation/InteracETransferQuestionValidator.java index bd7374e097..616e469297 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/InteracETransferQuestionValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/InteracETransferQuestionValidator.java @@ -1,4 +1,4 @@ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.locale.Res; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/InteracETransferValidator.java b/core/src/main/java/bisq/core/payment/validation/InteracETransferValidator.java similarity index 99% rename from desktop/src/main/java/bisq/desktop/util/validation/InteracETransferValidator.java rename to core/src/main/java/bisq/core/payment/validation/InteracETransferValidator.java index 4a85762170..e124a68d17 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/InteracETransferValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/InteracETransferValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.locale.Res; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/JapanBankAccountNameValidator.java b/core/src/main/java/bisq/core/payment/validation/JapanBankAccountNameValidator.java similarity index 94% rename from desktop/src/main/java/bisq/desktop/util/validation/JapanBankAccountNameValidator.java rename to core/src/main/java/bisq/core/payment/validation/JapanBankAccountNameValidator.java index 4d82f3e0a5..a6a3f491f7 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/JapanBankAccountNameValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/JapanBankAccountNameValidator.java @@ -15,10 +15,9 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; - -import bisq.desktop.components.paymentmethods.data.JapanBankData; +package bisq.core.payment.validation; +import bisq.core.payment.JapanBankData; import bisq.core.util.validation.InputValidator; import bisq.core.util.validation.RegexValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/JapanBankAccountNumberValidator.java b/core/src/main/java/bisq/core/payment/validation/JapanBankAccountNumberValidator.java similarity index 93% rename from desktop/src/main/java/bisq/desktop/util/validation/JapanBankAccountNumberValidator.java rename to core/src/main/java/bisq/core/payment/validation/JapanBankAccountNumberValidator.java index 018af6954b..86882c31af 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/JapanBankAccountNumberValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/JapanBankAccountNumberValidator.java @@ -15,10 +15,10 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.util.validation.InputValidator; -import bisq.desktop.components.paymentmethods.data.JapanBankData; +import bisq.core.payment.JapanBankData; public final class JapanBankAccountNumberValidator extends InputValidator { diff --git a/desktop/src/main/java/bisq/desktop/util/validation/JapanBankBranchCodeValidator.java b/core/src/main/java/bisq/core/payment/validation/JapanBankBranchCodeValidator.java similarity index 91% rename from desktop/src/main/java/bisq/desktop/util/validation/JapanBankBranchCodeValidator.java rename to core/src/main/java/bisq/core/payment/validation/JapanBankBranchCodeValidator.java index d3cc408c00..f9a90eff9f 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/JapanBankBranchCodeValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/JapanBankBranchCodeValidator.java @@ -15,10 +15,10 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.util.validation.InputValidator; -import bisq.desktop.components.paymentmethods.data.JapanBankData; +import bisq.core.payment.JapanBankData; public final class JapanBankBranchCodeValidator extends InputValidator { diff --git a/desktop/src/main/java/bisq/desktop/util/validation/JapanBankBranchNameValidator.java b/core/src/main/java/bisq/core/payment/validation/JapanBankBranchNameValidator.java similarity index 94% rename from desktop/src/main/java/bisq/desktop/util/validation/JapanBankBranchNameValidator.java rename to core/src/main/java/bisq/core/payment/validation/JapanBankBranchNameValidator.java index 7fd19aab93..9750490fae 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/JapanBankBranchNameValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/JapanBankBranchNameValidator.java @@ -15,9 +15,9 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; -import bisq.desktop.components.paymentmethods.data.JapanBankData; +import bisq.core.payment.JapanBankData; import bisq.core.util.validation.InputValidator; import bisq.core.util.validation.RegexValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/JapanBankTransferValidator.java b/core/src/main/java/bisq/core/payment/validation/JapanBankTransferValidator.java similarity index 97% rename from desktop/src/main/java/bisq/desktop/util/validation/JapanBankTransferValidator.java rename to core/src/main/java/bisq/core/payment/validation/JapanBankTransferValidator.java index 6c20a5fd94..1616db35ec 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/JapanBankTransferValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/JapanBankTransferValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/LengthValidator.java b/core/src/main/java/bisq/core/payment/validation/LengthValidator.java similarity index 96% rename from desktop/src/main/java/bisq/desktop/util/validation/LengthValidator.java rename to core/src/main/java/bisq/core/payment/validation/LengthValidator.java index 7e1dc3e141..e5572b9288 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/LengthValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/LengthValidator.java @@ -1,4 +1,4 @@ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.locale.Res; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/MoneyBeamValidator.java b/core/src/main/java/bisq/core/payment/validation/MoneyBeamValidator.java similarity index 96% rename from desktop/src/main/java/bisq/desktop/util/validation/MoneyBeamValidator.java rename to core/src/main/java/bisq/core/payment/validation/MoneyBeamValidator.java index 259fe26ecb..bb99e90406 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/MoneyBeamValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/MoneyBeamValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/NationalAccountIdValidator.java b/core/src/main/java/bisq/core/payment/validation/NationalAccountIdValidator.java similarity index 95% rename from desktop/src/main/java/bisq/desktop/util/validation/NationalAccountIdValidator.java rename to core/src/main/java/bisq/core/payment/validation/NationalAccountIdValidator.java index c730c01926..9b47db5212 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/NationalAccountIdValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/NationalAccountIdValidator.java @@ -1,4 +1,4 @@ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.locale.BankUtil; import bisq.core.locale.Res; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/PercentageNumberValidator.java b/core/src/main/java/bisq/core/payment/validation/PercentageNumberValidator.java similarity index 98% rename from desktop/src/main/java/bisq/desktop/util/validation/PercentageNumberValidator.java rename to core/src/main/java/bisq/core/payment/validation/PercentageNumberValidator.java index 83e14db61c..0c99fe3edf 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/PercentageNumberValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/PercentageNumberValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.locale.Res; import bisq.core.util.validation.NumberValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/PerfectMoneyValidator.java b/core/src/main/java/bisq/core/payment/validation/PerfectMoneyValidator.java similarity index 97% rename from desktop/src/main/java/bisq/desktop/util/validation/PerfectMoneyValidator.java rename to core/src/main/java/bisq/core/payment/validation/PerfectMoneyValidator.java index 1ac5b3af5c..9bad62b80d 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/PerfectMoneyValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/PerfectMoneyValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/PhoneNumberValidator.java b/core/src/main/java/bisq/core/payment/validation/PhoneNumberValidator.java similarity index 98% rename from desktop/src/main/java/bisq/desktop/util/validation/PhoneNumberValidator.java rename to core/src/main/java/bisq/core/payment/validation/PhoneNumberValidator.java index ae580c2121..9a94ea7d0d 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/PhoneNumberValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/PhoneNumberValidator.java @@ -1,4 +1,4 @@ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.locale.Res; import bisq.core.util.validation.InputValidator; @@ -17,7 +17,7 @@ import javax.annotation.Nullable; * Area codes and mobile provider codes are not validated, but all numbers following * calling codes are included in the normalized number. *

- * @see bisq.desktop.util.validation.CountryCallingCodes + * @see bisq.core.payment.validation.CountryCallingCodes */ public class PhoneNumberValidator extends InputValidator { /** diff --git a/desktop/src/main/java/bisq/desktop/util/validation/PopmoneyValidator.java b/core/src/main/java/bisq/core/payment/validation/PopmoneyValidator.java similarity index 96% rename from desktop/src/main/java/bisq/desktop/util/validation/PopmoneyValidator.java rename to core/src/main/java/bisq/core/payment/validation/PopmoneyValidator.java index 7570aca330..45054c9270 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/PopmoneyValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/PopmoneyValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/PromptPayValidator.java b/core/src/main/java/bisq/core/payment/validation/PromptPayValidator.java similarity index 96% rename from desktop/src/main/java/bisq/desktop/util/validation/PromptPayValidator.java rename to core/src/main/java/bisq/core/payment/validation/PromptPayValidator.java index 52224f7153..87b39a034c 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/PromptPayValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/PromptPayValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/RevolutValidator.java b/core/src/main/java/bisq/core/payment/validation/RevolutValidator.java similarity index 97% rename from desktop/src/main/java/bisq/desktop/util/validation/RevolutValidator.java rename to core/src/main/java/bisq/core/payment/validation/RevolutValidator.java index 4eeac7f7f4..dacbcf7790 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/RevolutValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/RevolutValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; public final class RevolutValidator extends LengthValidator { public RevolutValidator() { diff --git a/desktop/src/main/java/bisq/desktop/util/validation/SecurityDepositValidator.java b/core/src/main/java/bisq/core/payment/validation/SecurityDepositValidator.java similarity index 98% rename from desktop/src/main/java/bisq/desktop/util/validation/SecurityDepositValidator.java rename to core/src/main/java/bisq/core/payment/validation/SecurityDepositValidator.java index 2ae725d781..9755f8dcda 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/SecurityDepositValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/SecurityDepositValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.btc.wallet.Restrictions; import bisq.core.locale.Res; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/SepaIBANValidator.java b/core/src/main/java/bisq/core/payment/validation/SepaIBANValidator.java similarity index 95% rename from desktop/src/main/java/bisq/desktop/util/validation/SepaIBANValidator.java rename to core/src/main/java/bisq/core/payment/validation/SepaIBANValidator.java index 3541e397e7..11682f1d5a 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/SepaIBANValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/SepaIBANValidator.java @@ -1,4 +1,4 @@ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.locale.Country; import bisq.core.locale.CountryUtil; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/SwishValidator.java b/core/src/main/java/bisq/core/payment/validation/SwishValidator.java similarity index 97% rename from desktop/src/main/java/bisq/desktop/util/validation/SwishValidator.java rename to core/src/main/java/bisq/core/payment/validation/SwishValidator.java index 0aadc087a0..358eba7294 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/SwishValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/SwishValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; public final class SwishValidator extends PhoneNumberValidator { diff --git a/desktop/src/main/java/bisq/desktop/util/validation/TransferwiseValidator.java b/core/src/main/java/bisq/core/payment/validation/TransferwiseValidator.java similarity index 97% rename from desktop/src/main/java/bisq/desktop/util/validation/TransferwiseValidator.java rename to core/src/main/java/bisq/core/payment/validation/TransferwiseValidator.java index baf701c539..cec0fad5c6 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/TransferwiseValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/TransferwiseValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/USPostalMoneyOrderValidator.java b/core/src/main/java/bisq/core/payment/validation/USPostalMoneyOrderValidator.java similarity index 97% rename from desktop/src/main/java/bisq/desktop/util/validation/USPostalMoneyOrderValidator.java rename to core/src/main/java/bisq/core/payment/validation/USPostalMoneyOrderValidator.java index 908d421876..c9253fef91 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/USPostalMoneyOrderValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/USPostalMoneyOrderValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/UpholdValidator.java b/core/src/main/java/bisq/core/payment/validation/UpholdValidator.java similarity index 96% rename from desktop/src/main/java/bisq/desktop/util/validation/UpholdValidator.java rename to core/src/main/java/bisq/core/payment/validation/UpholdValidator.java index 27f917301e..afbbe91d8c 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/UpholdValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/UpholdValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/WeChatPayValidator.java b/core/src/main/java/bisq/core/payment/validation/WeChatPayValidator.java similarity index 96% rename from desktop/src/main/java/bisq/desktop/util/validation/WeChatPayValidator.java rename to core/src/main/java/bisq/core/payment/validation/WeChatPayValidator.java index 293db54ac5..5f4bb208bc 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/WeChatPayValidator.java +++ b/core/src/main/java/bisq/core/payment/validation/WeChatPayValidator.java @@ -15,7 +15,7 @@ * along with Haveno. If not, see . */ -package bisq.desktop.util.validation; +package bisq.core.payment.validation; import bisq.core.util.validation.InputValidator; diff --git a/core/src/main/java/bisq/core/util/validation/AltcoinValidator.java b/core/src/main/java/bisq/core/util/validation/AltcoinValidator.java index 890073f824..593c6f1d3d 100644 --- a/core/src/main/java/bisq/core/util/validation/AltcoinValidator.java +++ b/core/src/main/java/bisq/core/util/validation/AltcoinValidator.java @@ -21,12 +21,12 @@ import javax.inject.Inject; public class AltcoinValidator extends MonetaryValidator { @Override - protected double getMinValue() { + public double getMinValue() { return 0.00000001; } @Override - protected double getMaxValue() { + public double getMaxValue() { // hard to say what the max value should be with altcoins return 100_000_000; } diff --git a/core/src/main/java/bisq/core/util/validation/FiatPriceValidator.java b/core/src/main/java/bisq/core/util/validation/FiatPriceValidator.java index 5986fae545..3f7b162f2b 100644 --- a/core/src/main/java/bisq/core/util/validation/FiatPriceValidator.java +++ b/core/src/main/java/bisq/core/util/validation/FiatPriceValidator.java @@ -21,12 +21,12 @@ import javax.inject.Inject; public class FiatPriceValidator extends MonetaryValidator { @Override - protected double getMinValue() { + public double getMinValue() { return 0.0001; } @Override - protected double getMaxValue() { + public double getMaxValue() { // Hard to say what the max value should be (zimbabwe dollar....)? // Lets set it to Double.MAX_VALUE until we find some reasonable number return Double.MAX_VALUE; diff --git a/core/src/main/java/bisq/core/util/validation/MonetaryValidator.java b/core/src/main/java/bisq/core/util/validation/MonetaryValidator.java index 3513aa0800..2bfa5cff06 100644 --- a/core/src/main/java/bisq/core/util/validation/MonetaryValidator.java +++ b/core/src/main/java/bisq/core/util/validation/MonetaryValidator.java @@ -22,10 +22,10 @@ import javax.inject.Inject; public abstract class MonetaryValidator extends NumberValidator { - protected abstract double getMinValue(); + public abstract double getMinValue(); @SuppressWarnings("SameReturnValue") - protected abstract double getMaxValue(); + public abstract double getMaxValue(); @Inject public MonetaryValidator() { diff --git a/daemon/src/main/java/bisq/daemon/grpc/GrpcPaymentAccountsService.java b/daemon/src/main/java/bisq/daemon/grpc/GrpcPaymentAccountsService.java index ca901ea701..dc99dde2a4 100644 --- a/daemon/src/main/java/bisq/daemon/grpc/GrpcPaymentAccountsService.java +++ b/daemon/src/main/java/bisq/daemon/grpc/GrpcPaymentAccountsService.java @@ -18,6 +18,8 @@ package bisq.daemon.grpc; import bisq.core.api.CoreApi; +import bisq.core.api.model.PaymentAccountForm; +import bisq.core.api.model.PaymentAccountFormField; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.PaymentMethod; @@ -33,7 +35,8 @@ import bisq.proto.grpc.GetPaymentAccountsReply; import bisq.proto.grpc.GetPaymentAccountsRequest; import bisq.proto.grpc.GetPaymentMethodsReply; import bisq.proto.grpc.GetPaymentMethodsRequest; - +import bisq.proto.grpc.ValidateFormFieldReply; +import bisq.proto.grpc.ValidateFormFieldRequest; import io.grpc.ServerInterceptor; import io.grpc.stub.StreamObserver; @@ -47,7 +50,6 @@ import lombok.extern.slf4j.Slf4j; import static bisq.daemon.grpc.interceptor.GrpcServiceRateMeteringConfig.getCustomRateMeteringInterceptor; import static bisq.proto.grpc.PaymentAccountsGrpc.*; -import static java.util.concurrent.TimeUnit.MINUTES; import static java.util.concurrent.TimeUnit.SECONDS; @@ -71,7 +73,7 @@ class GrpcPaymentAccountsService extends PaymentAccountsImplBase { public void createPaymentAccount(CreatePaymentAccountRequest req, StreamObserver responseObserver) { try { - PaymentAccount paymentAccount = coreApi.createPaymentAccount(req.getPaymentAccountForm()); + PaymentAccount paymentAccount = coreApi.createPaymentAccount(PaymentAccountForm.fromProto(req.getPaymentAccountForm())); var reply = CreatePaymentAccountReply.newBuilder() .setPaymentAccount(paymentAccount.toProtoMessage()) .build(); @@ -118,9 +120,9 @@ class GrpcPaymentAccountsService extends PaymentAccountsImplBase { public void getPaymentAccountForm(GetPaymentAccountFormRequest req, StreamObserver responseObserver) { try { - var paymentAccountFormJson = coreApi.getPaymentAccountForm(req.getPaymentMethodId()); + var form = coreApi.getPaymentAccountForm(req.getPaymentMethodId()); var reply = GetPaymentAccountFormReply.newBuilder() - .setPaymentAccountFormJson(paymentAccountFormJson) + .setPaymentAccountForm(form.toProtoMessage()) .build(); responseObserver.onNext(reply); responseObserver.onCompleted(); @@ -162,6 +164,19 @@ class GrpcPaymentAccountsService extends PaymentAccountsImplBase { exceptionHandler.handleException(log, cause, responseObserver); } } + + @Override + public void validateFormField(ValidateFormFieldRequest req, + StreamObserver responseObserver) { + try { + coreApi.validateFormField(PaymentAccountForm.fromProto(req.getForm()), PaymentAccountFormField.FieldId.fromProto(req.getFieldId()), req.getValue()); + var reply = ValidateFormFieldReply.newBuilder().build(); + responseObserver.onNext(reply); + responseObserver.onCompleted(); + } catch (Throwable cause) { + exceptionHandler.handleException(log, cause, responseObserver); + } + } final ServerInterceptor[] interceptors() { Optional rateMeteringInterceptor = rateMeteringInterceptor(); @@ -173,11 +188,11 @@ class GrpcPaymentAccountsService extends PaymentAccountsImplBase { return getCustomRateMeteringInterceptor(coreApi.getConfig().appDataDir, this.getClass()) .or(() -> Optional.of(CallRateMeteringInterceptor.valueOf( new HashMap<>() {{ - put(getCreatePaymentAccountMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS)); - put(getCreateCryptoCurrencyPaymentAccountMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS)); - put(getGetPaymentAccountsMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS)); - put(getGetPaymentMethodsMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS)); - put(getGetPaymentAccountFormMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS)); + put(getCreatePaymentAccountMethod().getFullMethodName(), new GrpcCallRateMeter(100, SECONDS)); + put(getCreateCryptoCurrencyPaymentAccountMethod().getFullMethodName(), new GrpcCallRateMeter(100, SECONDS)); + put(getGetPaymentAccountsMethod().getFullMethodName(), new GrpcCallRateMeter(100, SECONDS)); + put(getGetPaymentMethodsMethod().getFullMethodName(), new GrpcCallRateMeter(100, SECONDS)); + put(getGetPaymentAccountFormMethod().getFullMethodName(), new GrpcCallRateMeter(100, SECONDS)); }} ))); } diff --git a/desktop/src/main/java/bisq/desktop/components/InputTextField.java b/desktop/src/main/java/bisq/desktop/components/InputTextField.java index edd9c93b84..edaee3e712 100644 --- a/desktop/src/main/java/bisq/desktop/components/InputTextField.java +++ b/desktop/src/main/java/bisq/desktop/components/InputTextField.java @@ -18,11 +18,9 @@ package bisq.desktop.components; -import bisq.desktop.util.validation.JFXInputValidator; - import bisq.core.locale.Res; import bisq.core.util.validation.InputValidator; - +import bisq.desktop.util.validation.JFXInputValidator; import com.jfoenix.controls.JFXTextField; import javafx.scene.control.Skin; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/AdvancedCashForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/AdvancedCashForm.java index 6937ab1614..a1e82cdc82 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/AdvancedCashForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/AdvancedCashForm.java @@ -19,14 +19,13 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.FormBuilder; -import bisq.desktop.util.validation.AdvancedCashValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Res; import bisq.core.payment.AdvancedCashAccount; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.AdvancedCashAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.validation.AdvancedCashValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/AliPayForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/AliPayForm.java index 90a96c4822..97fdc1d8c2 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/AliPayForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/AliPayForm.java @@ -17,14 +17,13 @@ package bisq.desktop.components.paymentmethods; -import bisq.desktop.util.validation.AliPayValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Res; import bisq.core.payment.AliPayAccount; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.AliPayAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.validation.AliPayValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/AustraliaPayidForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/AustraliaPayidForm.java index 1101a9725b..a19d83436d 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/AustraliaPayidForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/AustraliaPayidForm.java @@ -19,8 +19,6 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.FormBuilder; -import bisq.desktop.util.validation.AustraliaPayidValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Res; import bisq.core.locale.TradeCurrency; @@ -28,6 +26,7 @@ import bisq.core.payment.AustraliaPayidAccount; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.AustraliaPayidAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.validation.AustraliaPayidValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/CapitualForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/CapitualForm.java index 939f630ace..890dc40de3 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/CapitualForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/CapitualForm.java @@ -19,14 +19,13 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.FormBuilder; -import bisq.desktop.util.validation.CapitualValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Res; import bisq.core.payment.CapitualAccount; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.CapitualAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.validation.CapitualValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/CashDepositForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/CashDepositForm.java index b3ad552833..c8a4c042b4 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/CashDepositForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/CashDepositForm.java @@ -19,8 +19,6 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.GUIUtil; -import bisq.desktop.util.validation.EmailValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.BankUtil; import bisq.core.locale.Country; @@ -33,6 +31,7 @@ import bisq.core.payment.CountryBasedPaymentAccount; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.CashDepositAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.validation.EmailValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/CelPayForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/CelPayForm.java index e4f2167460..f796e2ef70 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/CelPayForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/CelPayForm.java @@ -19,14 +19,13 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.FormBuilder; -import bisq.desktop.util.validation.EmailValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Res; import bisq.core.payment.CelPayAccount; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.CelPayAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.validation.EmailValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/ChaseQuickPayForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/ChaseQuickPayForm.java index f8ca113132..ce601124e9 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/ChaseQuickPayForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/ChaseQuickPayForm.java @@ -19,8 +19,6 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.FormBuilder; -import bisq.desktop.util.validation.ChaseQuickPayValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Res; import bisq.core.locale.TradeCurrency; @@ -28,6 +26,7 @@ import bisq.core.payment.ChaseQuickPayAccount; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.ChaseQuickPayAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.validation.ChaseQuickPayValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/ClearXchangeForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/ClearXchangeForm.java index 7fa5d92a14..2eb85671a5 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/ClearXchangeForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/ClearXchangeForm.java @@ -19,8 +19,6 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.FormBuilder; -import bisq.desktop.util.validation.ClearXchangeValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Res; import bisq.core.locale.TradeCurrency; @@ -28,6 +26,7 @@ import bisq.core.payment.ClearXchangeAccount; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.ClearXchangeAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.validation.EmailOrMobileNrValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; @@ -40,7 +39,7 @@ import static bisq.desktop.util.FormBuilder.addTopLabelTextField; public class ClearXchangeForm extends PaymentMethodForm { private final ClearXchangeAccount clearXchangeAccount; - private final ClearXchangeValidator clearXchangeValidator; + private final EmailOrMobileNrValidator clearXchangeValidator; public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) { addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.account.owner"), @@ -50,7 +49,7 @@ public class ClearXchangeForm extends PaymentMethodForm { return gridRow; } - public ClearXchangeForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, ClearXchangeValidator clearXchangeValidator, InputValidator inputValidator, GridPane gridPane, int gridRow, CoinFormatter formatter) { + public ClearXchangeForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, EmailOrMobileNrValidator clearXchangeValidator, InputValidator inputValidator, GridPane gridPane, int gridRow, CoinFormatter formatter) { super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter); this.clearXchangeAccount = (ClearXchangeAccount) paymentAccount; this.clearXchangeValidator = clearXchangeValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/F2FForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/F2FForm.java index 93c8eceb8f..e8057e5a97 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/F2FForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/F2FForm.java @@ -19,8 +19,6 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.GUIUtil; -import bisq.desktop.util.validation.F2FValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Country; import bisq.core.locale.CountryUtil; @@ -34,6 +32,7 @@ import bisq.core.payment.F2FAccount; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.F2FAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.validation.F2FValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/FasterPaymentsForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/FasterPaymentsForm.java index 153043c0ff..4601d092d6 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/FasterPaymentsForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/FasterPaymentsForm.java @@ -19,9 +19,6 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.FormBuilder; -import bisq.desktop.util.validation.AccountNrValidator; -import bisq.desktop.util.validation.BranchIdValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Res; import bisq.core.locale.TradeCurrency; @@ -29,6 +26,8 @@ import bisq.core.payment.FasterPaymentsAccount; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.FasterPaymentsAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.validation.AccountNrValidator; +import bisq.core.payment.validation.BranchIdValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/GeneralBankForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/GeneralBankForm.java index 75d76c81bf..62dbfbb58d 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/GeneralBankForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/GeneralBankForm.java @@ -1,16 +1,15 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; -import bisq.desktop.util.validation.AccountNrValidator; -import bisq.desktop.util.validation.BankIdValidator; -import bisq.desktop.util.validation.BranchIdValidator; -import bisq.desktop.util.validation.NationalAccountIdValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.BankUtil; import bisq.core.locale.Res; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.BankAccountPayload; +import bisq.core.payment.validation.AccountNrValidator; +import bisq.core.payment.validation.BankIdValidator; +import bisq.core.payment.validation.BranchIdValidator; +import bisq.core.payment.validation.NationalAccountIdValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/HalCashForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/HalCashForm.java index b605e1945b..d63e970815 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/HalCashForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/HalCashForm.java @@ -19,8 +19,6 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.FormBuilder; -import bisq.desktop.util.validation.HalCashValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Res; import bisq.core.locale.TradeCurrency; @@ -28,6 +26,7 @@ import bisq.core.payment.HalCashAccount; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.HalCashAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.validation.HalCashValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/InteracETransferForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/InteracETransferForm.java index b91793e98f..334a92e17a 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/InteracETransferForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/InteracETransferForm.java @@ -19,8 +19,6 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.FormBuilder; -import bisq.desktop.util.validation.InteracETransferValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Res; import bisq.core.locale.TradeCurrency; @@ -28,6 +26,7 @@ import bisq.core.payment.InteracETransferAccount; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.InteracETransferAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.validation.InteracETransferValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/JapanBankTransferForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/JapanBankTransferForm.java index 40bad1b307..b317b97f1e 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/JapanBankTransferForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/JapanBankTransferForm.java @@ -19,20 +19,19 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.AutocompleteComboBox; import bisq.desktop.components.InputTextField; -import bisq.desktop.components.paymentmethods.data.JapanBankData; -import bisq.desktop.util.validation.JapanBankAccountNameValidator; -import bisq.desktop.util.validation.JapanBankAccountNumberValidator; -import bisq.desktop.util.validation.JapanBankBranchCodeValidator; -import bisq.desktop.util.validation.JapanBankBranchNameValidator; -import bisq.desktop.util.validation.LengthValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Res; import bisq.core.locale.TradeCurrency; import bisq.core.payment.JapanBankAccount; +import bisq.core.payment.JapanBankData; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.JapanBankAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.validation.JapanBankAccountNameValidator; +import bisq.core.payment.validation.JapanBankAccountNumberValidator; +import bisq.core.payment.validation.JapanBankBranchCodeValidator; +import bisq.core.payment.validation.JapanBankBranchNameValidator; +import bisq.core.payment.validation.LengthValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; import bisq.core.util.validation.RegexValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/MoneyBeamForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/MoneyBeamForm.java index cc5282e0a4..0b1f867379 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/MoneyBeamForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/MoneyBeamForm.java @@ -19,8 +19,6 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.FormBuilder; -import bisq.desktop.util.validation.MoneyBeamValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Res; import bisq.core.locale.TradeCurrency; @@ -28,6 +26,7 @@ import bisq.core.payment.MoneyBeamAccount; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.MoneyBeamAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.validation.MoneyBeamValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/MoneyGramForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/MoneyGramForm.java index 684354903a..3fceb53e15 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/MoneyGramForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/MoneyGramForm.java @@ -20,8 +20,6 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.GUIUtil; import bisq.desktop.util.Layout; -import bisq.desktop.util.validation.EmailValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.BankUtil; import bisq.core.locale.Country; @@ -31,6 +29,7 @@ import bisq.core.payment.MoneyGramAccount; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.MoneyGramAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.validation.EmailValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; @@ -171,7 +170,7 @@ public class MoneyGramForm extends PaymentMethodForm { @Override protected void autoFillNameTextField() { - setAccountNameWithString(moneyGramAccountPayload.getHolderName()); + setAccountNameWithString(moneyGramAccountPayload.getHolderName() == null ? "" : moneyGramAccountPayload.getHolderName()); } @Override diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/PaxumForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/PaxumForm.java index 14f68bced2..e693eb0862 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/PaxumForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/PaxumForm.java @@ -19,14 +19,13 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.FormBuilder; -import bisq.desktop.util.validation.EmailValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Res; import bisq.core.payment.PaxumAccount; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.PaxumAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.validation.EmailValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/PayseraForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/PayseraForm.java index ef4e829448..ff605d91e9 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/PayseraForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/PayseraForm.java @@ -19,14 +19,13 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.FormBuilder; -import bisq.desktop.util.validation.EmailValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Res; import bisq.core.payment.PaymentAccount; import bisq.core.payment.PayseraAccount; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.PayseraAccountPayload; +import bisq.core.payment.validation.EmailValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/PerfectMoneyForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/PerfectMoneyForm.java index 63075b346d..1d8a30aa76 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/PerfectMoneyForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/PerfectMoneyForm.java @@ -17,8 +17,6 @@ package bisq.desktop.components.paymentmethods; -import bisq.desktop.util.validation.PerfectMoneyValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.FiatCurrency; import bisq.core.locale.Res; @@ -26,6 +24,7 @@ import bisq.core.payment.PaymentAccount; import bisq.core.payment.PerfectMoneyAccount; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.PerfectMoneyAccountPayload; +import bisq.core.payment.validation.PerfectMoneyValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/PopmoneyForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/PopmoneyForm.java index e69d0b9e83..d8cb6100f9 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/PopmoneyForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/PopmoneyForm.java @@ -19,8 +19,6 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.FormBuilder; -import bisq.desktop.util.validation.PopmoneyValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Res; import bisq.core.locale.TradeCurrency; @@ -28,6 +26,7 @@ import bisq.core.payment.PaymentAccount; import bisq.core.payment.PopmoneyAccount; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.PopmoneyAccountPayload; +import bisq.core.payment.validation.PopmoneyValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/PromptPayForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/PromptPayForm.java index 732e33dcb0..e030572e9f 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/PromptPayForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/PromptPayForm.java @@ -18,8 +18,6 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; -import bisq.desktop.util.validation.PromptPayValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Res; import bisq.core.locale.TradeCurrency; @@ -27,6 +25,7 @@ import bisq.core.payment.PaymentAccount; import bisq.core.payment.PromptPayAccount; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.PromptPayAccountPayload; +import bisq.core.payment.validation.PromptPayValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/RevolutForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/RevolutForm.java index 97a0102c7f..d157741def 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/RevolutForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/RevolutForm.java @@ -20,14 +20,13 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.FormBuilder; import bisq.desktop.util.Layout; -import bisq.desktop.util.validation.RevolutValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Res; import bisq.core.payment.PaymentAccount; import bisq.core.payment.RevolutAccount; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.RevolutAccountPayload; +import bisq.core.payment.validation.RevolutValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaForm.java index 5ce4a68fdd..cf1077bf84 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaForm.java @@ -17,11 +17,8 @@ package bisq.desktop.components.paymentmethods; -import bisq.desktop.components.InputTextField; -import bisq.desktop.util.FormBuilder; -import bisq.desktop.util.normalization.IBANNormalizer; -import bisq.desktop.util.validation.BICValidator; -import bisq.desktop.util.validation.SepaIBANValidator; +import static bisq.desktop.util.FormBuilder.addCompactTopLabelTextField; +import static bisq.desktop.util.FormBuilder.addCompactTopLabelTextFieldWithCopyIcon; import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Country; @@ -32,21 +29,20 @@ import bisq.core.payment.PaymentAccount; import bisq.core.payment.SepaAccount; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.SepaAccountPayload; +import bisq.core.payment.validation.BICValidator; +import bisq.core.payment.validation.SepaIBANValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; - +import bisq.desktop.components.InputTextField; +import bisq.desktop.util.FormBuilder; +import bisq.desktop.util.normalization.IBANNormalizer; +import java.util.List; +import java.util.Optional; +import javafx.collections.FXCollections; import javafx.scene.control.ComboBox; import javafx.scene.control.TextFormatter; import javafx.scene.layout.GridPane; -import javafx.collections.FXCollections; - -import java.util.List; -import java.util.Optional; - -import static bisq.desktop.util.FormBuilder.addCompactTopLabelTextField; -import static bisq.desktop.util.FormBuilder.addCompactTopLabelTextFieldWithCopyIcon; - public class SepaForm extends GeneralSepaForm { public static int addFormForBuyer(GridPane gridPane, int gridRow, diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaInstantForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaInstantForm.java index 8d359c4af7..b601489dbe 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaInstantForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/SepaInstantForm.java @@ -20,9 +20,6 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.FormBuilder; import bisq.desktop.util.normalization.IBANNormalizer; -import bisq.desktop.util.validation.BICValidator; -import bisq.desktop.util.validation.SepaIBANValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Country; import bisq.core.locale.CountryUtil; @@ -32,6 +29,8 @@ import bisq.core.payment.PaymentAccount; import bisq.core.payment.SepaInstantAccount; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.SepaInstantAccountPayload; +import bisq.core.payment.validation.BICValidator; +import bisq.core.payment.validation.SepaIBANValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/SwiftForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/SwiftForm.java index b559412249..a6a1e175f2 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/SwiftForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/SwiftForm.java @@ -23,8 +23,6 @@ import bisq.desktop.components.InputTextField; import bisq.desktop.main.overlays.windows.SwiftPaymentDetails; import bisq.desktop.util.GUIUtil; import bisq.desktop.util.Layout; -import bisq.desktop.util.validation.LengthValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Country; import bisq.core.locale.CountryUtil; @@ -33,6 +31,7 @@ import bisq.core.payment.PaymentAccount; import bisq.core.payment.SwiftAccount; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.SwiftAccountPayload; +import bisq.core.payment.validation.LengthValidator; import bisq.core.trade.Trade; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/SwishForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/SwishForm.java index 2777ea95d2..9a73322e58 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/SwishForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/SwishForm.java @@ -19,8 +19,6 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.FormBuilder; -import bisq.desktop.util.validation.SwishValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Res; import bisq.core.locale.TradeCurrency; @@ -28,6 +26,7 @@ import bisq.core.payment.PaymentAccount; import bisq.core.payment.SwishAccount; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.SwishAccountPayload; +import bisq.core.payment.validation.SwishValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/TikkieForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/TikkieForm.java index abd9844476..94b1735658 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/TikkieForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/TikkieForm.java @@ -19,8 +19,6 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.FormBuilder; -import bisq.desktop.util.validation.IBANValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.CountryUtil; import bisq.core.locale.Res; @@ -28,6 +26,7 @@ import bisq.core.payment.PaymentAccount; import bisq.core.payment.TikkieAccount; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.TikkieAccountPayload; +import bisq.core.payment.validation.IBANValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/TransferwiseForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/TransferwiseForm.java index 0dcccd7238..927613a0ec 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/TransferwiseForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/TransferwiseForm.java @@ -19,14 +19,13 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.FormBuilder; -import bisq.desktop.util.validation.TransferwiseValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Res; import bisq.core.payment.PaymentAccount; import bisq.core.payment.TransferwiseAccount; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.TransferwiseAccountPayload; +import bisq.core.payment.validation.TransferwiseValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/TransferwiseUsdForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/TransferwiseUsdForm.java index b1a5932705..e3bfadc429 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/TransferwiseUsdForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/TransferwiseUsdForm.java @@ -19,9 +19,6 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.Layout; -import bisq.desktop.util.validation.EmailValidator; -import bisq.desktop.util.validation.LengthValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.CountryUtil; import bisq.core.locale.Res; @@ -29,6 +26,8 @@ import bisq.core.payment.PaymentAccount; import bisq.core.payment.TransferwiseUsdAccount; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.TransferwiseUsdAccountPayload; +import bisq.core.payment.validation.EmailValidator; +import bisq.core.payment.validation.LengthValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/USPostalMoneyOrderForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/USPostalMoneyOrderForm.java index a95af184d6..ea089b6826 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/USPostalMoneyOrderForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/USPostalMoneyOrderForm.java @@ -19,8 +19,6 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.FormBuilder; -import bisq.desktop.util.validation.USPostalMoneyOrderValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Res; import bisq.core.locale.TradeCurrency; @@ -28,6 +26,7 @@ import bisq.core.payment.PaymentAccount; import bisq.core.payment.USPostalMoneyOrderAccount; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.USPostalMoneyOrderAccountPayload; +import bisq.core.payment.validation.USPostalMoneyOrderValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/UpholdForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/UpholdForm.java index 9eaa7a8156..bbf9fc3b81 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/UpholdForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/UpholdForm.java @@ -19,14 +19,13 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.FormBuilder; -import bisq.desktop.util.validation.UpholdValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Res; import bisq.core.payment.PaymentAccount; import bisq.core.payment.UpholdAccount; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.UpholdAccountPayload; +import bisq.core.payment.validation.UpholdValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/WeChatPayForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/WeChatPayForm.java index 80d5e621e9..238a0acee1 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/WeChatPayForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/WeChatPayForm.java @@ -17,14 +17,13 @@ package bisq.desktop.components.paymentmethods; -import bisq.desktop.util.validation.WeChatPayValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Res; import bisq.core.payment.PaymentAccount; import bisq.core.payment.WeChatPayAccount; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.WeChatPayAccountPayload; +import bisq.core.payment.validation.WeChatPayValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/WesternUnionForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/WesternUnionForm.java index b5bea066be..dd285bac84 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/WesternUnionForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/WesternUnionForm.java @@ -20,8 +20,6 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; import bisq.desktop.util.FormBuilder; import bisq.desktop.util.GUIUtil; -import bisq.desktop.util.validation.EmailValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.BankUtil; import bisq.core.locale.Country; @@ -33,6 +31,7 @@ import bisq.core.payment.CountryBasedPaymentAccount; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.WesternUnionAccountPayload; +import bisq.core.payment.validation.EmailValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.validation.InputValidator; diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java b/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java index 1a1b294547..6609c2d338 100644 --- a/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java +++ b/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java @@ -76,29 +76,6 @@ import bisq.desktop.main.overlays.popups.Popup; import bisq.desktop.util.FormBuilder; import bisq.desktop.util.GUIUtil; import bisq.desktop.util.Layout; -import bisq.desktop.util.validation.AdvancedCashValidator; -import bisq.desktop.util.validation.AliPayValidator; -import bisq.desktop.util.validation.AustraliaPayidValidator; -import bisq.desktop.util.validation.BICValidator; -import bisq.desktop.util.validation.CapitualValidator; -import bisq.desktop.util.validation.ChaseQuickPayValidator; -import bisq.desktop.util.validation.ClearXchangeValidator; -import bisq.desktop.util.validation.F2FValidator; -import bisq.desktop.util.validation.HalCashValidator; -import bisq.desktop.util.validation.InteracETransferValidator; -import bisq.desktop.util.validation.JapanBankTransferValidator; -import bisq.desktop.util.validation.LengthValidator; -import bisq.desktop.util.validation.MoneyBeamValidator; -import bisq.desktop.util.validation.PerfectMoneyValidator; -import bisq.desktop.util.validation.PopmoneyValidator; -import bisq.desktop.util.validation.PromptPayValidator; -import bisq.desktop.util.validation.RevolutValidator; -import bisq.desktop.util.validation.SwishValidator; -import bisq.desktop.util.validation.TransferwiseValidator; -import bisq.desktop.util.validation.USPostalMoneyOrderValidator; -import bisq.desktop.util.validation.UpholdValidator; -import bisq.desktop.util.validation.WeChatPayValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Res; import bisq.core.offer.OfferRestrictions; @@ -116,6 +93,28 @@ import bisq.core.payment.RevolutAccount; import bisq.core.payment.USPostalMoneyOrderAccount; import bisq.core.payment.WesternUnionAccount; import bisq.core.payment.payload.PaymentMethod; +import bisq.core.payment.validation.AdvancedCashValidator; +import bisq.core.payment.validation.AliPayValidator; +import bisq.core.payment.validation.AustraliaPayidValidator; +import bisq.core.payment.validation.BICValidator; +import bisq.core.payment.validation.CapitualValidator; +import bisq.core.payment.validation.ChaseQuickPayValidator; +import bisq.core.payment.validation.EmailOrMobileNrValidator; +import bisq.core.payment.validation.F2FValidator; +import bisq.core.payment.validation.HalCashValidator; +import bisq.core.payment.validation.InteracETransferValidator; +import bisq.core.payment.validation.JapanBankTransferValidator; +import bisq.core.payment.validation.LengthValidator; +import bisq.core.payment.validation.MoneyBeamValidator; +import bisq.core.payment.validation.PerfectMoneyValidator; +import bisq.core.payment.validation.PopmoneyValidator; +import bisq.core.payment.validation.PromptPayValidator; +import bisq.core.payment.validation.RevolutValidator; +import bisq.core.payment.validation.SwishValidator; +import bisq.core.payment.validation.TransferwiseValidator; +import bisq.core.payment.validation.USPostalMoneyOrderValidator; +import bisq.core.payment.validation.UpholdValidator; +import bisq.core.payment.validation.WeChatPayValidator; import bisq.core.util.FormattingUtils; import bisq.core.util.coin.CoinFormatter; @@ -164,7 +163,7 @@ public class FiatAccountsView extends PaymentAccountsView list = PaymentMethod.getPaymentMethods().stream() + List list = PaymentMethod.paymentMethods.stream() .filter(PaymentMethod::isFiat) .sorted() .collect(Collectors.toList()); diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/notifications/MobileNotificationsView.java b/desktop/src/main/java/bisq/desktop/main/account/content/notifications/MobileNotificationsView.java index 595bd50a2b..1501812adf 100644 --- a/desktop/src/main/java/bisq/desktop/main/account/content/notifications/MobileNotificationsView.java +++ b/desktop/src/main/java/bisq/desktop/main/account/content/notifications/MobileNotificationsView.java @@ -25,8 +25,6 @@ import bisq.desktop.main.overlays.popups.Popup; import bisq.desktop.util.FormBuilder; import bisq.desktop.util.GUIUtil; import bisq.desktop.util.Layout; -import bisq.desktop.util.validation.PercentageNumberValidator; - import bisq.core.locale.CurrencyUtil; import bisq.core.locale.Res; import bisq.core.locale.TradeCurrency; @@ -40,6 +38,7 @@ import bisq.core.notifications.alerts.market.MarketAlerts; import bisq.core.notifications.alerts.price.PriceAlert; import bisq.core.notifications.alerts.price.PriceAlertFilter; import bisq.core.payment.PaymentAccount; +import bisq.core.payment.validation.PercentageNumberValidator; import bisq.core.provider.price.PriceFeedService; import bisq.core.user.Preferences; import bisq.core.user.User; diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/password/PasswordView.java b/desktop/src/main/java/bisq/desktop/main/account/content/password/PasswordView.java index 10e95270cc..937a8b3801 100644 --- a/desktop/src/main/java/bisq/desktop/main/account/content/password/PasswordView.java +++ b/desktop/src/main/java/bisq/desktop/main/account/content/password/PasswordView.java @@ -31,7 +31,6 @@ import bisq.desktop.main.account.content.seedwords.SeedWordsView; import bisq.desktop.main.overlays.popups.Popup; import bisq.desktop.util.Layout; import bisq.desktop.util.validation.PasswordValidator; - import bisq.core.btc.wallet.WalletsManager; import bisq.core.locale.Res; import bisq.common.crypto.ScryptUtil; diff --git a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java index 84e8b00cd5..b1bd166f0b 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java @@ -27,10 +27,6 @@ import bisq.desktop.main.settings.SettingsView; import bisq.desktop.main.settings.preferences.PreferencesView; import bisq.desktop.util.DisplayUtils; import bisq.desktop.util.GUIUtil; -import bisq.desktop.util.validation.BtcValidator; -import bisq.desktop.util.validation.FiatVolumeValidator; -import bisq.desktop.util.validation.SecurityDepositValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.btc.wallet.Restrictions; import bisq.core.locale.CurrencyUtil; @@ -46,6 +42,9 @@ import bisq.core.offer.OfferRestrictions; import bisq.core.offer.OfferUtil; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.PaymentMethod; +import bisq.core.payment.validation.BtcValidator; +import bisq.core.payment.validation.FiatVolumeValidator; +import bisq.core.payment.validation.SecurityDepositValidator; import bisq.core.provider.fee.FeeService; import bisq.core.provider.price.MarketPrice; import bisq.core.provider.price.PriceFeedService; diff --git a/desktop/src/main/java/bisq/desktop/main/offer/createoffer/CreateOfferViewModel.java b/desktop/src/main/java/bisq/desktop/main/offer/createoffer/CreateOfferViewModel.java index 9628d9b12b..123be11735 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/createoffer/CreateOfferViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/createoffer/CreateOfferViewModel.java @@ -20,12 +20,11 @@ package bisq.desktop.main.offer.createoffer; import bisq.desktop.Navigation; import bisq.desktop.common.model.ViewModel; import bisq.desktop.main.offer.MutableOfferViewModel; -import bisq.desktop.util.validation.BtcValidator; -import bisq.desktop.util.validation.FiatVolumeValidator; -import bisq.desktop.util.validation.SecurityDepositValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.offer.OfferUtil; +import bisq.core.payment.validation.BtcValidator; +import bisq.core.payment.validation.FiatVolumeValidator; +import bisq.core.payment.validation.SecurityDepositValidator; import bisq.core.provider.price.PriceFeedService; import bisq.core.user.Preferences; import bisq.core.util.FormattingUtils; diff --git a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java index e2d865e347..098240a280 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java @@ -349,7 +349,7 @@ abstract class OfferBookViewModel extends ActivatableViewModel { } ObservableList getPaymentMethods() { - ObservableList list = FXCollections.observableArrayList(PaymentMethod.getPaymentMethods()); + ObservableList list = FXCollections.observableArrayList(PaymentMethod.paymentMethods); if (preferences.isHideNonAccountPaymentMethods() && user.getPaymentAccounts() != null) { Set supportedPaymentMethods = user.getPaymentAccounts().stream() .map(PaymentAccount::getPaymentMethod).collect(Collectors.toSet()); diff --git a/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferViewModel.java b/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferViewModel.java index 3558e46071..1cac6ad2e4 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferViewModel.java @@ -27,8 +27,6 @@ import bisq.desktop.main.offer.OfferViewModelUtil; import bisq.desktop.main.overlays.popups.Popup; import bisq.desktop.util.DisplayUtils; import bisq.desktop.util.GUIUtil; -import bisq.desktop.util.validation.BtcValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.btc.wallet.Restrictions; import bisq.core.locale.CurrencyUtil; @@ -40,6 +38,7 @@ import bisq.core.offer.OfferRestrictions; import bisq.core.offer.OfferUtil; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.PaymentMethod; +import bisq.core.payment.validation.BtcValidator; import bisq.core.provider.fee.FeeService; import bisq.core.trade.Trade; import bisq.core.util.FormattingUtils; diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/EditCustomExplorerWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/EditCustomExplorerWindow.java index c1340d99e9..98e9f9e160 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/EditCustomExplorerWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/EditCustomExplorerWindow.java @@ -22,9 +22,8 @@ import bisq.desktop.components.AutoTooltipLabel; import bisq.desktop.components.InputTextField; import bisq.desktop.main.overlays.Overlay; import bisq.desktop.util.Layout; -import bisq.desktop.util.validation.LengthValidator; - import bisq.core.locale.Res; +import bisq.core.payment.validation.LengthValidator; import bisq.core.util.validation.UrlInputValidator; import bisq.common.util.Tuple2; diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/ManualPayoutTxWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/ManualPayoutTxWindow.java index daa812760e..e4cecd23de 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/ManualPayoutTxWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/ManualPayoutTxWindow.java @@ -23,8 +23,6 @@ import bisq.desktop.components.InputTextField; import bisq.desktop.main.overlays.Overlay; import bisq.desktop.main.overlays.popups.Popup; import bisq.desktop.util.GUIUtil; -import bisq.desktop.util.validation.LengthValidator; -import bisq.desktop.util.validation.PercentageNumberValidator; import bisq.core.api.CoreMoneroConnectionsService; import bisq.core.btc.exceptions.TransactionVerificationException; import bisq.core.btc.exceptions.TxBroadcastException; @@ -33,6 +31,8 @@ import bisq.core.btc.wallet.TradeWalletService; import bisq.core.btc.wallet.TxBroadcaster; import bisq.core.btc.wallet.WalletsManager; import bisq.core.locale.Res; +import bisq.core.payment.validation.LengthValidator; +import bisq.core.payment.validation.PercentageNumberValidator; import bisq.core.support.dispute.Dispute; import bisq.core.support.dispute.mediation.MediationManager; import bisq.core.user.BlockChainExplorer; diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/SignPaymentAccountsWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/SignPaymentAccountsWindow.java index 27dd7c21c4..d63a8d0a95 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/SignPaymentAccountsWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/SignPaymentAccountsWindow.java @@ -170,7 +170,7 @@ public class SignPaymentAccountsWindow extends Overlay getPaymentMethods() { - return PaymentMethod.getPaymentMethods().stream() + return PaymentMethod.paymentMethods.stream() .filter(PaymentMethod::isFiat) .filter(PaymentMethod::hasChargebackRisk) .collect(Collectors.toList()); diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/UpdateRevolutAccountWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/UpdateRevolutAccountWindow.java index 9eaca8bbed..9dd214efc9 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/UpdateRevolutAccountWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/UpdateRevolutAccountWindow.java @@ -20,10 +20,9 @@ package bisq.desktop.main.overlays.windows; import bisq.desktop.components.InputTextField; import bisq.desktop.main.overlays.Overlay; import bisq.desktop.util.Layout; -import bisq.desktop.util.validation.RevolutValidator; - import bisq.core.locale.Res; import bisq.core.payment.RevolutAccount; +import bisq.core.payment.validation.RevolutValidator; import bisq.core.user.User; import javafx.scene.Scene; diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/duplicateoffer/DuplicateOfferViewModel.java b/desktop/src/main/java/bisq/desktop/main/portfolio/duplicateoffer/DuplicateOfferViewModel.java index bbbe5cf78a..544b60ae57 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/duplicateoffer/DuplicateOfferViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/duplicateoffer/DuplicateOfferViewModel.java @@ -19,14 +19,13 @@ package bisq.desktop.main.portfolio.duplicateoffer; import bisq.desktop.Navigation; import bisq.desktop.main.offer.MutableOfferViewModel; -import bisq.desktop.util.validation.BtcValidator; -import bisq.desktop.util.validation.FiatVolumeValidator; -import bisq.desktop.util.validation.SecurityDepositValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.offer.Offer; import bisq.core.offer.OfferPayload; import bisq.core.offer.OfferUtil; +import bisq.core.payment.validation.BtcValidator; +import bisq.core.payment.validation.FiatVolumeValidator; +import bisq.core.payment.validation.SecurityDepositValidator; import bisq.core.provider.price.PriceFeedService; import bisq.core.user.Preferences; import bisq.core.util.FormattingUtils; diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/editoffer/EditOfferViewModel.java b/desktop/src/main/java/bisq/desktop/main/portfolio/editoffer/EditOfferViewModel.java index 647ae59d51..d5e32aec78 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/editoffer/EditOfferViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/editoffer/EditOfferViewModel.java @@ -19,13 +19,12 @@ package bisq.desktop.main.portfolio.editoffer; import bisq.desktop.Navigation; import bisq.desktop.main.offer.MutableOfferViewModel; -import bisq.desktop.util.validation.BtcValidator; -import bisq.desktop.util.validation.FiatVolumeValidator; -import bisq.desktop.util.validation.SecurityDepositValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.offer.OfferUtil; import bisq.core.offer.OpenOffer; +import bisq.core.payment.validation.BtcValidator; +import bisq.core.payment.validation.FiatVolumeValidator; +import bisq.core.payment.validation.SecurityDepositValidator; import bisq.core.provider.price.PriceFeedService; import bisq.core.user.Preferences; import bisq.core.util.FormattingUtils; diff --git a/desktop/src/main/java/bisq/desktop/main/settings/preferences/PreferencesView.java b/desktop/src/main/java/bisq/desktop/main/settings/preferences/PreferencesView.java index 0b1251a46c..5a8a44fa46 100644 --- a/desktop/src/main/java/bisq/desktop/main/settings/preferences/PreferencesView.java +++ b/desktop/src/main/java/bisq/desktop/main/settings/preferences/PreferencesView.java @@ -30,8 +30,6 @@ import bisq.desktop.main.overlays.windows.EditCustomExplorerWindow; import bisq.desktop.util.GUIUtil; import bisq.desktop.util.ImageUtil; import bisq.desktop.util.Layout; -import bisq.desktop.util.validation.BtcValidator; - import bisq.core.btc.wallet.Restrictions; import bisq.core.filter.Filter; import bisq.core.filter.FilterManager; @@ -45,6 +43,7 @@ import bisq.core.locale.Res; import bisq.core.locale.TradeCurrency; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.PaymentMethod; +import bisq.core.payment.validation.BtcValidator; import bisq.core.provider.fee.FeeService; import bisq.core.user.Preferences; import bisq.core.user.User; diff --git a/desktop/src/test/java/bisq/desktop/main/offer/createoffer/CreateOfferViewModelTest.java b/desktop/src/test/java/bisq/desktop/main/offer/createoffer/CreateOfferViewModelTest.java index 6ca4dbdd90..28c23eab33 100644 --- a/desktop/src/test/java/bisq/desktop/main/offer/createoffer/CreateOfferViewModelTest.java +++ b/desktop/src/test/java/bisq/desktop/main/offer/createoffer/CreateOfferViewModelTest.java @@ -17,9 +17,6 @@ package bisq.desktop.main.offer.createoffer; -import bisq.desktop.util.validation.BtcValidator; -import bisq.desktop.util.validation.SecurityDepositValidator; - import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.btc.model.XmrAddressEntry; import bisq.core.btc.wallet.XmrWalletService; @@ -33,6 +30,8 @@ import bisq.core.offer.OfferPayload; import bisq.core.offer.OfferUtil; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.PaymentMethod; +import bisq.core.payment.validation.BtcValidator; +import bisq.core.payment.validation.SecurityDepositValidator; import bisq.core.provider.fee.FeeService; import bisq.core.provider.price.MarketPrice; import bisq.core.provider.price.PriceFeedService; diff --git a/desktop/src/test/java/bisq/desktop/util/validation/AccountNrValidatorTest.java b/desktop/src/test/java/bisq/desktop/util/validation/AccountNrValidatorTest.java index 1de80967cb..638393d431 100644 --- a/desktop/src/test/java/bisq/desktop/util/validation/AccountNrValidatorTest.java +++ b/desktop/src/test/java/bisq/desktop/util/validation/AccountNrValidatorTest.java @@ -1,7 +1,7 @@ package bisq.desktop.util.validation; import bisq.core.locale.Res; - +import bisq.core.payment.validation.AccountNrValidator; import java.util.Locale; import org.junit.Before; diff --git a/desktop/src/test/java/bisq/desktop/util/validation/AdvancedCashValidatorTest.java b/desktop/src/test/java/bisq/desktop/util/validation/AdvancedCashValidatorTest.java index 4d505bc23e..a373251073 100644 --- a/desktop/src/test/java/bisq/desktop/util/validation/AdvancedCashValidatorTest.java +++ b/desktop/src/test/java/bisq/desktop/util/validation/AdvancedCashValidatorTest.java @@ -2,6 +2,8 @@ package bisq.desktop.util.validation; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.Res; +import bisq.core.payment.validation.AdvancedCashValidator; +import bisq.core.payment.validation.EmailValidator; import bisq.core.util.validation.RegexValidator; import bisq.common.config.BaseCurrencyNetwork; diff --git a/desktop/src/test/java/bisq/desktop/util/validation/BranchIdValidatorTest.java b/desktop/src/test/java/bisq/desktop/util/validation/BranchIdValidatorTest.java index c1809814e7..3e0a4f36a0 100644 --- a/desktop/src/test/java/bisq/desktop/util/validation/BranchIdValidatorTest.java +++ b/desktop/src/test/java/bisq/desktop/util/validation/BranchIdValidatorTest.java @@ -1,7 +1,7 @@ package bisq.desktop.util.validation; import bisq.core.locale.Res; - +import bisq.core.payment.validation.BranchIdValidator; import java.util.Locale; import org.junit.Before; diff --git a/desktop/src/test/java/bisq/desktop/util/validation/BtcValidatorTest.java b/desktop/src/test/java/bisq/desktop/util/validation/BtcValidatorTest.java index c7617831b6..a768ff7269 100644 --- a/desktop/src/test/java/bisq/desktop/util/validation/BtcValidatorTest.java +++ b/desktop/src/test/java/bisq/desktop/util/validation/BtcValidatorTest.java @@ -22,6 +22,7 @@ import bisq.common.config.Config; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.Res; +import bisq.core.payment.validation.BtcValidator; import bisq.core.util.coin.CoinFormatter; import bisq.core.util.coin.ImmutableCoinFormatter; diff --git a/desktop/src/test/java/bisq/desktop/util/validation/CapitualValidatorTest.java b/desktop/src/test/java/bisq/desktop/util/validation/CapitualValidatorTest.java index 36260dfdff..1d5e814a83 100644 --- a/desktop/src/test/java/bisq/desktop/util/validation/CapitualValidatorTest.java +++ b/desktop/src/test/java/bisq/desktop/util/validation/CapitualValidatorTest.java @@ -2,6 +2,7 @@ package bisq.desktop.util.validation; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.Res; +import bisq.core.payment.validation.CapitualValidator; import bisq.core.util.validation.RegexValidator; import bisq.common.config.BaseCurrencyNetwork; diff --git a/desktop/src/test/java/bisq/desktop/util/validation/FiatVolumeValidatorTest.java b/desktop/src/test/java/bisq/desktop/util/validation/FiatVolumeValidatorTest.java index c7f53d5f72..13e468b5db 100644 --- a/desktop/src/test/java/bisq/desktop/util/validation/FiatVolumeValidatorTest.java +++ b/desktop/src/test/java/bisq/desktop/util/validation/FiatVolumeValidatorTest.java @@ -19,7 +19,7 @@ package bisq.desktop.util.validation; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.Res; - +import bisq.core.payment.validation.FiatVolumeValidator; import bisq.common.config.BaseCurrencyNetwork; import bisq.common.config.Config; diff --git a/desktop/src/test/java/bisq/desktop/util/validation/InteracETransferAnswerValidatorTest.java b/desktop/src/test/java/bisq/desktop/util/validation/InteracETransferAnswerValidatorTest.java index 2fe20b03ae..ba6022c5f4 100644 --- a/desktop/src/test/java/bisq/desktop/util/validation/InteracETransferAnswerValidatorTest.java +++ b/desktop/src/test/java/bisq/desktop/util/validation/InteracETransferAnswerValidatorTest.java @@ -19,6 +19,8 @@ package bisq.desktop.util.validation; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.Res; +import bisq.core.payment.validation.InteracETransferAnswerValidator; +import bisq.core.payment.validation.LengthValidator; import bisq.core.util.validation.RegexValidator; import bisq.common.config.BaseCurrencyNetwork; diff --git a/desktop/src/test/java/bisq/desktop/util/validation/InteracETransferQuestionValidatorTest.java b/desktop/src/test/java/bisq/desktop/util/validation/InteracETransferQuestionValidatorTest.java index cc39b08202..3ebe865f9d 100644 --- a/desktop/src/test/java/bisq/desktop/util/validation/InteracETransferQuestionValidatorTest.java +++ b/desktop/src/test/java/bisq/desktop/util/validation/InteracETransferQuestionValidatorTest.java @@ -19,6 +19,8 @@ package bisq.desktop.util.validation; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.Res; +import bisq.core.payment.validation.InteracETransferQuestionValidator; +import bisq.core.payment.validation.LengthValidator; import bisq.core.util.validation.RegexValidator; import bisq.common.config.BaseCurrencyNetwork; diff --git a/desktop/src/test/java/bisq/desktop/util/validation/InteracETransferValidatorTest.java b/desktop/src/test/java/bisq/desktop/util/validation/InteracETransferValidatorTest.java index ebcd610e40..94f8a04106 100644 --- a/desktop/src/test/java/bisq/desktop/util/validation/InteracETransferValidatorTest.java +++ b/desktop/src/test/java/bisq/desktop/util/validation/InteracETransferValidatorTest.java @@ -19,6 +19,11 @@ package bisq.desktop.util.validation; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.Res; +import bisq.core.payment.validation.EmailValidator; +import bisq.core.payment.validation.InteracETransferAnswerValidator; +import bisq.core.payment.validation.InteracETransferQuestionValidator; +import bisq.core.payment.validation.InteracETransferValidator; +import bisq.core.payment.validation.LengthValidator; import bisq.core.util.validation.RegexValidator; import bisq.common.config.BaseCurrencyNetwork; diff --git a/desktop/src/test/java/bisq/desktop/util/validation/LengthValidatorTest.java b/desktop/src/test/java/bisq/desktop/util/validation/LengthValidatorTest.java index 0ae7096c8f..a4d7464335 100644 --- a/desktop/src/test/java/bisq/desktop/util/validation/LengthValidatorTest.java +++ b/desktop/src/test/java/bisq/desktop/util/validation/LengthValidatorTest.java @@ -19,7 +19,7 @@ package bisq.desktop.util.validation; import bisq.core.locale.CurrencyUtil; import bisq.core.locale.Res; - +import bisq.core.payment.validation.LengthValidator; import bisq.common.config.BaseCurrencyNetwork; import bisq.common.config.Config; diff --git a/desktop/src/test/java/bisq/desktop/util/validation/NationalAccountIdValidatorTest.java b/desktop/src/test/java/bisq/desktop/util/validation/NationalAccountIdValidatorTest.java index 2873b85ce6..111c11bfc2 100644 --- a/desktop/src/test/java/bisq/desktop/util/validation/NationalAccountIdValidatorTest.java +++ b/desktop/src/test/java/bisq/desktop/util/validation/NationalAccountIdValidatorTest.java @@ -1,7 +1,7 @@ package bisq.desktop.util.validation; import bisq.core.locale.Res; - +import bisq.core.payment.validation.NationalAccountIdValidator; import java.util.Locale; import org.junit.Before; diff --git a/desktop/src/test/java/bisq/desktop/util/validation/PhoneNumberValidatorTest.java b/desktop/src/test/java/bisq/desktop/util/validation/PhoneNumberValidatorTest.java index 797665bd49..5672830d2f 100644 --- a/desktop/src/test/java/bisq/desktop/util/validation/PhoneNumberValidatorTest.java +++ b/desktop/src/test/java/bisq/desktop/util/validation/PhoneNumberValidatorTest.java @@ -1,6 +1,7 @@ package bisq.desktop.util.validation; import bisq.core.locale.Res; +import bisq.core.payment.validation.PhoneNumberValidator; import bisq.core.util.validation.InputValidator.ValidationResult; import org.junit.Before; diff --git a/proto/src/main/proto/grpc.proto b/proto/src/main/proto/grpc.proto index dff649ab7c..411e9159d3 100644 --- a/proto/src/main/proto/grpc.proto +++ b/proto/src/main/proto/grpc.proto @@ -550,14 +550,19 @@ service PaymentAccounts { } rpc GetPaymentAccountForm (GetPaymentAccountFormRequest) returns (GetPaymentAccountFormReply) { } + rpc GetPaymentAccountFormAsJson (GetPaymentAccountFormAsJsonRequest) returns (GetPaymentAccountFormAsJsonReply) { + } rpc CreateCryptoCurrencyPaymentAccount (CreateCryptoCurrencyPaymentAccountRequest) returns (CreateCryptoCurrencyPaymentAccountReply) { } rpc GetCryptoCurrencyPaymentMethods (GetCryptoCurrencyPaymentMethodsRequest) returns (GetCryptoCurrencyPaymentMethodsReply) { } + rpc ValidateFormField (ValidateFormFieldRequest) returns (ValidateFormFieldReply) { + } } message CreatePaymentAccountRequest { - string payment_account_form = 1; + PaymentAccountForm payment_account_form = 1; + string payment_account_form_as_json = 2; } message CreatePaymentAccountReply { @@ -583,7 +588,15 @@ message GetPaymentAccountFormRequest { } message GetPaymentAccountFormReply { - string payment_account_form_json = 1; + PaymentAccountForm payment_account_form = 1; +} + +message GetPaymentAccountFormAsJsonRequest { + string payment_method_id = 1; +} + +message GetPaymentAccountFormAsJsonReply { + string payment_account_form_as_json = 1; } message CreateCryptoCurrencyPaymentAccountRequest { @@ -604,6 +617,15 @@ message GetCryptoCurrencyPaymentMethodsReply { repeated PaymentMethod payment_methods = 1; } +message ValidateFormFieldRequest { + PaymentAccountForm form = 1; + PaymentAccountFormField.FieldId field_id = 2; + string value = 3; +} + +message ValidateFormFieldReply { +} + /////////////////////////////////////////////////////////////////////////////////////////// // Price /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/proto/src/main/proto/pb.proto b/proto/src/main/proto/pb.proto index e5c6873e09..db07f1760c 100644 --- a/proto/src/main/proto/pb.proto +++ b/proto/src/main/proto/pb.proto @@ -1093,14 +1093,15 @@ message ClearXchangeAccountPayload { } message CountryBasedPaymentAccountPayload { - string countryCode = 1; + string country_code = 1; + repeated string accepted_country_codes = 2; oneof message { - BankAccountPayload bank_account_payload = 2; - CashDepositAccountPayload cash_deposit_account_payload = 3; - SepaAccountPayload sepa_account_payload = 4; - WesternUnionAccountPayload western_union_account_payload = 5; - SepaInstantAccountPayload sepa_instant_account_payload = 6; - F2FAccountPayload f2f_account_payload = 7; + BankAccountPayload bank_account_payload = 3; + CashDepositAccountPayload cash_deposit_account_payload = 4; + SepaAccountPayload sepa_account_payload = 5; + WesternUnionAccountPayload western_union_account_payload = 6; + SepaInstantAccountPayload sepa_instant_account_payload = 7; + F2FAccountPayload f2f_account_payload = 8; UpiAccountPayload upi_account_payload = 9; PaytmAccountPayload paytm_account_payload = 10; IfscBasedAccountPayload ifsc_based_account_payload = 11; @@ -1111,6 +1112,7 @@ message CountryBasedPaymentAccountPayload { StrikeAccountPayload strike_account_payload = 16; TikkieAccountPayload tikkie_account_payload = 17; TransferwiseUsdAccountPayload transferwise_usd_account_payload = 18; + SwiftAccountPayload swift_account_payload = 19; } } @@ -1207,14 +1209,12 @@ message SepaAccountPayload { string iban = 2; string bic = 3; string email = 4 [deprecated = true]; - repeated string accepted_country_codes = 5; } message SepaInstantAccountPayload { string holder_name = 1; string iban = 2; string bic = 3; - repeated string accepted_country_codes = 4; } message CryptoCurrencyAccountPayload { @@ -2071,3 +2071,96 @@ message MockPayload { string message_version = 1; string message = 2; } + +message PaymentAccountForm { + enum FormId { + REVOLUT = 0; + SEPA = 1; + TRANSFERWISE = 2; + CLEAR_X_CHANGE = 3; + SWIFT = 4; + F2F = 5; + STRIKE = 6; + } + FormId id = 1; + repeated PaymentAccountFormField fields = 2; +} + +message PaymentAccountFormField { + enum FieldId { + ACCEPTED_COUNTRY_CODES = 0; + ACCOUNT_ID = 1; + ACCOUNT_NAME = 2; + ACCOUNT_NR = 3; + ACCOUNT_OWNER = 4; + ACCOUNT_TYPE = 5; + ANSWER = 6; + BANK_ACCOUNT_NAME = 7; + BANK_ACCOUNT_NUMBER = 8; + BANK_ACCOUNT_TYPE = 9; + BANK_ADDRESS = 10; + BANK_BRANCH = 11; + BANK_BRANCH_CODE = 12; + BANK_BRANCH_NAME = 13; + BANK_CODE = 14; + BANK_COUNTRY_CODE = 15; + BANK_ID = 16; + BANK_NAME = 17; + BANK_SWIFT_CODE = 18; + BENEFICIARY_ACCOUNT_NR = 19; + BENEFICIARY_ADDRESS = 20; + BENEFICIARY_CITY = 21; + BENEFICIARY_NAME = 22; + BENEFICIARY_PHONE = 23; + BIC = 24; + BRANCH_ID = 25; + CITY = 26; + CONTACT = 27; + COUNTRY = 28; + EMAIL = 29; + EMAIL_OR_MOBILE_NR = 30; + EXTRA_INFO = 31; + HOLDER_ADDRESS = 32; + HOLDER_EMAIL = 33; + HOLDER_NAME = 34; + HOLDER_TAX_ID = 35; + IBAN = 36; + IFSC = 37; + INTERMEDIARY_ADDRESS = 38; + INTERMEDIARY_BRANCH = 39; + INTERMEDIARY_COUNTRY_CODE = 40; + INTERMEDIARY_NAME = 41; + INTERMEDIARY_SWIFT_CODE = 42; + MOBILE_NR = 43; + NATIONAL_ACCOUNT_ID = 44; + PAYID = 45; + PIX_KEY = 46; + POSTAL_ADDRESS = 47; + PROMPT_PAY_ID = 48; + QUESTION = 49; + REQUIREMENTS = 50; + SALT = 51; + SORT_CODE = 52; + SPECIAL_INSTRUCTIONS = 53; + STATE = 54; + TRADE_CURRENCIES = 55; + USER_NAME = 56; + VIRTUAL_PAYMENT_ADDRESS = 57; + } + enum Component { + TEXT = 0; + SELECT_ONE = 1; + SELECT_MULTIPLE = 2; + } + FieldId id = 1; + Component component = 2; + string type = 3; + string label = 4; + string value = 5; + uint32 minLength = 6; + uint32 maxLength = 7; + repeated TradeCurrency supported_currencies = 8; + repeated Country supported_countries = 9; + repeated Country supported_sepa_euro_countries = 10; + repeated Country supported_sepa_non_euro_countries = 11; +} \ No newline at end of file