From f5c653b92afca7d755fbd5db7141d2d6415474ec Mon Sep 17 00:00:00 2001 From: jmacxx <47253594+jmacxx@users.noreply.github.com> Date: Sun, 31 Oct 2021 13:52:33 -0500 Subject: [PATCH] Include owner name for Monese & Satispay accounts --- .../java/bisq/core/payment/MoneseAccount.java | 8 ++++++ .../bisq/core/payment/SatispayAccount.java | 8 ++++++ .../payment/payload/MoneseAccountPayload.java | 12 ++++++--- .../payload/SatispayAccountPayload.java | 13 +++++++--- .../components/paymentmethods/MoneseForm.java | 22 +++++++++++----- .../paymentmethods/SatispayForm.java | 25 +++++++++++++------ 6 files changed, 68 insertions(+), 20 deletions(-) diff --git a/core/src/main/java/bisq/core/payment/MoneseAccount.java b/core/src/main/java/bisq/core/payment/MoneseAccount.java index cc15b49e914..efc583c325b 100644 --- a/core/src/main/java/bisq/core/payment/MoneseAccount.java +++ b/core/src/main/java/bisq/core/payment/MoneseAccount.java @@ -34,6 +34,14 @@ protected PaymentAccountPayload createPayload() { return new MoneseAccountPayload(paymentMethod.getId(), id); } + public void setHolderName(String accountId) { + ((MoneseAccountPayload) paymentAccountPayload).setHolderName(accountId); + } + + public String getHolderName() { + return ((MoneseAccountPayload) paymentAccountPayload).getHolderName(); + } + public void setMobileNr(String accountId) { ((MoneseAccountPayload) paymentAccountPayload).setMobileNr(accountId); } diff --git a/core/src/main/java/bisq/core/payment/SatispayAccount.java b/core/src/main/java/bisq/core/payment/SatispayAccount.java index 440126dd112..f1d9b6f69f7 100644 --- a/core/src/main/java/bisq/core/payment/SatispayAccount.java +++ b/core/src/main/java/bisq/core/payment/SatispayAccount.java @@ -34,6 +34,14 @@ protected PaymentAccountPayload createPayload() { return new SatispayAccountPayload(paymentMethod.getId(), id); } + public void setHolderName(String accountId) { + ((SatispayAccountPayload) paymentAccountPayload).setHolderName(accountId); + } + + public String getHolderName() { + return ((SatispayAccountPayload) paymentAccountPayload).getHolderName(); + } + public void setMobileNr(String accountId) { ((SatispayAccountPayload) paymentAccountPayload).setMobileNr(accountId); } diff --git a/core/src/main/java/bisq/core/payment/payload/MoneseAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/MoneseAccountPayload.java index dce0cea4a8a..d80c1b474a4 100644 --- a/core/src/main/java/bisq/core/payment/payload/MoneseAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/MoneseAccountPayload.java @@ -38,6 +38,7 @@ @Getter @Slf4j public final class MoneseAccountPayload extends PaymentAccountPayload { + private String holderName = ""; private String mobileNr = ""; public MoneseAccountPayload(String paymentMethod, String id) { @@ -46,6 +47,7 @@ public MoneseAccountPayload(String paymentMethod, String id) { private MoneseAccountPayload(String paymentMethod, String id, + String holderName, String mobileNr, long maxTradePeriod, Map excludeFromJsonDataMap) { @@ -54,19 +56,23 @@ private MoneseAccountPayload(String paymentMethod, maxTradePeriod, excludeFromJsonDataMap); + this.holderName = holderName; this.mobileNr = mobileNr; } @Override public Message toProtoMessage() { return getPaymentAccountPayloadBuilder() - .setMoneseAccountPayload(protobuf.MoneseAccountPayload.newBuilder().setMobileNr(mobileNr)) + .setMoneseAccountPayload(protobuf.MoneseAccountPayload.newBuilder() + .setHolderName(holderName) + .setMobileNr(mobileNr)) .build(); } public static MoneseAccountPayload fromProto(protobuf.PaymentAccountPayload proto) { return new MoneseAccountPayload(proto.getPaymentMethodId(), proto.getId(), + proto.getMoneseAccountPayload().getHolderName(), proto.getMoneseAccountPayload().getMobileNr(), proto.getMaxTradePeriod(), new HashMap<>(proto.getExcludeFromJsonDataMap())); @@ -74,7 +80,7 @@ public static MoneseAccountPayload fromProto(protobuf.PaymentAccountPayload prot @Override public String getPaymentDetails() { - return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.mobile") + " " + mobileNr; + return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.account.userName") + " " + holderName; } @Override @@ -84,6 +90,6 @@ public String getPaymentDetailsForTradePopup() { @Override public byte[] getAgeWitnessInputData() { - return super.getAgeWitnessInputData(mobileNr.getBytes(StandardCharsets.UTF_8)); + return super.getAgeWitnessInputData(holderName.getBytes(StandardCharsets.UTF_8)); } } 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 fcd00ab383d..0a662068413 100644 --- a/core/src/main/java/bisq/core/payment/payload/SatispayAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/SatispayAccountPayload.java @@ -38,6 +38,7 @@ @Getter @Slf4j public final class SatispayAccountPayload extends CountryBasedPaymentAccountPayload { + private String holderName = ""; private String mobileNr = ""; public SatispayAccountPayload(String paymentMethod, String id) { @@ -47,6 +48,7 @@ public SatispayAccountPayload(String paymentMethod, String id) { private SatispayAccountPayload(String paymentMethod, String id, String countryCode, + String holderName, String mobileNr, long maxTradePeriod, Map excludeFromJsonDataMap) { @@ -56,12 +58,14 @@ private SatispayAccountPayload(String paymentMethod, maxTradePeriod, excludeFromJsonDataMap); + this.holderName = holderName; this.mobileNr = mobileNr; } @Override public Message toProtoMessage() { protobuf.SatispayAccountPayload.Builder builder = protobuf.SatispayAccountPayload.newBuilder() + .setHolderName(holderName) .setMobileNr(mobileNr); final protobuf.CountryBasedPaymentAccountPayload.Builder countryBasedPaymentAccountPayload = getPaymentAccountPayloadBuilder() .getCountryBasedPaymentAccountPayloadBuilder() @@ -73,18 +77,19 @@ public Message toProtoMessage() { public static SatispayAccountPayload fromProto(protobuf.PaymentAccountPayload proto) { protobuf.CountryBasedPaymentAccountPayload countryBasedPaymentAccountPayload = proto.getCountryBasedPaymentAccountPayload(); - protobuf.SatispayAccountPayload paytmAccountPayloadPB = countryBasedPaymentAccountPayload.getSatispayAccountPayload(); + protobuf.SatispayAccountPayload accountPayloadPB = countryBasedPaymentAccountPayload.getSatispayAccountPayload(); return new SatispayAccountPayload(proto.getPaymentMethodId(), proto.getId(), countryBasedPaymentAccountPayload.getCountryCode(), - paytmAccountPayloadPB.getMobileNr(), + accountPayloadPB.getHolderName(), + accountPayloadPB.getMobileNr(), proto.getMaxTradePeriod(), new HashMap<>(proto.getExcludeFromJsonDataMap())); } @Override public String getPaymentDetails() { - return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.mobile") + " " + mobileNr; + return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.account.userName") + " " + holderName; } @Override @@ -94,6 +99,6 @@ public String getPaymentDetailsForTradePopup() { @Override public byte[] getAgeWitnessInputData() { - return super.getAgeWitnessInputData(mobileNr.getBytes(StandardCharsets.UTF_8)); + return super.getAgeWitnessInputData(holderName.getBytes(StandardCharsets.UTF_8)); } } diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/MoneseForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/MoneseForm.java index a2a2fc4ad9c..5b0b84f130b 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/MoneseForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/MoneseForm.java @@ -31,7 +31,6 @@ 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; @@ -41,11 +40,14 @@ public class MoneseForm extends PaymentMethodForm { private final MoneseAccount account; + private InputTextField holderNameInputTextField; private InputTextField mobileNrInputTextField; public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) { - addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.mobile"), + addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, 0, Res.get("payment.account.owner"), + ((MoneseAccountPayload) paymentAccountPayload).getHolderName()); + addCompactTopLabelTextFieldWithCopyIcon(gridPane, gridRow, 1, Res.get("payment.mobile"), ((MoneseAccountPayload) paymentAccountPayload).getMobileNr()); return gridRow; } @@ -61,6 +63,13 @@ public MoneseForm(PaymentAccount paymentAccount, AccountAgeWitnessService accoun public void addFormForAddAccount() { gridRowFrom = gridRow + 1; + holderNameInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.account.owner")); + holderNameInputTextField.setValidator(inputValidator); + holderNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { + account.setHolderName(newValue.trim()); + updateFromInputs(); + }); + mobileNrInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.mobile")); mobileNrInputTextField.setValidator(inputValidator); mobileNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { @@ -99,9 +108,10 @@ public void addFormForDisplayAccount() { 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.mobile"), - account.getMobileNr()).second; - field.setMouseTransparent(false); + addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.owner"), account.getHolderName()) + .second.setMouseTransparent(false); + addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.mobile"), account.getMobileNr()) + .second.setMouseTransparent(false); addLimitations(true); addCurrenciesGrid(false); } @@ -109,7 +119,7 @@ public void addFormForDisplayAccount() { @Override public void updateAllInputsValid() { allInputsValid.set(isAccountNameValid() - && account.getMobileNr() != null + && inputValidator.validate(account.getHolderName()).isValid && inputValidator.validate(account.getMobileNr()).isValid && account.getTradeCurrencies().size() > 0); } diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/SatispayForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/SatispayForm.java index ee9e302452b..2bcd774293e 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/SatispayForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/SatispayForm.java @@ -32,21 +32,23 @@ 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.addCompactTopLabelTextFieldWithCopyIcon; import static bisq.desktop.util.FormBuilder.addTopLabelTextField; -import static bisq.desktop.util.FormBuilder.addTopLabelTextFieldWithCopyIcon; public class SatispayForm extends PaymentMethodForm { private final SatispayAccount account; + private InputTextField holderNameField; private InputTextField mobileNrInputTextField; public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) { - addTopLabelTextFieldWithCopyIcon(gridPane, gridRow, 1, Res.get("payment.mobile"), - ((SatispayAccountPayload) paymentAccountPayload).getMobileNr(), Layout.COMPACT_FIRST_ROW_AND_GROUP_DISTANCE); + addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, 0, Res.get("payment.account.owner"), + ((SatispayAccountPayload) paymentAccountPayload).getHolderName()); + addCompactTopLabelTextFieldWithCopyIcon(gridPane, gridRow, 1, Res.get("payment.mobile"), + ((SatispayAccountPayload) paymentAccountPayload).getMobileNr()); return gridRow; } @@ -65,6 +67,13 @@ public void addFormForAddAccount() { gridRowFrom = gridRow + 1; + holderNameField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.account.owner")); + holderNameField.setValidator(inputValidator); + holderNameField.textProperty().addListener((ov, oldValue, newValue) -> { + account.setHolderName(newValue.trim()); + updateFromInputs(); + }); + mobileNrInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.mobile")); mobileNrInputTextField.setValidator(inputValidator); mobileNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { @@ -90,9 +99,10 @@ public void addFormForDisplayAccount() { 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.mobile"), - account.getMobileNr()).second; - field.setMouseTransparent(false); + addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.owner"), account.getHolderName()) + .second.setMouseTransparent(false); + addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.mobile"), account.getMobileNr()) + .second.setMouseTransparent(false); addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), account.getSingleTradeCurrency().getNameAndCode()); addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.country"), account.getCountry().name); addLimitations(true); @@ -101,6 +111,7 @@ public void addFormForDisplayAccount() { @Override public void updateAllInputsValid() { allInputsValid.set(isAccountNameValid() + && inputValidator.validate(account.getHolderName()).isValid && inputValidator.validate(account.getMobileNr()).isValid); } }