From 4017fa108acc28329fd0f802cdd3a33a741473ce Mon Sep 17 00:00:00 2001 From: woodser Date: Sat, 9 Sep 2023 07:29:36 -0400 Subject: [PATCH] support cash at atm over grpc --- .../core/api/model/PaymentAccountForm.java | 1 + .../haveno/core/payment/CashAtAtmAccount.java | 14 +++++++++++++- .../core/payment/payload/PaymentMethod.java | 17 +++++++++-------- proto/src/main/proto/pb.proto | 1 + 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/haveno/core/api/model/PaymentAccountForm.java b/core/src/main/java/haveno/core/api/model/PaymentAccountForm.java index d2e27d780f..5716225b8e 100644 --- a/core/src/main/java/haveno/core/api/model/PaymentAccountForm.java +++ b/core/src/main/java/haveno/core/api/model/PaymentAccountForm.java @@ -60,6 +60,7 @@ public final class PaymentAccountForm implements PersistablePayload { public enum FormId { BLOCK_CHAINS, + CASH_AT_ATM, FASTER_PAYMENTS, F2F, MONEY_GRAM, diff --git a/core/src/main/java/haveno/core/payment/CashAtAtmAccount.java b/core/src/main/java/haveno/core/payment/CashAtAtmAccount.java index 4d1e3d4c6f..60d64205b2 100644 --- a/core/src/main/java/haveno/core/payment/CashAtAtmAccount.java +++ b/core/src/main/java/haveno/core/payment/CashAtAtmAccount.java @@ -19,6 +19,7 @@ package haveno.core.payment; import haveno.core.api.model.PaymentAccountFormField; import haveno.core.locale.CurrencyUtil; +import haveno.core.locale.Res; import haveno.core.locale.TradeCurrency; import haveno.core.payment.payload.CashAtAtmAccountPayload; import haveno.core.payment.payload.PaymentAccountPayload; @@ -32,7 +33,10 @@ public final class CashAtAtmAccount extends PaymentAccount { public static final List SUPPORTED_CURRENCIES = CurrencyUtil.getAllFiatCurrencies(); private static final List INPUT_FIELD_IDS = List.of( - PaymentAccountFormField.FieldId.EXTRA_INFO + PaymentAccountFormField.FieldId.TRADE_CURRENCIES, + PaymentAccountFormField.FieldId.EXTRA_INFO, + PaymentAccountFormField.FieldId.ACCOUNT_NAME, + PaymentAccountFormField.FieldId.SALT ); public CashAtAtmAccount() { @@ -61,4 +65,12 @@ public final class CashAtAtmAccount extends PaymentAccount { public String getExtraInfo() { return ((CashAtAtmAccountPayload) paymentAccountPayload).getExtraInfo(); } + + @Override + protected PaymentAccountFormField getEmptyFormField(PaymentAccountFormField.FieldId fieldId) { + var field = super.getEmptyFormField(fieldId); + if (field.getId() == PaymentAccountFormField.FieldId.TRADE_CURRENCIES) field.setComponent(PaymentAccountFormField.Component.SELECT_ONE); + if (field.getId() == PaymentAccountFormField.FieldId.EXTRA_INFO) field.setLabel(Res.get("payment.cashAtAtm.extraInfo.prompt")); + return field; + } } diff --git a/core/src/main/java/haveno/core/payment/payload/PaymentMethod.java b/core/src/main/java/haveno/core/payment/payload/PaymentMethod.java index 55dff62fdc..532142059f 100644 --- a/core/src/main/java/haveno/core/payment/payload/PaymentMethod.java +++ b/core/src/main/java/haveno/core/payment/payload/PaymentMethod.java @@ -334,19 +334,20 @@ public final class PaymentMethod implements PersistablePayload, Comparable getPaymentMethods() { List paymentMethodIds = List.of( BLOCK_CHAINS_ID, + CASH_AT_ATM_ID, + FASTER_PAYMENTS_ID, + F2F_ID, + MONEY_GRAM_ID, + PAXUM_ID, + PAY_BY_MAIL_ID, REVOLUT_ID, SEPA_ID, SEPA_INSTANT_ID, - TRANSFERWISE_ID, - ZELLE_ID, - SWIFT_ID, - F2F_ID, STRIKE_ID, - MONEY_GRAM_ID, - FASTER_PAYMENTS_ID, + SWIFT_ID, + TRANSFERWISE_ID, UPHOLD_ID, - PAXUM_ID, - PAY_BY_MAIL_ID); + ZELLE_ID); return paymentMethods.stream().filter(paymentMethod -> paymentMethodIds.contains(paymentMethod.getId())).collect(Collectors.toList()); } diff --git a/proto/src/main/proto/pb.proto b/proto/src/main/proto/pb.proto index b50aba8e3e..e30e55abc3 100644 --- a/proto/src/main/proto/pb.proto +++ b/proto/src/main/proto/pb.proto @@ -1839,6 +1839,7 @@ message PaymentAccountForm { UPHOLD = 11; PAXUM = 12; PAY_BY_MAIL = 13; + CASH_AT_ATM = 14; } FormId id = 1; repeated PaymentAccountFormField fields = 2;