From 8dfe2601df547939d2c88dd38247ca6eac8cf743 Mon Sep 17 00:00:00 2001 From: BtcContributor <79100296+BtcContributor@users.noreply.github.com> Date: Tue, 18 May 2021 18:10:20 +0200 Subject: [PATCH] Restore proto order and add backward compatibility --- .../payment/payload/UpholdAccountPayload.java | 17 ++++++++++++++--- .../components/paymentmethods/UpholdForm.java | 8 +++++++- proto/src/main/proto/pb.proto | 4 ++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/bisq/core/payment/payload/UpholdAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/UpholdAccountPayload.java index cdf6698819..e04c3b406a 100644 --- a/core/src/main/java/bisq/core/payment/payload/UpholdAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/UpholdAccountPayload.java @@ -19,6 +19,8 @@ package bisq.core.payment.payload; import bisq.core.locale.Res; +import bisq.common.util.JsonExclude; + import com.google.protobuf.Message; import java.nio.charset.StandardCharsets; @@ -39,6 +41,9 @@ import lombok.extern.slf4j.Slf4j; @Slf4j public final class UpholdAccountPayload extends PaymentAccountPayload { private String accountId = ""; + + // For backward compatibility we need to exclude the new field from the contract json. + @JsonExclude private String accountOwner = ""; public UpholdAccountPayload(String paymentMethod, String id) { @@ -95,9 +100,15 @@ public final class UpholdAccountPayload extends PaymentAccountPayload { @Override public String getPaymentDetailsForTradePopup() { - return - Res.get("payment.account") + ": " + accountId + "\n" + - Res.get("payment.account.owner") + ": " + accountOwner; + if (accountOwner != "") { + return + Res.get("payment.account") + ": " + accountId + "\n" + + Res.get("payment.account.owner") + ": " + accountOwner; + } else { + return + Res.get("payment.account") + ": " + accountId + "\n" + + Res.get("payment.account.owner") + ": N/A"; + } } @Override diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/UpholdForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/UpholdForm.java index f05da06a27..e1b9d8b22d 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/UpholdForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/UpholdForm.java @@ -47,10 +47,16 @@ public class UpholdForm extends PaymentMethodForm { public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) { + String accountOwner = ((UpholdAccountPayload) paymentAccountPayload).getAccountOwner(); + if (accountOwner.isEmpty()) { + accountOwner = Res.get("payment.ask"); + } addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.account.owner"), - ((UpholdAccountPayload) paymentAccountPayload).getAccountOwner()); + accountOwner); + addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.uphold.accountId"), ((UpholdAccountPayload) paymentAccountPayload).getAccountId()); + return gridRow; } diff --git a/proto/src/main/proto/pb.proto b/proto/src/main/proto/pb.proto index ec12105838..26655d5d71 100644 --- a/proto/src/main/proto/pb.proto +++ b/proto/src/main/proto/pb.proto @@ -1132,8 +1132,8 @@ message OKPayAccountPayload { } message UpholdAccountPayload { - string account_owner = 1; - string account_id = 2; + string account_id = 1; + string account_owner = 2; } // Deprecated, not used anymore