Merge pull request #6965 from yonson2023/pix_add_holder_name

Update Pix payment account, add HolderName
This commit is contained in:
Alejandro García 2023-12-20 05:05:18 +00:00 committed by GitHub
commit 70a15ceb06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 3 deletions

View File

@ -21,6 +21,8 @@ import bisq.core.locale.Res;
import com.google.protobuf.Message;
import org.apache.commons.lang3.ArrayUtils;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
@ -84,16 +86,21 @@ public final class PixAccountPayload extends CountryBasedPaymentAccountPayload {
@Override
public String getPaymentDetails() {
return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.pix.key") + " " + pixKey;
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.pix.key") + " " + pixKey;
}
@Override
public byte[] getAgeWitnessInputData() {
return super.getAgeWitnessInputData(pixKey.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(
pixKey.getBytes(StandardCharsets.UTF_8),
getHolderName().getBytes(StandardCharsets.UTF_8)));
}
}

View File

@ -45,6 +45,8 @@ public class PixForm extends PaymentMethodForm {
PaymentAccountPayload paymentAccountPayload) {
addTopLabelTextFieldWithCopyIcon(gridPane, gridRow, 1, Res.get("payment.pix.key"),
((PixAccountPayload) paymentAccountPayload).getPixKey(), Layout.COMPACT_FIRST_ROW_AND_GROUP_DISTANCE);
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.owner"),
paymentAccountPayload.getHolderName());
return gridRow;
}
@ -70,6 +72,14 @@ public class PixForm extends PaymentMethodForm {
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();
});
addTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), account.getSingleTradeCurrency().getNameAndCode());
addTopLabelTextField(gridPane, ++gridRow, Res.get("shared.country"), account.getCountry().name);
addLimitations(false);
@ -90,6 +100,8 @@ public class PixForm extends PaymentMethodForm {
TextField field = addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.pix.key"),
account.getPixKey()).second;
field.setMouseTransparent(false);
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.owner"),
account.getHolderName());
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.currency"), account.getSingleTradeCurrency().getNameAndCode());
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.country"), account.getCountry().name);
addLimitations(true);
@ -98,6 +110,7 @@ public class PixForm extends PaymentMethodForm {
@Override
public void updateAllInputsValid() {
allInputsValid.set(isAccountNameValid()
&& inputValidator.validate(account.getHolderName()).isValid
&& inputValidator.validate(account.getPixKey()).isValid);
}
}