diff --git a/core/src/main/java/bisq/core/locale/CurrencyUtil.java b/core/src/main/java/bisq/core/locale/CurrencyUtil.java index 6c012b0bdfc..85dddaf38cc 100644 --- a/core/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/core/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -445,6 +445,17 @@ public static List getAllMoneseCurrencies() { )); } + // https://github.com/bisq-network/growth/issues/223 + public static List getAllVerseCurrencies() { + return new ArrayList<>(Arrays.asList( + new FiatCurrency("DKK"), + new FiatCurrency("EUR"), + new FiatCurrency("HUF"), + new FiatCurrency("PLN"), + new FiatCurrency("SEK") + )); + } + // https://www.revolut.com/help/getting-started/exchanging-currencies/what-fiat-currencies-are-supported-for-holding-and-exchange public static List getAllRevolutCurrencies() { ArrayList currencies = new ArrayList<>(Arrays.asList( diff --git a/core/src/main/java/bisq/core/payment/PaymentAccountFactory.java b/core/src/main/java/bisq/core/payment/PaymentAccountFactory.java index b7fd572a984..d1764980547 100644 --- a/core/src/main/java/bisq/core/payment/PaymentAccountFactory.java +++ b/core/src/main/java/bisq/core/payment/PaymentAccountFactory.java @@ -114,6 +114,10 @@ public static PaymentAccount getPaymentAccount(PaymentMethod paymentMethod) { return new MoneseAccount(); case PaymentMethod.SATISPAY_ID: return new SatispayAccount(); + case PaymentMethod.VERSE_ID: + return new VerseAccount(); + case PaymentMethod.STRIKE_ID: + return new StrikeAccount(); case PaymentMethod.SWIFT_ID: return new SwiftAccount(); diff --git a/core/src/main/java/bisq/core/payment/StrikeAccount.java b/core/src/main/java/bisq/core/payment/StrikeAccount.java new file mode 100644 index 00000000000..deb37b0ca60 --- /dev/null +++ b/core/src/main/java/bisq/core/payment/StrikeAccount.java @@ -0,0 +1,56 @@ +/* + * This file is part of Bisq. + * + * Bisq 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. + * + * Bisq 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 Bisq. If not, see . + */ + +package bisq.core.payment; + +import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.payload.PaymentMethod; +import bisq.core.payment.payload.StrikeAccountPayload; + +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +public final class StrikeAccount extends CountryBasedPaymentAccount { + public StrikeAccount() { + super(PaymentMethod.STRIKE); + } + + @Override + protected PaymentAccountPayload createPayload() { + return new StrikeAccountPayload(paymentMethod.getId(), id); + } + + public void setHolderName(String accountId) { + ((StrikeAccountPayload) paymentAccountPayload).setHolderName(accountId); + } + + public String getHolderName() { + return ((StrikeAccountPayload) paymentAccountPayload).getHolderName(); + } + + public String getMessageForBuyer() { + return "payment.strike.info.buyer"; + } + + public String getMessageForSeller() { + return "payment.strike.info.seller"; + } + + public String getMessageForAccountCreation() { + return "payment.strike.info.account"; + } +} diff --git a/core/src/main/java/bisq/core/payment/VerseAccount.java b/core/src/main/java/bisq/core/payment/VerseAccount.java new file mode 100644 index 00000000000..a0a211704ce --- /dev/null +++ b/core/src/main/java/bisq/core/payment/VerseAccount.java @@ -0,0 +1,56 @@ +/* + * This file is part of Bisq. + * + * Bisq 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. + * + * Bisq 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 Bisq. If not, see . + */ + +package bisq.core.payment; + +import bisq.core.payment.payload.VerseAccountPayload; +import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.payload.PaymentMethod; + +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +public final class VerseAccount extends PaymentAccount { + public VerseAccount() { + super(PaymentMethod.VERSE); + } + + @Override + protected PaymentAccountPayload createPayload() { + return new VerseAccountPayload(paymentMethod.getId(), id); + } + + public void setHolderName(String accountId) { + ((VerseAccountPayload) paymentAccountPayload).setHolderName(accountId); + } + + public String getHolderName() { + return ((VerseAccountPayload) paymentAccountPayload).getHolderName(); + } + + public String getMessageForBuyer() { + return "payment.verse.info.buyer"; + } + + public String getMessageForSeller() { + return "payment.verse.info.seller"; + } + + public String getMessageForAccountCreation() { + return "payment.verse.info.account"; + } +} 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 0ec8747724c..e6da6be373f 100644 --- a/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java +++ b/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java @@ -113,6 +113,8 @@ public final class PaymentMethod implements PersistablePayload, Comparable. + */ + +package bisq.core.payment.payload; + +import bisq.core.locale.Res; + +import com.google.protobuf.Message; + +import java.nio.charset.StandardCharsets; + +import java.util.HashMap; +import java.util.Map; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import lombok.extern.slf4j.Slf4j; + +@EqualsAndHashCode(callSuper = true) +@ToString +@Setter +@Getter +@Slf4j +public final class StrikeAccountPayload extends CountryBasedPaymentAccountPayload { + private String holderName = ""; + + public StrikeAccountPayload(String paymentMethod, String id) { + super(paymentMethod, id); + } + + private StrikeAccountPayload(String paymentMethod, + String id, + String countryCode, + String holderName, + long maxTradePeriod, + Map excludeFromJsonDataMap) { + super(paymentMethod, + id, + countryCode, + maxTradePeriod, + excludeFromJsonDataMap); + + this.holderName = holderName; + } + + @Override + public Message toProtoMessage() { + protobuf.StrikeAccountPayload.Builder builder = protobuf.StrikeAccountPayload.newBuilder() + .setHolderName(holderName); + final protobuf.CountryBasedPaymentAccountPayload.Builder countryBasedPaymentAccountPayload = getPaymentAccountPayloadBuilder() + .getCountryBasedPaymentAccountPayloadBuilder() + .setStrikeAccountPayload(builder); + return getPaymentAccountPayloadBuilder() + .setCountryBasedPaymentAccountPayload(countryBasedPaymentAccountPayload) + .build(); + } + + public static StrikeAccountPayload fromProto(protobuf.PaymentAccountPayload proto) { + protobuf.CountryBasedPaymentAccountPayload countryBasedPaymentAccountPayload = proto.getCountryBasedPaymentAccountPayload(); + protobuf.StrikeAccountPayload accountPayloadPB = countryBasedPaymentAccountPayload.getStrikeAccountPayload(); + return new StrikeAccountPayload(proto.getPaymentMethodId(), + proto.getId(), + countryBasedPaymentAccountPayload.getCountryCode(), + accountPayloadPB.getHolderName(), + proto.getMaxTradePeriod(), + new HashMap<>(proto.getExcludeFromJsonDataMap())); + } + + @Override + public String getPaymentDetails() { + return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.account.userName") + " " + holderName; + } + + @Override + public String getPaymentDetailsForTradePopup() { + return getPaymentDetails(); + } + + @Override + public byte[] getAgeWitnessInputData() { + return super.getAgeWitnessInputData(holderName.getBytes(StandardCharsets.UTF_8)); + } +} diff --git a/core/src/main/java/bisq/core/payment/payload/VerseAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/VerseAccountPayload.java new file mode 100644 index 00000000000..7cb3d53d694 --- /dev/null +++ b/core/src/main/java/bisq/core/payment/payload/VerseAccountPayload.java @@ -0,0 +1,89 @@ +/* + * This file is part of Bisq. + * + * Bisq 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. + * + * Bisq 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 Bisq. If not, see . + */ + +package bisq.core.payment.payload; + +import bisq.core.locale.Res; + +import com.google.protobuf.Message; + +import java.nio.charset.StandardCharsets; + +import java.util.HashMap; +import java.util.Map; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import lombok.extern.slf4j.Slf4j; + +@EqualsAndHashCode(callSuper = true) +@ToString +@Setter +@Getter +@Slf4j +public final class VerseAccountPayload extends PaymentAccountPayload { + private String holderName = ""; + + public VerseAccountPayload(String paymentMethod, String id) { + super(paymentMethod, id); + } + + private VerseAccountPayload(String paymentMethod, + String id, + String holderName, + long maxTradePeriod, + Map excludeFromJsonDataMap) { + super(paymentMethod, + id, + maxTradePeriod, + excludeFromJsonDataMap); + + this.holderName = holderName; + } + + @Override + public Message toProtoMessage() { + return getPaymentAccountPayloadBuilder() + .setVerseAccountPayload(protobuf.VerseAccountPayload.newBuilder().setHolderName(holderName)) + .build(); + } + + public static VerseAccountPayload fromProto(protobuf.PaymentAccountPayload proto) { + return new VerseAccountPayload(proto.getPaymentMethodId(), + proto.getId(), + proto.getVerseAccountPayload().getHolderName(), + proto.getMaxTradePeriod(), + new HashMap<>(proto.getExcludeFromJsonDataMap())); + } + + @Override + public String getPaymentDetails() { + return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.account.userName") + " " + holderName; + } + + @Override + public String getPaymentDetailsForTradePopup() { + return getPaymentDetails(); + } + + @Override + public byte[] getAgeWitnessInputData() { + return super.getAgeWitnessInputData(holderName.getBytes(StandardCharsets.UTF_8)); + } +} diff --git a/core/src/main/java/bisq/core/proto/CoreProtoResolver.java b/core/src/main/java/bisq/core/proto/CoreProtoResolver.java index 98857ad4d91..f76d38fdecc 100644 --- a/core/src/main/java/bisq/core/proto/CoreProtoResolver.java +++ b/core/src/main/java/bisq/core/proto/CoreProtoResolver.java @@ -63,6 +63,7 @@ import bisq.core.payment.payload.SepaAccountPayload; import bisq.core.payment.payload.SepaInstantAccountPayload; import bisq.core.payment.payload.SpecificBanksAccountPayload; +import bisq.core.payment.payload.StrikeAccountPayload; import bisq.core.payment.payload.SwiftAccountPayload; import bisq.core.payment.payload.SwishAccountPayload; import bisq.core.payment.payload.TransferwiseAccountPayload; @@ -70,6 +71,7 @@ import bisq.core.payment.payload.UpholdAccountPayload; import bisq.core.payment.payload.UpiAccountPayload; import bisq.core.payment.payload.VenmoAccountPayload; +import bisq.core.payment.payload.VerseAccountPayload; import bisq.core.payment.payload.WeChatPayAccountPayload; import bisq.core.payment.payload.WesternUnionAccountPayload; import bisq.core.trade.statistics.TradeStatistics2; @@ -141,6 +143,8 @@ public PaymentAccountPayload fromProto(protobuf.PaymentAccountPayload proto) { return PixAccountPayload.fromProto(proto); case SATISPAY_ACCOUNT_PAYLOAD: return SatispayAccountPayload.fromProto(proto); + case STRIKE_ACCOUNT_PAYLOAD: + return StrikeAccountPayload.fromProto(proto); case IFSC_BASED_ACCOUNT_PAYLOAD: final protobuf.IfscBasedAccountPayload.MessageCase messageCaseIfsc = proto.getCountryBasedPaymentAccountPayload().getIfscBasedAccountPayload().getMessageCase(); switch (messageCaseIfsc) { @@ -210,6 +214,8 @@ public PaymentAccountPayload fromProto(protobuf.PaymentAccountPayload proto) { return CelPayAccountPayload.fromProto(proto); case MONESE_ACCOUNT_PAYLOAD: return MoneseAccountPayload.fromProto(proto); + case VERSE_ACCOUNT_PAYLOAD: + return VerseAccountPayload.fromProto(proto); case SWIFT_ACCOUNT_PAYLOAD: return SwiftAccountPayload.fromProto(proto); diff --git a/core/src/main/java/bisq/core/trade/statistics/TradeStatistics3.java b/core/src/main/java/bisq/core/trade/statistics/TradeStatistics3.java index aab3b0c2b97..fee029654b6 100644 --- a/core/src/main/java/bisq/core/trade/statistics/TradeStatistics3.java +++ b/core/src/main/java/bisq/core/trade/statistics/TradeStatistics3.java @@ -167,7 +167,9 @@ private enum PaymentMethodMapper { BIZUM, PIX, MONESE, - SATISPAY + SATISPAY, + VERSE, + STRIKE } @Getter diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 4b61e5d835a..0202d306380 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -3628,6 +3628,39 @@ Satispay account limits are individually set. If you want to trade increased amo support to increase your limits. Traders on Bisq should be aware of their limits. If you trade over the above limits \ your trade might be cancelled and there could be a penalty. +payment.verse.info.account=Verse is a multiple currency payment method that can send and receive payment in EUR, SEK, HUF, DKK, PLN.\n\n\ +When setting up your Verse account in Bisq please make sure to include the username that matches your username in your \ + Verse account. This will ensure that when you send funds they show from the correct account and when you receive \ + funds they will be credited to your account.\n\n\ +Verse users are limited to sending or receiving €10,000 per year (or equivalent foreign currency amount) for \ + accumulated payments made from or received into their payment account. This can be increased by Verse on request. +payment.verse.info.buyer=Please send payment only to the username provided by the BTC Seller in their Bisq account. \ + Please leave the payment description blank.\n\n\ +Verse users are limited to sending or receiving €10,000 per year (or equivalent foreign currency amount) for \ + accumulated payments made from or received into their payment account. This can be increased by Verse on request. +payment.verse.info.seller=BTC Sellers should expect to receive payment from the username shown in the BTC Buyer's Bisq account.\n\n\ +Verse users are limited to sending or receiving €10,000 per year (or equivalent foreign currency amount) for \ + accumulated payments made from or received into their payment account. This can be increased by Verse on request. + +payment.strike.info.account=Please make sure to include your Strike username.\n\n\ +In Bisq, Strike is used for fiat to fiat payments only.\n\n\ +Please make sure you are aware of the Strike limits:\n\n\ +Users who have registered with only their email, name, and phone number have the following limits:\n\n\ + ● $100 maximum per deposit\n\ + ● $1,000 maximum total deposits per week\n\ + ● $100 maximum per payment\n\n\ +Users can increase their limits by providing Strike more information have the following limits:\n\n\ + ● $1,000 maximum per deposit\n\ + ● $1,000 maximum total deposits per week\n\ + ● $1,000 maximum per payment\n\n\ +If you trade over the above limits your trade might be cancelled and there could be a penalty. +payment.strike.info.buyer=Please send payment only to the BTC Seller's Strike username as provided in Bisq.\n\n\ +The maximum trade size is $1,000 maximum per payment.\n\n\ +If you trade over the above limits your trade might be cancelled and there could be a penalty. +payment.strike.info.seller=Please make sure your payment is received from the BTC Buyer's Strike username as provided in Bisq.\n\n\ +The maximum trade size is $1,000 maximum per payment.\n\n\ +If you trade over the above limits your trade might be cancelled and there could be a penalty. + payment.usPostalMoneyOrder.info=Trading using US Postal Money Orders (USPMO) on Bisq requires that you understand the following:\n\ \n\ - BTC buyers must write the BTC Seller’s name in both the Payer and the Payee’s fields & take a high-resolution photo of the USPMO and envelope with proof of tracking before sending.\n\ @@ -3822,6 +3855,10 @@ MONESE=Monese # suppress inspection "UnusedProperty" SATISPAY=Satispay # suppress inspection "UnusedProperty" +VERSE=Verse +# suppress inspection "UnusedProperty" +STRIKE=Strike +# suppress inspection "UnusedProperty" SWIFT=SWIFT International Wire Transfer # Deprecated: Cannot be deleted as it would break old trade history entries @@ -3904,6 +3941,10 @@ MONESE_SHORT=Monese # suppress inspection "UnusedProperty" SATISPAY_SHORT=Satispay # suppress inspection "UnusedProperty" +VERSE_SHORT=Verse +# suppress inspection "UnusedProperty" +STRIKE_SHORT=Strike +# suppress inspection "UnusedProperty" SWIFT_SHORT=SWIFT # Deprecated: Cannot be deleted as it would break old trade history entries diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/StrikeForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/StrikeForm.java new file mode 100644 index 00000000000..486147e293e --- /dev/null +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/StrikeForm.java @@ -0,0 +1,106 @@ +/* + * This file is part of Bisq. + * + * Bisq 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. + * + * Bisq 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 Bisq. If not, see . + */ + +package bisq.desktop.components.paymentmethods; + +import bisq.desktop.components.InputTextField; +import bisq.desktop.util.FormBuilder; +import bisq.desktop.util.Layout; + +import bisq.core.account.witness.AccountAgeWitnessService; +import bisq.core.locale.CountryUtil; +import bisq.core.locale.FiatCurrency; +import bisq.core.locale.Res; +import bisq.core.payment.PaymentAccount; +import bisq.core.payment.StrikeAccount; +import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.payload.StrikeAccountPayload; +import bisq.core.util.coin.CoinFormatter; +import bisq.core.util.validation.InputValidator; + +import javafx.scene.control.TextField; +import javafx.scene.layout.GridPane; + +import static bisq.desktop.util.FormBuilder.addCompactTopLabelTextField; +import static bisq.desktop.util.FormBuilder.addTopLabelTextField; +import static bisq.desktop.util.FormBuilder.addTopLabelTextFieldWithCopyIcon; + +public class StrikeForm extends PaymentMethodForm { + private final StrikeAccount account; + private InputTextField holderNameField; + + public static int addFormForBuyer(GridPane gridPane, int gridRow, + PaymentAccountPayload paymentAccountPayload) { + addTopLabelTextFieldWithCopyIcon(gridPane, gridRow, 1, Res.get("payment.account.userName"), + ((StrikeAccountPayload) paymentAccountPayload).getHolderName(), Layout.COMPACT_FIRST_ROW_AND_GROUP_DISTANCE); + return gridRow; + } + + public StrikeForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, + InputValidator inputValidator, GridPane gridPane, + int gridRow, CoinFormatter formatter) { + super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter); + this.account = (StrikeAccount) paymentAccount; + } + + @Override + public void addFormForAddAccount() { + // this payment method is currently restricted to United States/USD + account.setSingleTradeCurrency(new FiatCurrency("USD")); + CountryUtil.findCountryByCode("US").ifPresent(c -> account.setCountry(c)); + + gridRowFrom = gridRow + 1; + + holderNameField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.account.userName")); + holderNameField.setValidator(inputValidator); + holderNameField.textProperty().addListener((ov, oldValue, newValue) -> { + account.setHolderName(newValue.trim()); + updateFromInputs(); + }); + + addTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), account.getSingleTradeCurrency().getNameAndCode()); + addTopLabelTextField(gridPane, ++gridRow, Res.get("shared.country"), account.getCountry().name); + addLimitations(false); + addAccountNameTextFieldWithAutoFillToggleButton(); + } + + @Override + protected void autoFillNameTextField() { + setAccountNameWithString(holderNameField.getText()); + } + + @Override + public void addFormForDisplayAccount() { + gridRowFrom = gridRow; + addTopLabelTextField(gridPane, gridRow, Res.get("payment.account.name"), + account.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE); + addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"), + Res.get(account.getPaymentMethod().getId())); + TextField field = addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.userName"), + account.getHolderName()).second; + field.setMouseTransparent(false); + addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), account.getSingleTradeCurrency().getNameAndCode()); + addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.country"), account.getCountry().name); + addLimitations(true); + } + + @Override + public void updateAllInputsValid() { + allInputsValid.set(isAccountNameValid() + && inputValidator.validate(account.getHolderName()).isValid); + } +} diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/VerseForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/VerseForm.java new file mode 100644 index 00000000000..f497d17e76f --- /dev/null +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/VerseForm.java @@ -0,0 +1,116 @@ +/* + * This file is part of Bisq. + * + * Bisq 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. + * + * Bisq 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 Bisq. If not, see . + */ + +package bisq.desktop.components.paymentmethods; + +import bisq.desktop.components.InputTextField; +import bisq.desktop.util.FormBuilder; +import bisq.desktop.util.Layout; + +import bisq.core.account.witness.AccountAgeWitnessService; +import bisq.core.locale.CurrencyUtil; +import bisq.core.locale.Res; +import bisq.core.payment.PaymentAccount; +import bisq.core.payment.VerseAccount; +import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.payload.VerseAccountPayload; +import bisq.core.util.coin.CoinFormatter; +import bisq.core.util.validation.InputValidator; + +import javafx.scene.control.TextField; +import javafx.scene.layout.FlowPane; +import javafx.scene.layout.GridPane; + +import static bisq.desktop.util.FormBuilder.addCompactTopLabelTextField; +import static bisq.desktop.util.FormBuilder.addCompactTopLabelTextFieldWithCopyIcon; +import static bisq.desktop.util.FormBuilder.addTopLabelTextField; + +public class VerseForm extends PaymentMethodForm { + private final VerseAccount account; + private InputTextField holderNameInputTextField; + + public static int addFormForBuyer(GridPane gridPane, int gridRow, + PaymentAccountPayload paymentAccountPayload) { + addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.account.userName"), + ((VerseAccountPayload) paymentAccountPayload).getHolderName()); + return gridRow; + } + + public VerseForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, + InputValidator inputValidator, GridPane gridPane, + int gridRow, CoinFormatter formatter) { + super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter); + this.account = (VerseAccount) paymentAccount; + } + + @Override + public void addFormForAddAccount() { + gridRowFrom = gridRow + 1; + + holderNameInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.account.userName")); + holderNameInputTextField.setValidator(inputValidator); + holderNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { + account.setHolderName(newValue.trim()); + updateFromInputs(); + }); + + addCurrenciesGrid(true); + addLimitations(false); + addAccountNameTextFieldWithAutoFillToggleButton(); + } + + private void addCurrenciesGrid(boolean isEditable) { + FlowPane flowPane = FormBuilder.addTopLabelFlowPane(gridPane, ++gridRow, + Res.get("payment.supportedCurrencies"), 20, 20).second; + + if (isEditable) { + flowPane.setId("flow-pane-checkboxes-bg"); + } else { + flowPane.setId("flow-pane-checkboxes-non-editable-bg"); + } + + CurrencyUtil.getAllVerseCurrencies().forEach(currency -> + fillUpFlowPaneWithCurrencies(isEditable, flowPane, currency, account)); + } + + @Override + protected void autoFillNameTextField() { + setAccountNameWithString(holderNameInputTextField.getText()); + } + + @Override + public void addFormForDisplayAccount() { + gridRowFrom = gridRow; + addTopLabelTextField(gridPane, gridRow, Res.get("payment.account.name"), + account.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE); + addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"), + Res.get(account.getPaymentMethod().getId())); + TextField field = addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.userName"), + account.getHolderName()).second; + field.setMouseTransparent(false); + addLimitations(true); + addCurrenciesGrid(false); + } + + @Override + public void updateAllInputsValid() { + allInputsValid.set(isAccountNameValid() + && account.getHolderName() != null + && inputValidator.validate(account.getHolderName()).isValid + && account.getTradeCurrencies().size() > 0); + } +} 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 7889da9d1b3..3e6d3a61805 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 @@ -55,6 +55,7 @@ import bisq.desktop.components.paymentmethods.SepaForm; import bisq.desktop.components.paymentmethods.SepaInstantForm; import bisq.desktop.components.paymentmethods.SpecificBankForm; +import bisq.desktop.components.paymentmethods.StrikeForm; import bisq.desktop.components.paymentmethods.SwiftForm; import bisq.desktop.components.paymentmethods.SwishForm; import bisq.desktop.components.paymentmethods.TransferwiseForm; @@ -63,6 +64,7 @@ import bisq.desktop.components.paymentmethods.USPostalMoneyOrderForm; import bisq.desktop.components.paymentmethods.UpholdForm; import bisq.desktop.components.paymentmethods.UpiForm; +import bisq.desktop.components.paymentmethods.VerseForm; import bisq.desktop.components.paymentmethods.WeChatPayForm; import bisq.desktop.components.paymentmethods.WesternUnionForm; import bisq.desktop.main.account.content.PaymentAccountsView; @@ -583,6 +585,10 @@ private PaymentMethodForm getPaymentMethodForm(PaymentMethod paymentMethod, Paym return new MoneseForm(paymentAccount, accountAgeWitnessService, inputValidator, root, gridRow, formatter); case PaymentMethod.SATISPAY_ID: return new SatispayForm(paymentAccount, accountAgeWitnessService, inputValidator, root, gridRow, formatter); + case PaymentMethod.VERSE_ID: + return new VerseForm(paymentAccount, accountAgeWitnessService, inputValidator, root, gridRow, formatter); + case PaymentMethod.STRIKE_ID: + return new StrikeForm(paymentAccount, accountAgeWitnessService, inputValidator, root, gridRow, formatter); case PaymentMethod.SWIFT_ID: return new SwiftForm(paymentAccount, accountAgeWitnessService, inputValidator, root, gridRow, formatter); default: diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java index 1c2c3151596..4d58c9e0526 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java @@ -58,12 +58,14 @@ import bisq.desktop.components.paymentmethods.SepaForm; import bisq.desktop.components.paymentmethods.SepaInstantForm; import bisq.desktop.components.paymentmethods.SpecificBankForm; +import bisq.desktop.components.paymentmethods.StrikeForm; import bisq.desktop.components.paymentmethods.SwiftForm; import bisq.desktop.components.paymentmethods.SwishForm; import bisq.desktop.components.paymentmethods.TransferwiseForm; import bisq.desktop.components.paymentmethods.USPostalMoneyOrderForm; import bisq.desktop.components.paymentmethods.UpholdForm; import bisq.desktop.components.paymentmethods.UpiForm; +import bisq.desktop.components.paymentmethods.VerseForm; import bisq.desktop.components.paymentmethods.WeChatPayForm; import bisq.desktop.components.paymentmethods.WesternUnionForm; import bisq.desktop.main.MainView; @@ -381,6 +383,12 @@ protected void addContent() { case PaymentMethod.SATISPAY_ID: gridRow = SatispayForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload); break; + case PaymentMethod.VERSE_ID: + gridRow = VerseForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload); + break; + case PaymentMethod.STRIKE_ID: + gridRow = StrikeForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload); + break; case PaymentMethod.SWIFT_ID: gridRow = SwiftForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload, trade); break; diff --git a/proto/src/main/proto/pb.proto b/proto/src/main/proto/pb.proto index bcba85821b5..7b48346db45 100644 --- a/proto/src/main/proto/pb.proto +++ b/proto/src/main/proto/pb.proto @@ -1002,6 +1002,7 @@ message PaymentAccountPayload { SwiftAccountPayload swift_account_payload = 36; CelPayAccountPayload cel_pay_account_payload = 37; MoneseAccountPayload monese_account_payload = 38; + VerseAccountPayload verse_account_payload = 39; } map exclude_from_json_data = 15; } @@ -1040,6 +1041,7 @@ message CountryBasedPaymentAccountPayload { BizumAccountPayload bizum_account_payload = 13; PixAccountPayload pix_account_payload = 14; SatispayAccountPayload satispay_account_payload = 15; + StrikeAccountPayload strike_account_payload = 16; } } @@ -1296,6 +1298,14 @@ message SatispayAccountPayload { string holder_name = 2; } +message StrikeAccountPayload { + string holder_name = 1; +} + +message VerseAccountPayload { + string holder_name = 1; +} + message SwiftAccountPayload { string beneficiary_name = 1; string beneficiary_account_nr = 2;