Skip to content

Commit

Permalink
Add holdername to MoneyBeam account.
Browse files Browse the repository at this point in the history
  • Loading branch information
yonson2023 committed Jan 9, 2024
1 parent 566ab53 commit 9e5fa8f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

import com.google.protobuf.Message;

import org.apache.commons.lang3.ArrayUtils;

import java.nio.charset.StandardCharsets;

import java.util.HashMap;
Expand Down Expand Up @@ -85,16 +87,21 @@ public static MoneyBeamAccountPayload fromProto(protobuf.PaymentAccountPayload p

@Override
public String getPaymentDetails() {
return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.account") + " " + accountId;
return Res.get(paymentMethodId) + " - " + getPaymentDetailsForTradePopup().replace("\n", ", ");
}

@Override
public String getPaymentDetailsForTradePopup() {
return getPaymentDetails();
return (getHolderName().isEmpty() ? "" : Res.getWithCol("payment.account.owner") + " " + getHolderName() + "\n") +
Res.getWithCol("payment.account") + " " + accountId;
}

@Override
public byte[] getAgeWitnessInputData() {
return super.getAgeWitnessInputData(accountId.getBytes(StandardCharsets.UTF_8));
// holderName will be included as part of the witness data.
// older accounts that don't have holderName still retain their existing witness.
return super.getAgeWitnessInputData(ArrayUtils.addAll(
accountId.getBytes(StandardCharsets.UTF_8),
getHolderName().getBytes(StandardCharsets.UTF_8)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public class MoneyBeamForm extends PaymentMethodForm {

public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) {
addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.moneyBeam.accountId"), ((MoneyBeamAccountPayload) paymentAccountPayload).getAccountId());
addCompactTopLabelTextFieldWithCopyIcon(gridPane, gridRow, 1, Res.get("payment.account.owner"),
paymentAccountPayload.getHolderName());
return gridRow;
}

Expand All @@ -64,6 +66,14 @@ public void addFormForAddAccount() {
updateFromInputs();
});

InputTextField holderNameInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow,
Res.get("payment.account.owner"));
holderNameInputTextField.setValidator(inputValidator);
holderNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
account.setHolderName(newValue);
updateFromInputs();
});

final TradeCurrency singleTradeCurrency = account.getSingleTradeCurrency();
final String nameAndCode = singleTradeCurrency != null ? singleTradeCurrency.getNameAndCode() : "";
addTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), nameAndCode);
Expand All @@ -83,6 +93,8 @@ public void addFormForEditAccount() {
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"), Res.get(account.getPaymentMethod().getId()));
TextField field = addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.moneyBeam.accountId"), account.getAccountId()).second;
field.setMouseTransparent(false);
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.owner"),
account.getHolderName());
final TradeCurrency singleTradeCurrency = account.getSingleTradeCurrency();
final String nameAndCode = singleTradeCurrency != null ? singleTradeCurrency.getNameAndCode() : "";
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), nameAndCode);
Expand All @@ -93,6 +105,7 @@ public void addFormForEditAccount() {
public void updateAllInputsValid() {
allInputsValid.set(isAccountNameValid()
&& validator.validate(account.getAccountId()).isValid
&& inputValidator.validate(account.getHolderName()).isValid
&& account.getTradeCurrencies().size() > 0);
}
}

0 comments on commit 9e5fa8f

Please sign in to comment.