Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MoneyBeam account, add HolderName #6968

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 Res.getWithCol("payment.account") + " " + accountId + "\n" +
Res.getWithCol("payment.account.owner") + " " + getHolderNameOrPromptIfEmpty();
}

@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 @@ -17,6 +17,8 @@

package bisq.core.payment.payload;

import bisq.core.locale.Res;

import bisq.common.consensus.UsedForTradeContractJson;
import bisq.common.crypto.CryptoUtils;
import bisq.common.proto.network.NetworkPayload;
Expand Down Expand Up @@ -135,6 +137,9 @@ public String getHolderName() {
return excludeFromJsonDataMap.getOrDefault(HOLDER_NAME, "");
}

public String getHolderNameOrPromptIfEmpty() {
return getHolderName().isEmpty() ? Res.get("payment.account.owner.ask") : getHolderName();
}
public void setHolderName(String holderName) {
// an empty string must result in the mapping removing the entry.
excludeFromJsonDataMap.compute(HOLDER_NAME, (k, v) -> Strings.emptyToNull(holderName));
Expand Down
1 change: 1 addition & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3710,6 +3710,7 @@ payment.account.name=Account name
payment.account.userName=User name
payment.account.phoneNr=Phone number
payment.account.owner=Account owner full name
payment.account.owner.ask=[Ask trader to provide account name if needed]
payment.account.fullName=Full name (first, middle, last)
payment.account.state=State/Province/Region
payment.account.city=City
Expand Down
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.getHolderNameOrPromptIfEmpty());
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);
}
}