From cbb59c155b688cf51433b5f4070f70aa3d3fb24f Mon Sep 17 00:00:00 2001 From: Steven Barclay Date: Sat, 7 Mar 2020 19:57:50 +0800 Subject: [PATCH 1/4] Remove redundant @Nullable from account payload excludeFromJsonDataMap Since this map is final and every PaymentAccountPayload constructor initialises it to something nonnull, the @Nullable field annotation is redundant, so remove it. Further simplify the code by passing an empty map into the constructor directly from each subclass constructor, rather than mapping empties to nulls from each 'proto.getExcludeFromJsonDataMap()' result, then mapping nulls back to empties in the base constructor. This is safe, since getExcludeFromJsonDataMap() always returns a nonnull map. Finally, tidy the code slightly by replacing 'Charset.forName("UTF-8")' with StandardCharsets.UTF_8 in each PaymentAccountPayload subclass. --- .../payload/AdvancedCashAccountPayload.java | 12 ++-- .../payment/payload/AliPayAccountPayload.java | 12 ++-- .../payment/payload/AssetsAccountPayload.java | 8 +-- .../payment/payload/BankAccountPayload.java | 23 ++++---- .../payload/CashAppAccountPayload.java | 8 +-- .../payload/CashDepositAccountPayload.java | 10 ++-- .../payload/ChaseQuickPayAccountPayload.java | 15 ++--- .../payload/ClearXchangeAccountPayload.java | 15 ++--- .../CountryBasedPaymentAccountPayload.java | 9 +-- .../payload/CryptoCurrencyAccountPayload.java | 10 +--- .../payment/payload/F2FAccountPayload.java | 14 ++--- .../payload/FasterPaymentsAccountPayload.java | 14 ++--- .../payload/HalCashAccountPayload.java | 12 ++-- .../payload/InstantCryptoCurrencyPayload.java | 9 +-- .../InteracETransferAccountPayload.java | 16 ++---- .../payload/JapanBankAccountPayload.java | 56 +++++++++---------- .../payload/MoneyBeamAccountPayload.java | 8 +-- .../payload/MoneyGramAccountPayload.java | 12 ++-- .../payload/NationalBankAccountPayload.java | 8 +-- .../payment/payload/OKPayAccountPayload.java | 8 +-- .../payload/PaymentAccountPayload.java | 19 ++----- .../payload/PerfectMoneyAccountPayload.java | 12 ++-- .../payload/PopmoneyAccountPayload.java | 8 +-- .../payload/PromptPayAccountPayload.java | 12 ++-- .../payload/RevolutAccountPayload.java | 8 +-- .../payload/SameBankAccountPayload.java | 9 +-- .../payment/payload/SepaAccountPayload.java | 30 +++++----- .../payload/SepaInstantAccountPayload.java | 25 ++++----- .../payload/SpecificBanksAccountPayload.java | 10 +--- .../payment/payload/SwishAccountPayload.java | 12 ++-- .../USPostalMoneyOrderAccountPayload.java | 14 ++--- .../payment/payload/UpholdAccountPayload.java | 8 +-- .../payment/payload/VenmoAccountPayload.java | 8 +-- .../payload/WeChatPayAccountPayload.java | 12 ++-- .../payload/WesternUnionAccountPayload.java | 15 ++--- 35 files changed, 179 insertions(+), 302 deletions(-) diff --git a/core/src/main/java/bisq/core/payment/payload/AdvancedCashAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/AdvancedCashAccountPayload.java index f902c06cde0..cea2a0546a1 100644 --- a/core/src/main/java/bisq/core/payment/payload/AdvancedCashAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/AdvancedCashAccountPayload.java @@ -19,11 +19,9 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -34,8 +32,6 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @ToString @Setter @@ -57,7 +53,7 @@ private AdvancedCashAccountPayload(String paymentMethod, String id, String accountNr, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethod, id, maxTradePeriod, @@ -79,7 +75,7 @@ public static AdvancedCashAccountPayload fromProto(protobuf.PaymentAccountPayloa proto.getId(), proto.getAdvancedCashAccountPayload().getAccountNr(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -99,6 +95,6 @@ public String getPaymentDetailsForTradePopup() { @Override public byte[] getAgeWitnessInputData() { - return super.getAgeWitnessInputData(accountNr.getBytes(Charset.forName("UTF-8"))); + return super.getAgeWitnessInputData(accountNr.getBytes(StandardCharsets.UTF_8)); } } diff --git a/core/src/main/java/bisq/core/payment/payload/AliPayAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/AliPayAccountPayload.java index 87d439da458..e0dd58eaa5d 100644 --- a/core/src/main/java/bisq/core/payment/payload/AliPayAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/AliPayAccountPayload.java @@ -19,11 +19,9 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -33,8 +31,6 @@ import lombok.Setter; import lombok.ToString; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @Getter @Setter @@ -55,7 +51,7 @@ private AliPayAccountPayload(String paymentMethod, String id, String accountNr, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethod, id, maxTradePeriod, @@ -76,7 +72,7 @@ public static AliPayAccountPayload fromProto(protobuf.PaymentAccountPayload prot proto.getId(), proto.getAliPayAccountPayload().getAccountNr(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -96,6 +92,6 @@ public String getPaymentDetailsForTradePopup() { @Override public byte[] getAgeWitnessInputData() { - return super.getAgeWitnessInputData(accountNr.getBytes(Charset.forName("UTF-8"))); + return super.getAgeWitnessInputData(accountNr.getBytes(StandardCharsets.UTF_8)); } } diff --git a/core/src/main/java/bisq/core/payment/payload/AssetsAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/AssetsAccountPayload.java index 76d34790e62..e35dd4c7bcb 100644 --- a/core/src/main/java/bisq/core/payment/payload/AssetsAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/AssetsAccountPayload.java @@ -19,7 +19,7 @@ import bisq.core.locale.Res; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.Map; @@ -29,8 +29,6 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @ToString @Setter @@ -52,7 +50,7 @@ protected AssetsAccountPayload(String paymentMethod, String id, String address, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethod, id, maxTradePeriod, @@ -77,6 +75,6 @@ public String getPaymentDetailsForTradePopup() { @Override public byte[] getAgeWitnessInputData() { - return super.getAgeWitnessInputData(address.getBytes(Charset.forName("UTF-8"))); + return super.getAgeWitnessInputData(address.getBytes(StandardCharsets.UTF_8)); } } diff --git a/core/src/main/java/bisq/core/payment/payload/BankAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/BankAccountPayload.java index c1ac4da1f9f..1e7af8bb0ee 100644 --- a/core/src/main/java/bisq/core/payment/payload/BankAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/BankAccountPayload.java @@ -21,7 +21,7 @@ import bisq.core.locale.CountryUtil; import bisq.core.locale.Res; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.Optional; @@ -56,7 +56,7 @@ public abstract class BankAccountPayload extends CountryBasedPaymentAccountPaylo @Nullable protected String nationalAccountId; - public BankAccountPayload(String paymentMethod, String id) { + protected BankAccountPayload(String paymentMethod, String id) { super(paymentMethod, id); } @@ -64,20 +64,19 @@ public BankAccountPayload(String paymentMethod, String id) { // PROTO BUFFER /////////////////////////////////////////////////////////////////////////////////////////// - @SuppressWarnings("NullableProblems") protected BankAccountPayload(String paymentMethodName, String id, String countryCode, String holderName, - String bankName, - String branchId, - String accountNr, - String accountType, - String holderTaxId, - String bankId, - String nationalAccountId, + @Nullable String bankName, + @Nullable String branchId, + @Nullable String accountNr, + @Nullable String accountType, + @Nullable String holderTaxId, + @Nullable String bankId, + @Nullable String nationalAccountId, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethodName, id, countryCode, @@ -178,6 +177,6 @@ public byte[] getAgeWitnessInputData() { holderTaxIdString + nationalAccountId; - return super.getAgeWitnessInputData(all.getBytes(Charset.forName("UTF-8"))); + return super.getAgeWitnessInputData(all.getBytes(StandardCharsets.UTF_8)); } } diff --git a/core/src/main/java/bisq/core/payment/payload/CashAppAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/CashAppAccountPayload.java index e2d5420f978..718cd43e105 100644 --- a/core/src/main/java/bisq/core/payment/payload/CashAppAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/CashAppAccountPayload.java @@ -19,11 +19,9 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -80,7 +78,7 @@ public static CashAppAccountPayload fromProto(protobuf.PaymentAccountPayload pro proto.getId(), proto.getCashAppAccountPayload().getCashTag(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -100,6 +98,6 @@ public String getPaymentDetailsForTradePopup() { @Override public byte[] getAgeWitnessInputData() { - return super.getAgeWitnessInputData(cashTag.getBytes(Charset.forName("UTF-8"))); + return super.getAgeWitnessInputData(cashTag.getBytes(StandardCharsets.UTF_8)); } } diff --git a/core/src/main/java/bisq/core/payment/payload/CashDepositAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/CashDepositAccountPayload.java index 9e907ff0a4c..cde304caa6a 100644 --- a/core/src/main/java/bisq/core/payment/payload/CashDepositAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/CashDepositAccountPayload.java @@ -21,11 +21,9 @@ import bisq.core.locale.CountryUtil; import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -88,7 +86,7 @@ private CashDepositAccountPayload(String paymentMethodName, @Nullable String bankId, @Nullable String nationalAccountId, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethodName, id, countryCode, @@ -146,7 +144,7 @@ public static PaymentAccountPayload fromProto(protobuf.PaymentAccountPayload pro cashDepositAccountPayload.getBankId().isEmpty() ? null : cashDepositAccountPayload.getBankId(), cashDepositAccountPayload.getNationalAccountId().isEmpty() ? null : cashDepositAccountPayload.getNationalAccountId(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -224,6 +222,6 @@ public byte[] getAgeWitnessInputData() { holderTaxIdString + nationalAccountId; - return super.getAgeWitnessInputData(all.getBytes(Charset.forName("UTF-8"))); + return super.getAgeWitnessInputData(all.getBytes(StandardCharsets.UTF_8)); } } diff --git a/core/src/main/java/bisq/core/payment/payload/ChaseQuickPayAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/ChaseQuickPayAccountPayload.java index e7bf05cd4e6..2a2b176b625 100644 --- a/core/src/main/java/bisq/core/payment/payload/ChaseQuickPayAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/ChaseQuickPayAccountPayload.java @@ -19,11 +19,9 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -34,8 +32,6 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @ToString @Setter @@ -59,7 +55,7 @@ private ChaseQuickPayAccountPayload(String paymentMethod, String email, String holderName, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethod, id, maxTradePeriod, @@ -84,7 +80,7 @@ public static ChaseQuickPayAccountPayload fromProto(protobuf.PaymentAccountPaylo proto.getChaseQuickPayAccountPayload().getEmail(), proto.getChaseQuickPayAccountPayload().getHolderName(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -94,7 +90,8 @@ public static ChaseQuickPayAccountPayload fromProto(protobuf.PaymentAccountPaylo @Override public String getPaymentDetails() { - return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.account.owner") + " " + holderName + ", " + Res.get("payment.email") + " " + email; + return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.account.owner") + " " + holderName + ", " + + Res.get("payment.email") + " " + email; } @Override @@ -107,6 +104,6 @@ public String getPaymentDetailsForTradePopup() { public byte[] getAgeWitnessInputData() { // We don't add holderName because we don't want to break age validation if the user recreates an account with // slight changes in holder name (e.g. add or remove middle name) - return super.getAgeWitnessInputData(email.getBytes(Charset.forName("UTF-8"))); + return super.getAgeWitnessInputData(email.getBytes(StandardCharsets.UTF_8)); } } diff --git a/core/src/main/java/bisq/core/payment/payload/ClearXchangeAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/ClearXchangeAccountPayload.java index 5e41ed26b2d..7b8a3be8c40 100644 --- a/core/src/main/java/bisq/core/payment/payload/ClearXchangeAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/ClearXchangeAccountPayload.java @@ -19,11 +19,9 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -34,8 +32,6 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @ToString @Setter @@ -59,7 +55,7 @@ private ClearXchangeAccountPayload(String paymentMethod, String emailOrMobileNr, String holderName, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethod, id, maxTradePeriod, @@ -84,7 +80,7 @@ public static ClearXchangeAccountPayload fromProto(protobuf.PaymentAccountPayloa proto.getClearXchangeAccountPayload().getEmailOrMobileNr(), proto.getClearXchangeAccountPayload().getHolderName(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -94,7 +90,8 @@ public static ClearXchangeAccountPayload fromProto(protobuf.PaymentAccountPayloa @Override public String getPaymentDetails() { - return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.account.owner") + " " + holderName + ", " + Res.getWithCol("payment.emailOrMobile") + " " + emailOrMobileNr; + return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.account.owner") + " " + holderName + ", " + + Res.getWithCol("payment.emailOrMobile") + " " + emailOrMobileNr; } @Override @@ -107,6 +104,6 @@ public String getPaymentDetailsForTradePopup() { public byte[] getAgeWitnessInputData() { // We don't add holderName because we don't want to break age validation if the user recreates an account with // slight changes in holder name (e.g. add or remove middle name) - return super.getAgeWitnessInputData(emailOrMobileNr.getBytes(Charset.forName("UTF-8"))); + return super.getAgeWitnessInputData(emailOrMobileNr.getBytes(StandardCharsets.UTF_8)); } } diff --git a/core/src/main/java/bisq/core/payment/payload/CountryBasedPaymentAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/CountryBasedPaymentAccountPayload.java index 80aafc0bec6..41b2a5245db 100644 --- a/core/src/main/java/bisq/core/payment/payload/CountryBasedPaymentAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/CountryBasedPaymentAccountPayload.java @@ -17,10 +17,9 @@ package bisq.core.payment.payload; - import org.apache.commons.lang3.ArrayUtils; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.Map; @@ -30,8 +29,6 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @ToString @Setter @@ -48,7 +45,7 @@ protected CountryBasedPaymentAccountPayload(String paymentMethodName, String id, String countryCode, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethodName, id, maxTradePeriod, @@ -71,6 +68,6 @@ protected protobuf.PaymentAccountPayload.Builder getPaymentAccountPayloadBuilder @Override protected byte[] getAgeWitnessInputData(byte[] data) { - return super.getAgeWitnessInputData(ArrayUtils.addAll(countryCode.getBytes(Charset.forName("UTF-8")), data)); + return super.getAgeWitnessInputData(ArrayUtils.addAll(countryCode.getBytes(StandardCharsets.UTF_8), data)); } } diff --git a/core/src/main/java/bisq/core/payment/payload/CryptoCurrencyAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/CryptoCurrencyAccountPayload.java index 223a66cf89c..3557a83f567 100644 --- a/core/src/main/java/bisq/core/payment/payload/CryptoCurrencyAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/CryptoCurrencyAccountPayload.java @@ -17,9 +17,6 @@ package bisq.core.payment.payload; - -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; import java.util.HashMap; @@ -31,8 +28,6 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @ToString @Setter @@ -53,7 +48,7 @@ private CryptoCurrencyAccountPayload(String paymentMethod, String id, String address, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethod, id, address, @@ -74,7 +69,6 @@ public static CryptoCurrencyAccountPayload fromProto(protobuf.PaymentAccountPayl proto.getId(), proto.getCryptoCurrencyAccountPayload().getAddress(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } - } diff --git a/core/src/main/java/bisq/core/payment/payload/F2FAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/F2FAccountPayload.java index 8df00b891c2..0f725668d85 100644 --- a/core/src/main/java/bisq/core/payment/payload/F2FAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/F2FAccountPayload.java @@ -19,13 +19,11 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; import org.apache.commons.lang3.ArrayUtils; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -36,8 +34,6 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @ToString @Setter @@ -64,7 +60,7 @@ private F2FAccountPayload(String paymentMethodName, String city, String extraInfo, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethodName, id, countryCode, @@ -99,7 +95,7 @@ public static PaymentAccountPayload fromProto(protobuf.PaymentAccountPayload pro f2fAccountPayloadPB.getCity(), f2fAccountPayloadPB.getExtraInfo(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -125,7 +121,7 @@ public String getPaymentDetailsForTradePopup() { @Override public byte[] getAgeWitnessInputData() { // We use here the city because the address alone seems to be too weak - return super.getAgeWitnessInputData(ArrayUtils.addAll(contact.getBytes(Charset.forName("UTF-8")), - city.getBytes(Charset.forName("UTF-8")))); + return super.getAgeWitnessInputData(ArrayUtils.addAll(contact.getBytes(StandardCharsets.UTF_8), + city.getBytes(StandardCharsets.UTF_8))); } } diff --git a/core/src/main/java/bisq/core/payment/payload/FasterPaymentsAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/FasterPaymentsAccountPayload.java index edcc0233faf..497e7bf88a6 100644 --- a/core/src/main/java/bisq/core/payment/payload/FasterPaymentsAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/FasterPaymentsAccountPayload.java @@ -19,13 +19,11 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; import org.apache.commons.lang3.ArrayUtils; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -36,8 +34,6 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @ToString @Getter @@ -64,7 +60,7 @@ private FasterPaymentsAccountPayload(String paymentMethod, String accountNr, String email, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethod, id, maxTradePeriod, @@ -91,7 +87,7 @@ public static FasterPaymentsAccountPayload fromProto(protobuf.PaymentAccountPayl proto.getFasterPaymentsAccountPayload().getAccountNr(), proto.getFasterPaymentsAccountPayload().getEmail(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -112,7 +108,7 @@ public String getPaymentDetailsForTradePopup() { @Override public byte[] getAgeWitnessInputData() { - return super.getAgeWitnessInputData(ArrayUtils.addAll(sortCode.getBytes(Charset.forName("UTF-8")), - accountNr.getBytes(Charset.forName("UTF-8")))); + return super.getAgeWitnessInputData(ArrayUtils.addAll(sortCode.getBytes(StandardCharsets.UTF_8), + accountNr.getBytes(StandardCharsets.UTF_8))); } } diff --git a/core/src/main/java/bisq/core/payment/payload/HalCashAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/HalCashAccountPayload.java index b704f9d9dbb..c991f0e8a79 100644 --- a/core/src/main/java/bisq/core/payment/payload/HalCashAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/HalCashAccountPayload.java @@ -19,11 +19,9 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -34,8 +32,6 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @ToString @Setter @@ -56,7 +52,7 @@ public HalCashAccountPayload(String paymentMethod, String id) { private HalCashAccountPayload(String paymentMethod, String id, String mobileNr, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethod, id, maxTradePeriod, @@ -77,7 +73,7 @@ public static HalCashAccountPayload fromProto(protobuf.PaymentAccountPayload pro proto.getId(), proto.getHalCashAccountPayload().getMobileNr(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -97,6 +93,6 @@ public String getPaymentDetailsForTradePopup() { @Override public byte[] getAgeWitnessInputData() { - return super.getAgeWitnessInputData(mobileNr.getBytes(Charset.forName("UTF-8"))); + return super.getAgeWitnessInputData(mobileNr.getBytes(StandardCharsets.UTF_8)); } } diff --git a/core/src/main/java/bisq/core/payment/payload/InstantCryptoCurrencyPayload.java b/core/src/main/java/bisq/core/payment/payload/InstantCryptoCurrencyPayload.java index 39551eefff4..5c7cb03fe55 100644 --- a/core/src/main/java/bisq/core/payment/payload/InstantCryptoCurrencyPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/InstantCryptoCurrencyPayload.java @@ -17,9 +17,6 @@ package bisq.core.payment.payload; - -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; import java.util.HashMap; @@ -31,8 +28,6 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @ToString @Setter @@ -53,7 +48,7 @@ private InstantCryptoCurrencyPayload(String paymentMethod, String id, String address, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethod, id, address, @@ -74,6 +69,6 @@ public static InstantCryptoCurrencyPayload fromProto(protobuf.PaymentAccountPayl proto.getId(), proto.getInstantCryptoCurrencyAccountPayload().getAddress(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } } diff --git a/core/src/main/java/bisq/core/payment/payload/InteracETransferAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/InteracETransferAccountPayload.java index 424ca7ea143..1b50a18c47d 100644 --- a/core/src/main/java/bisq/core/payment/payload/InteracETransferAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/InteracETransferAccountPayload.java @@ -19,13 +19,11 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; import org.apache.commons.lang3.ArrayUtils; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -36,8 +34,6 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @ToString @Setter @@ -65,7 +61,7 @@ private InteracETransferAccountPayload(String paymentMethod, String question, String answer, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethod, id, maxTradePeriod, @@ -95,7 +91,7 @@ public static InteracETransferAccountPayload fromProto(protobuf.PaymentAccountPa proto.getInteracETransferAccountPayload().getQuestion(), proto.getInteracETransferAccountPayload().getAnswer(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -120,8 +116,8 @@ public String getPaymentDetailsForTradePopup() { @Override public byte[] getAgeWitnessInputData() { - return super.getAgeWitnessInputData(ArrayUtils.addAll(email.getBytes(Charset.forName("UTF-8")), - ArrayUtils.addAll(question.getBytes(Charset.forName("UTF-8")), - answer.getBytes(Charset.forName("UTF-8"))))); + return super.getAgeWitnessInputData(ArrayUtils.addAll(email.getBytes(StandardCharsets.UTF_8), + ArrayUtils.addAll(question.getBytes(StandardCharsets.UTF_8), + answer.getBytes(StandardCharsets.UTF_8)))); } } diff --git a/core/src/main/java/bisq/core/payment/payload/JapanBankAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/JapanBankAccountPayload.java index 2509e4b7909..4cfd4260e6f 100644 --- a/core/src/main/java/bisq/core/payment/payload/JapanBankAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/JapanBankAccountPayload.java @@ -19,11 +19,9 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -61,16 +59,16 @@ public JapanBankAccountPayload(String paymentMethod, String id) { /////////////////////////////////////////////////////////////////////////////////////////// private JapanBankAccountPayload(String paymentMethod, - String id, - String bankName, - String bankCode, - String bankBranchName, - String bankBranchCode, - String bankAccountType, - String bankAccountName, - String bankAccountNumber, - long maxTradePeriod, - Map excludeFromJsonDataMap) { + String id, + String bankName, + String bankCode, + String bankBranchName, + String bankBranchCode, + String bankAccountType, + String bankAccountName, + String bankAccountNumber, + long maxTradePeriod, + Map excludeFromJsonDataMap) { super(paymentMethod, id, maxTradePeriod, @@ -90,13 +88,13 @@ public Message toProtoMessage() { return getPaymentAccountPayloadBuilder() .setJapanBankAccountPayload( protobuf.JapanBankAccountPayload.newBuilder() - .setBankName(bankName) - .setBankCode(bankCode) - .setBankBranchName(bankBranchName) - .setBankBranchCode(bankBranchCode) - .setBankAccountType(bankAccountType) - .setBankAccountName(bankAccountName) - .setBankAccountNumber(bankAccountNumber) + .setBankName(bankName) + .setBankCode(bankCode) + .setBankBranchName(bankBranchName) + .setBankBranchCode(bankBranchCode) + .setBankAccountType(bankAccountType) + .setBankAccountName(bankAccountName) + .setBankAccountNumber(bankAccountNumber) ).build(); } @@ -112,7 +110,7 @@ public static JapanBankAccountPayload fromProto(protobuf.PaymentAccountPayload p japanBankAccountPayload.getBankAccountName(), japanBankAccountPayload.getBankAccountNumber(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -121,24 +119,22 @@ public static JapanBankAccountPayload fromProto(protobuf.PaymentAccountPayload p /////////////////////////////////////////////////////////////////////////////////////////// @Override - public String getPaymentDetails() - { + public String getPaymentDetails() { return Res.get(paymentMethodId) + " - " + getPaymentDetailsForTradePopup().replace("\n", ", "); } @Override - public String getPaymentDetailsForTradePopup() - { - return - Res.get("payment.japan.bank") + ": " + bankName + "(" + bankCode + ")\n" + - Res.get("payment.japan.branch") + ": " + bankBranchName + "(" + bankBranchCode + ")\n" + - Res.get("payment.japan.account") + ": " + bankAccountType + " " + bankAccountNumber + "\n" + Res.get("payment.japan.recipient") + ": " + bankAccountName; + public String getPaymentDetailsForTradePopup() { + return Res.get("payment.japan.bank") + ": " + bankName + "(" + bankCode + ")\n" + + Res.get("payment.japan.branch") + ": " + bankBranchName + "(" + bankBranchCode + ")\n" + + Res.get("payment.japan.account") + ": " + bankAccountType + " " + bankAccountNumber + "\n" + + Res.get("payment.japan.recipient") + ": " + bankAccountName; } @Override public byte[] getAgeWitnessInputData() { String all = this.bankName + this.bankBranchName + this.bankAccountType + this.bankAccountNumber + this.bankAccountName; - return super.getAgeWitnessInputData(all.getBytes(Charset.forName("UTF-8"))); + return super.getAgeWitnessInputData(all.getBytes(StandardCharsets.UTF_8)); } } diff --git a/core/src/main/java/bisq/core/payment/payload/MoneyBeamAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/MoneyBeamAccountPayload.java index 6858dfd2a8e..ffb6ad7aa70 100644 --- a/core/src/main/java/bisq/core/payment/payload/MoneyBeamAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/MoneyBeamAccountPayload.java @@ -19,11 +19,9 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -77,7 +75,7 @@ public static MoneyBeamAccountPayload fromProto(protobuf.PaymentAccountPayload p proto.getId(), proto.getMoneyBeamAccountPayload().getAccountId(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -97,6 +95,6 @@ public String getPaymentDetailsForTradePopup() { @Override public byte[] getAgeWitnessInputData() { - return super.getAgeWitnessInputData(accountId.getBytes(Charset.forName("UTF-8"))); + return super.getAgeWitnessInputData(accountId.getBytes(StandardCharsets.UTF_8)); } } diff --git a/core/src/main/java/bisq/core/payment/payload/MoneyGramAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/MoneyGramAccountPayload.java index 8fcf4b5bb2e..e5f4ffc74d7 100644 --- a/core/src/main/java/bisq/core/payment/payload/MoneyGramAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/MoneyGramAccountPayload.java @@ -21,11 +21,9 @@ import bisq.core.locale.CountryUtil; import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -36,8 +34,6 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @ToString @Setter @@ -65,7 +61,7 @@ private MoneyGramAccountPayload(String paymentMethodName, String state, String email, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethodName, id, maxTradePeriod, @@ -99,7 +95,7 @@ public static PaymentAccountPayload fromProto(protobuf.PaymentAccountPayload pro moneyGramAccountPayload.getState(), moneyGramAccountPayload.getEmail(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -128,6 +124,6 @@ public byte[] getAgeWitnessInputData() { this.state + this.holderName + this.email; - return super.getAgeWitnessInputData(all.getBytes(Charset.forName("UTF-8"))); + return super.getAgeWitnessInputData(all.getBytes(StandardCharsets.UTF_8)); } } diff --git a/core/src/main/java/bisq/core/payment/payload/NationalBankAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/NationalBankAccountPayload.java index 865c122c1e9..194f4a2aabf 100644 --- a/core/src/main/java/bisq/core/payment/payload/NationalBankAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/NationalBankAccountPayload.java @@ -19,8 +19,6 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; import java.util.HashMap; @@ -30,8 +28,6 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @ToString @Slf4j @@ -58,7 +54,7 @@ private NationalBankAccountPayload(String paymentMethodName, String bankId, String nationalAccountId, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethodName, id, countryCode, @@ -105,7 +101,7 @@ public static NationalBankAccountPayload fromProto(protobuf.PaymentAccountPayloa bankAccountPayloadPB.getBankId().isEmpty() ? null : bankAccountPayloadPB.getBankId(), bankAccountPayloadPB.getNationalAccountId().isEmpty() ? null : bankAccountPayloadPB.getNationalAccountId(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @Override diff --git a/core/src/main/java/bisq/core/payment/payload/OKPayAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/OKPayAccountPayload.java index a14d7679f72..b13e83d1726 100644 --- a/core/src/main/java/bisq/core/payment/payload/OKPayAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/OKPayAccountPayload.java @@ -19,11 +19,9 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -79,7 +77,7 @@ public static OKPayAccountPayload fromProto(protobuf.PaymentAccountPayload proto proto.getId(), proto.getOKPayAccountPayload().getAccountNr(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -99,6 +97,6 @@ public String getPaymentDetailsForTradePopup() { @Override public byte[] getAgeWitnessInputData() { - return super.getAgeWitnessInputData(accountNr.getBytes(Charset.forName("UTF-8"))); + return super.getAgeWitnessInputData(accountNr.getBytes(StandardCharsets.UTF_8)); } } diff --git a/core/src/main/java/bisq/core/payment/payload/PaymentAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/PaymentAccountPayload.java index fb771f7aa17..aa31673dad3 100644 --- a/core/src/main/java/bisq/core/payment/payload/PaymentAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/PaymentAccountPayload.java @@ -25,21 +25,17 @@ import org.apache.commons.lang3.ArrayUtils; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; -import java.util.Optional; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; - import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; // That class is used in the contract for creating the contract json. Any change will break the contract. // If a field gets added it need to be be annotated with @JsonExclude (excluded from contract). @@ -67,7 +63,6 @@ public abstract class PaymentAccountPayload implements NetworkPayload, UsedForTr // PaymentAccountPayload is used for the json contract and a trade with a user who has an older version would // fail the contract verification. @JsonExclude - @Nullable protected final Map excludeFromJsonDataMap; @@ -79,7 +74,7 @@ public abstract class PaymentAccountPayload implements NetworkPayload, UsedForTr this(paymentMethodId, id, -1, - null); + new HashMap<>()); } /////////////////////////////////////////////////////////////////////////////////////////// @@ -89,11 +84,11 @@ public abstract class PaymentAccountPayload implements NetworkPayload, UsedForTr protected PaymentAccountPayload(String paymentMethodId, String id, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMapParam) { + Map excludeFromJsonDataMapParam) { this.paymentMethodId = paymentMethodId; this.id = id; this.maxTradePeriod = maxTradePeriod; - this.excludeFromJsonDataMap = excludeFromJsonDataMapParam == null ? new HashMap<>() : excludeFromJsonDataMapParam; + this.excludeFromJsonDataMap = excludeFromJsonDataMapParam; // If not set (old versions) we set by default a random 256 bit salt. // User can set salt as well by hex string. @@ -108,7 +103,7 @@ protected protobuf.PaymentAccountPayload.Builder getPaymentAccountPayloadBuilder .setMaxTradePeriod(maxTradePeriod) .setId(id); - Optional.ofNullable(excludeFromJsonDataMap).ifPresent(builder::putAllExcludeFromJsonData); + builder.putAllExcludeFromJsonData(excludeFromJsonDataMap); return builder; } @@ -123,13 +118,11 @@ protected protobuf.PaymentAccountPayload.Builder getPaymentAccountPayloadBuilder public abstract String getPaymentDetailsForTradePopup(); public byte[] getSalt() { - checkNotNull(excludeFromJsonDataMap, "excludeFromJsonDataMap must not be null"); checkArgument(excludeFromJsonDataMap.containsKey(SALT), "Salt must have been set in excludeFromJsonDataMap."); return Utilities.decodeFromHex(excludeFromJsonDataMap.get(SALT)); } public void setSalt(byte[] salt) { - checkNotNull(excludeFromJsonDataMap, "excludeFromJsonDataMap must not be null"); excludeFromJsonDataMap.put(SALT, Utilities.encodeToHex(salt)); } @@ -139,6 +132,6 @@ public void setSalt(byte[] salt) { public abstract byte[] getAgeWitnessInputData(); protected byte[] getAgeWitnessInputData(byte[] data) { - return ArrayUtils.addAll(paymentMethodId.getBytes(Charset.forName("UTF-8")), data); + return ArrayUtils.addAll(paymentMethodId.getBytes(StandardCharsets.UTF_8), data); } } diff --git a/core/src/main/java/bisq/core/payment/payload/PerfectMoneyAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/PerfectMoneyAccountPayload.java index e5c66a351a0..9ffbeb48378 100644 --- a/core/src/main/java/bisq/core/payment/payload/PerfectMoneyAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/PerfectMoneyAccountPayload.java @@ -19,11 +19,9 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -34,8 +32,6 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @ToString @Setter @@ -57,7 +53,7 @@ private PerfectMoneyAccountPayload(String paymentMethod, String id, String accountNr, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethod, id, maxTradePeriod, @@ -79,7 +75,7 @@ public static PerfectMoneyAccountPayload fromProto(protobuf.PaymentAccountPayloa proto.getId(), proto.getPerfectMoneyAccountPayload().getAccountNr(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -99,6 +95,6 @@ public String getPaymentDetailsForTradePopup() { @Override public byte[] getAgeWitnessInputData() { - return super.getAgeWitnessInputData(accountNr.getBytes(Charset.forName("UTF-8"))); + return super.getAgeWitnessInputData(accountNr.getBytes(StandardCharsets.UTF_8)); } } diff --git a/core/src/main/java/bisq/core/payment/payload/PopmoneyAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/PopmoneyAccountPayload.java index 358699a5a9e..56096cc47f3 100644 --- a/core/src/main/java/bisq/core/payment/payload/PopmoneyAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/PopmoneyAccountPayload.java @@ -19,11 +19,9 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -82,7 +80,7 @@ public static PopmoneyAccountPayload fromProto(protobuf.PaymentAccountPayload pr proto.getPopmoneyAccountPayload().getAccountId(), proto.getPopmoneyAccountPayload().getHolderName(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -103,6 +101,6 @@ public String getPaymentDetailsForTradePopup() { @Override public byte[] getAgeWitnessInputData() { - return super.getAgeWitnessInputData(accountId.getBytes(Charset.forName("UTF-8"))); + return super.getAgeWitnessInputData(accountId.getBytes(StandardCharsets.UTF_8)); } } diff --git a/core/src/main/java/bisq/core/payment/payload/PromptPayAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/PromptPayAccountPayload.java index c15fc797dab..bf3c7c976d6 100644 --- a/core/src/main/java/bisq/core/payment/payload/PromptPayAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/PromptPayAccountPayload.java @@ -19,11 +19,9 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -34,8 +32,6 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @ToString @Setter @@ -56,7 +52,7 @@ public PromptPayAccountPayload(String paymentMethod, String id) { private PromptPayAccountPayload(String paymentMethod, String id, String promptPayId, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethod, id, maxTradePeriod, @@ -78,7 +74,7 @@ public static PromptPayAccountPayload fromProto(protobuf.PaymentAccountPayload p proto.getId(), proto.getPromptPayAccountPayload().getPromptPayId(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -98,6 +94,6 @@ public String getPaymentDetailsForTradePopup() { @Override public byte[] getAgeWitnessInputData() { - return super.getAgeWitnessInputData(promptPayId.getBytes(Charset.forName("UTF-8"))); + return super.getAgeWitnessInputData(promptPayId.getBytes(StandardCharsets.UTF_8)); } } diff --git a/core/src/main/java/bisq/core/payment/payload/RevolutAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/RevolutAccountPayload.java index d081f6c5b01..24856d14054 100644 --- a/core/src/main/java/bisq/core/payment/payload/RevolutAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/RevolutAccountPayload.java @@ -19,11 +19,9 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -77,7 +75,7 @@ public static RevolutAccountPayload fromProto(protobuf.PaymentAccountPayload pro proto.getId(), proto.getRevolutAccountPayload().getAccountId(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -97,6 +95,6 @@ public String getPaymentDetailsForTradePopup() { @Override public byte[] getAgeWitnessInputData() { - return super.getAgeWitnessInputData(accountId.getBytes(Charset.forName("UTF-8"))); + return super.getAgeWitnessInputData(accountId.getBytes(StandardCharsets.UTF_8)); } } diff --git a/core/src/main/java/bisq/core/payment/payload/SameBankAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/SameBankAccountPayload.java index 3932cd822c4..d10d384219c 100644 --- a/core/src/main/java/bisq/core/payment/payload/SameBankAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/SameBankAccountPayload.java @@ -19,8 +19,6 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; import java.util.HashMap; @@ -30,8 +28,6 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @ToString @Slf4j @@ -58,7 +54,7 @@ private SameBankAccountPayload(String paymentMethodName, String bankId, String nationalAccountId, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethodName, id, countryCode, @@ -72,7 +68,6 @@ private SameBankAccountPayload(String paymentMethodName, nationalAccountId, maxTradePeriod, excludeFromJsonDataMap); - } @Override @@ -106,7 +101,7 @@ public static SameBankAccountPayload fromProto(protobuf.PaymentAccountPayload pr bankAccountPayload.getBankId().isEmpty() ? null : bankAccountPayload.getBankId(), bankAccountPayload.getNationalAccountId().isEmpty() ? null : bankAccountPayload.getNationalAccountId(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/core/src/main/java/bisq/core/payment/payload/SepaAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/SepaAccountPayload.java index c0aca441884..30bb334d158 100644 --- a/core/src/main/java/bisq/core/payment/payload/SepaAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/SepaAccountPayload.java @@ -21,19 +21,16 @@ import bisq.core.locale.CountryUtil; import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; import org.apache.commons.lang3.ArrayUtils; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.stream.Collectors; import lombok.EqualsAndHashCode; @@ -42,8 +39,6 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @ToString @Getter @@ -57,15 +52,16 @@ public final class SepaAccountPayload extends CountryBasedPaymentAccountPayload private String bic = ""; private String email = ""; // not used anymore but need to keep it for backward compatibility, must not be null but empty string, otherwise hash check fails for contract - // Dont use a set here as we need a deterministic ordering, otherwise the contract hash does not match + // Don't use a set here as we need a deterministic ordering, otherwise the contract hash does not match private final List acceptedCountryCodes; public SepaAccountPayload(String paymentMethod, String id, List acceptedCountries) { super(paymentMethod, id); - Set acceptedCountryCodesAsSet = acceptedCountries.stream() - .map(e -> e.code).collect(Collectors.toSet()); - acceptedCountryCodes = new ArrayList<>(acceptedCountryCodesAsSet); - acceptedCountryCodes.sort(String::compareTo); + acceptedCountryCodes = acceptedCountries.stream() + .map(e -> e.code) + .sorted() + .distinct() + .collect(Collectors.toList()); } @@ -82,7 +78,7 @@ private SepaAccountPayload(String paymentMethodName, String email, List acceptedCountryCodes, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethodName, id, countryCode, @@ -125,7 +121,7 @@ public static PaymentAccountPayload fromProto(protobuf.PaymentAccountPayload pro sepaAccountPayloadPB.getEmail(), new ArrayList<>(sepaAccountPayloadPB.getAcceptedCountryCodesList()), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -139,13 +135,13 @@ public void addAcceptedCountry(String countryCode) { } public void removeAcceptedCountry(String countryCode) { - if (acceptedCountryCodes.contains(countryCode)) - acceptedCountryCodes.remove(countryCode); + acceptedCountryCodes.remove(countryCode); } @Override public String getPaymentDetails() { - return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.account.owner") + " " + holderName + ", IBAN: " + iban + ", BIC: " + bic + ", " + Res.getWithCol("payment.bank.country") + " " + getCountryCode(); + return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.account.owner") + " " + holderName + ", IBAN: " + + iban + ", BIC: " + bic + ", " + Res.getWithCol("payment.bank.country") + " " + getCountryCode(); } @Override @@ -160,6 +156,6 @@ public String getPaymentDetailsForTradePopup() { public byte[] getAgeWitnessInputData() { // We don't add holderName because we don't want to break age validation if the user recreates an account with // slight changes in holder name (e.g. add or remove middle name) - return super.getAgeWitnessInputData(ArrayUtils.addAll(iban.getBytes(Charset.forName("UTF-8")), bic.getBytes(Charset.forName("UTF-8")))); + return super.getAgeWitnessInputData(ArrayUtils.addAll(iban.getBytes(StandardCharsets.UTF_8), bic.getBytes(StandardCharsets.UTF_8))); } } diff --git a/core/src/main/java/bisq/core/payment/payload/SepaInstantAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/SepaInstantAccountPayload.java index 9b413c82273..f74028baaa8 100644 --- a/core/src/main/java/bisq/core/payment/payload/SepaInstantAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/SepaInstantAccountPayload.java @@ -21,19 +21,16 @@ import bisq.core.locale.CountryUtil; import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; import org.apache.commons.lang3.ArrayUtils; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.stream.Collectors; import lombok.EqualsAndHashCode; @@ -42,8 +39,6 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @ToString @Getter @@ -61,10 +56,11 @@ public final class SepaInstantAccountPayload extends CountryBasedPaymentAccountP public SepaInstantAccountPayload(String paymentMethod, String id, List acceptedCountries) { super(paymentMethod, id); - Set acceptedCountryCodesAsSet = acceptedCountries.stream() - .map(e -> e.code).collect(Collectors.toSet()); - acceptedCountryCodes = new ArrayList<>(acceptedCountryCodesAsSet); - acceptedCountryCodes.sort(String::compareTo); + acceptedCountryCodes = acceptedCountries.stream() + .map(e -> e.code) + .sorted() + .distinct() + .collect(Collectors.toList()); } @@ -80,7 +76,7 @@ private SepaInstantAccountPayload(String paymentMethodName, String bic, List acceptedCountryCodes, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethodName, id, countryCode, @@ -120,7 +116,7 @@ public static PaymentAccountPayload fromProto(protobuf.PaymentAccountPayload pro sepaInstantAccountPayloadPB.getBic(), new ArrayList<>(sepaInstantAccountPayloadPB.getAcceptedCountryCodesList()), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -134,8 +130,7 @@ public void addAcceptedCountry(String countryCode) { } public void removeAcceptedCountry(String countryCode) { - if (acceptedCountryCodes.contains(countryCode)) - acceptedCountryCodes.remove(countryCode); + acceptedCountryCodes.remove(countryCode); } @Override @@ -156,6 +151,6 @@ public String getPaymentDetailsForTradePopup() { public byte[] getAgeWitnessInputData() { // We don't add holderName because we don't want to break age validation if the user recreates an account with // slight changes in holder name (e.g. add or remove middle name) - return super.getAgeWitnessInputData(ArrayUtils.addAll(iban.getBytes(Charset.forName("UTF-8")), bic.getBytes(Charset.forName("UTF-8")))); + return super.getAgeWitnessInputData(ArrayUtils.addAll(iban.getBytes(StandardCharsets.UTF_8), bic.getBytes(StandardCharsets.UTF_8))); } } diff --git a/core/src/main/java/bisq/core/payment/payload/SpecificBanksAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/SpecificBanksAccountPayload.java index 66551c40e52..ac32af5d47b 100644 --- a/core/src/main/java/bisq/core/payment/payload/SpecificBanksAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/SpecificBanksAccountPayload.java @@ -19,8 +19,6 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; import com.google.common.base.Joiner; @@ -34,14 +32,12 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @ToString @Getter @Slf4j public final class SpecificBanksAccountPayload extends BankAccountPayload { - // Dont use a set here as we need a deterministic ordering, otherwise the contract hash does not match + // Don't use a set here as we need a deterministic ordering, otherwise the contract hash does not match private ArrayList acceptedBanks = new ArrayList<>(); public SpecificBanksAccountPayload(String paymentMethod, String id) { @@ -66,7 +62,7 @@ private SpecificBanksAccountPayload(String paymentMethodName, String nationalAccountId, ArrayList acceptedBanks, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethodName, id, countryCode, @@ -120,7 +116,7 @@ public static SpecificBanksAccountPayload fromProto(protobuf.PaymentAccountPaylo bankAccountPayload.getNationalAccountId().isEmpty() ? null : bankAccountPayload.getNationalAccountId(), new ArrayList<>(specificBanksAccountPayload.getAcceptedBanksList()), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } diff --git a/core/src/main/java/bisq/core/payment/payload/SwishAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/SwishAccountPayload.java index fc13a233351..646a556f6e5 100644 --- a/core/src/main/java/bisq/core/payment/payload/SwishAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/SwishAccountPayload.java @@ -19,11 +19,9 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -34,8 +32,6 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @ToString @Setter @@ -58,7 +54,7 @@ private SwishAccountPayload(String paymentMethod, String id, String mobileNr, String holderName, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethod, id, maxTradePeriod, @@ -82,7 +78,7 @@ public static SwishAccountPayload fromProto(protobuf.PaymentAccountPayload proto proto.getSwishAccountPayload().getMobileNr(), proto.getSwishAccountPayload().getHolderName(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -106,6 +102,6 @@ public String getPaymentDetailsForTradePopup() { public byte[] getAgeWitnessInputData() { // We don't add holderName because we don't want to break age validation if the user recreates an account with // slight changes in holder name (e.g. add or remove middle name) - return super.getAgeWitnessInputData(mobileNr.getBytes(Charset.forName("UTF-8"))); + return super.getAgeWitnessInputData(mobileNr.getBytes(StandardCharsets.UTF_8)); } } diff --git a/core/src/main/java/bisq/core/payment/payload/USPostalMoneyOrderAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/USPostalMoneyOrderAccountPayload.java index 475ebdcebe5..3f6990e83ea 100644 --- a/core/src/main/java/bisq/core/payment/payload/USPostalMoneyOrderAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/USPostalMoneyOrderAccountPayload.java @@ -19,13 +19,11 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; import org.apache.commons.lang3.ArrayUtils; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -36,8 +34,6 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @ToString @Setter @@ -60,7 +56,7 @@ private USPostalMoneyOrderAccountPayload(String paymentMethod, String id, String postalAddress, String holderName, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethod, id, maxTradePeriod, @@ -84,7 +80,7 @@ public static USPostalMoneyOrderAccountPayload fromProto(protobuf.PaymentAccount proto.getUSPostalMoneyOrderAccountPayload().getPostalAddress(), proto.getUSPostalMoneyOrderAccountPayload().getHolderName(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -108,7 +104,7 @@ public String getPaymentDetailsForTradePopup() { @Override public byte[] getAgeWitnessInputData() { // We use here the holderName because the address alone seems to be too weak - return super.getAgeWitnessInputData(ArrayUtils.addAll(holderName.getBytes(Charset.forName("UTF-8")), - postalAddress.getBytes(Charset.forName("UTF-8")))); + return super.getAgeWitnessInputData(ArrayUtils.addAll(holderName.getBytes(StandardCharsets.UTF_8), + postalAddress.getBytes(StandardCharsets.UTF_8))); } } 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 fdd0f5679f5..eab4293f800 100644 --- a/core/src/main/java/bisq/core/payment/payload/UpholdAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/UpholdAccountPayload.java @@ -19,11 +19,9 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -77,7 +75,7 @@ public static UpholdAccountPayload fromProto(protobuf.PaymentAccountPayload prot proto.getId(), proto.getUpholdAccountPayload().getAccountId(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -97,6 +95,6 @@ public String getPaymentDetailsForTradePopup() { @Override public byte[] getAgeWitnessInputData() { - return super.getAgeWitnessInputData(accountId.getBytes(Charset.forName("UTF-8"))); + return super.getAgeWitnessInputData(accountId.getBytes(StandardCharsets.UTF_8)); } } diff --git a/core/src/main/java/bisq/core/payment/payload/VenmoAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/VenmoAccountPayload.java index 46a623c531c..05861b92e10 100644 --- a/core/src/main/java/bisq/core/payment/payload/VenmoAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/VenmoAccountPayload.java @@ -19,11 +19,9 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -85,7 +83,7 @@ public static VenmoAccountPayload fromProto(protobuf.PaymentAccountPayload proto proto.getVenmoAccountPayload().getVenmoUserName(), proto.getVenmoAccountPayload().getHolderName(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -106,6 +104,6 @@ public String getPaymentDetailsForTradePopup() { @Override public byte[] getAgeWitnessInputData() { - return super.getAgeWitnessInputData(venmoUserName.getBytes(Charset.forName("UTF-8"))); + return super.getAgeWitnessInputData(venmoUserName.getBytes(StandardCharsets.UTF_8)); } } diff --git a/core/src/main/java/bisq/core/payment/payload/WeChatPayAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/WeChatPayAccountPayload.java index ffc36680b9d..b4afe51bd40 100644 --- a/core/src/main/java/bisq/core/payment/payload/WeChatPayAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/WeChatPayAccountPayload.java @@ -19,11 +19,9 @@ import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -33,8 +31,6 @@ import lombok.Setter; import lombok.ToString; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @Getter @Setter @@ -55,7 +51,7 @@ private WeChatPayAccountPayload(String paymentMethod, String id, String accountNr, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethod, id, maxTradePeriod, @@ -76,7 +72,7 @@ public static WeChatPayAccountPayload fromProto(protobuf.PaymentAccountPayload p proto.getId(), proto.getWeChatPayAccountPayload().getAccountNr(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -96,6 +92,6 @@ public String getPaymentDetailsForTradePopup() { @Override public byte[] getAgeWitnessInputData() { - return super.getAgeWitnessInputData(accountNr.getBytes(Charset.forName("UTF-8"))); + return super.getAgeWitnessInputData(accountNr.getBytes(StandardCharsets.UTF_8)); } } diff --git a/core/src/main/java/bisq/core/payment/payload/WesternUnionAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/WesternUnionAccountPayload.java index 2375456ec0b..f99b80e81f0 100644 --- a/core/src/main/java/bisq/core/payment/payload/WesternUnionAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/WesternUnionAccountPayload.java @@ -21,11 +21,9 @@ import bisq.core.locale.CountryUtil; import bisq.core.locale.Res; -import bisq.common.util.CollectionUtils; - import com.google.protobuf.Message; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -36,8 +34,6 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import javax.annotation.Nullable; - @EqualsAndHashCode(callSuper = true) @ToString @Setter @@ -66,7 +62,7 @@ private WesternUnionAccountPayload(String paymentMethodName, String state, String email, long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + Map excludeFromJsonDataMap) { super(paymentMethodName, id, countryCode, @@ -106,7 +102,7 @@ public static PaymentAccountPayload fromProto(protobuf.PaymentAccountPayload pro westernUnionAccountPayload.getState(), westernUnionAccountPayload.getEmail(), proto.getMaxTradePeriod(), - CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + new HashMap<>(proto.getExcludeFromJsonDataMap())); } @@ -121,7 +117,8 @@ public String getPaymentDetails() { @Override public String getPaymentDetailsForTradePopup() { - String cityState = BankUtil.isStateRequired(countryCode) ? (Res.get("payment.account.city") + " / " + Res.getWithCol("payment.account.state") + " " + city + " / " + state + "\n") + String cityState = BankUtil.isStateRequired(countryCode) + ? (Res.get("payment.account.city") + " / " + Res.getWithCol("payment.account.state") + " " + city + " / " + state + "\n") : (Res.getWithCol("payment.account.city") + " " + city + "\n"); return Res.getWithCol("payment.account.fullName") + " " + holderName + "\n" + cityState + @@ -134,6 +131,6 @@ public byte[] getAgeWitnessInputData() { String all = this.countryCode + this.holderName + this.email; - return super.getAgeWitnessInputData(all.getBytes(Charset.forName("UTF-8"))); + return super.getAgeWitnessInputData(all.getBytes(StandardCharsets.UTF_8)); } } From a829969089d7d4acb9968856c31a2e91d37ab5fe Mon Sep 17 00:00:00 2001 From: Steven Barclay Date: Wed, 11 Mar 2020 19:09:34 +0800 Subject: [PATCH 2/4] Add holder name for new Faster Payments accounts Use excludeFromJsonDataMap to add an optional owner full name property to Faster Payments (GBP) accounts, without affecting the trade JSON contract (for backwards compatibility). This is to fix #3976, that some banks have started checking the recipient name. Make the name a non-optional field for _new_ accounts, but display the details for old Faster Payments accounts in exactly the same way as before, only showing the extra field in the info popup, account and trade step views when it is present. Also update the now misleading payment instructions in the buyer popup. TODO: Update translations (which probably aren't needed anyway). --- .../core/payment/FasterPaymentsAccount.java | 8 ++++++ .../payload/FasterPaymentsAccountPayload.java | 15 +++++++++-- .../payload/PaymentAccountPayload.java | 1 + .../resources/i18n/displayStrings.properties | 5 ++-- .../paymentmethods/FasterPaymentsForm.java | 25 +++++++++++++++++-- 5 files changed, 48 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/bisq/core/payment/FasterPaymentsAccount.java b/core/src/main/java/bisq/core/payment/FasterPaymentsAccount.java index cd3a8c63df6..3c4f124c662 100644 --- a/core/src/main/java/bisq/core/payment/FasterPaymentsAccount.java +++ b/core/src/main/java/bisq/core/payment/FasterPaymentsAccount.java @@ -36,6 +36,14 @@ protected PaymentAccountPayload createPayload() { return new FasterPaymentsAccountPayload(paymentMethod.getId(), id); } + public void setHolderName(String value) { + ((FasterPaymentsAccountPayload) paymentAccountPayload).setHolderName(value); + } + + public String getHolderName() { + return ((FasterPaymentsAccountPayload) paymentAccountPayload).getHolderName(); + } + public void setSortCode(String value) { ((FasterPaymentsAccountPayload) paymentAccountPayload).setSortCode(value); } diff --git a/core/src/main/java/bisq/core/payment/payload/FasterPaymentsAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/FasterPaymentsAccountPayload.java index 497e7bf88a6..1c14c47faf2 100644 --- a/core/src/main/java/bisq/core/payment/payload/FasterPaymentsAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/FasterPaymentsAccountPayload.java @@ -21,6 +21,8 @@ import com.google.protobuf.Message; +import com.google.common.base.Strings; + import org.apache.commons.lang3.ArrayUtils; import java.nio.charset.StandardCharsets; @@ -95,14 +97,23 @@ public static FasterPaymentsAccountPayload fromProto(protobuf.PaymentAccountPayl // API /////////////////////////////////////////////////////////////////////////////////////////// + public String getHolderName() { + return excludeFromJsonDataMap.getOrDefault(HOLDER_NAME, ""); + } + + public void setHolderName(String holderName) { + excludeFromJsonDataMap.compute(HOLDER_NAME, (k, v) -> Strings.emptyToNull(holderName)); + } + @Override public String getPaymentDetails() { - return Res.get(paymentMethodId) + " - UK Sort code: " + sortCode + ", " + Res.getWithCol("payment.accountNr") + " " + accountNr; + return Res.get(paymentMethodId) + " - " + getPaymentDetailsForTradePopup().replace("\n", ", "); } @Override public String getPaymentDetailsForTradePopup() { - return "UK Sort code: " + sortCode + "\n" + + return (getHolderName().isEmpty() ? "" : Res.getWithCol("payment.account.owner") + " " + getHolderName() + "\n") + + "UK Sort code: " + sortCode + "\n" + Res.getWithCol("payment.accountNr") + " " + accountNr; } diff --git a/core/src/main/java/bisq/core/payment/payload/PaymentAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/PaymentAccountPayload.java index aa31673dad3..8a198187075 100644 --- a/core/src/main/java/bisq/core/payment/payload/PaymentAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/PaymentAccountPayload.java @@ -49,6 +49,7 @@ public abstract class PaymentAccountPayload implements NetworkPayload, UsedForTr // Keys for excludeFromJsonDataMap public static final String SALT = "salt"; + public static final String HOLDER_NAME = "holderName"; protected final String paymentMethodId; protected final String id; diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 31b5c04a6a3..c5e947f4983 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -622,8 +622,9 @@ portfolio.pending.step2_buyer.halCashInfo.msg=You need to send a text message wi trade ID ({0}) to the BTC seller.\nThe seller''s mobile nr. is {1}.\n\n\ Did you send the code to the seller? portfolio.pending.step2_buyer.fasterPaymentsHolderNameInfo=Some banks might require the receiver's name. \ - The UK sort code and account number is sufficient for a Faster Payment transfer and the receivers name is not verified \ - by any of the banks. + The UK sort code and account number used to be sufficient for a Faster Payment transfer, but since then some banks \ + have started verifying the receiver's name. For this reason, accounts created in old Bisq clients do not provide the \ + trade partner with an owner full name. Please use trade chat to avoid any issues in such cases. portfolio.pending.step2_buyer.confirmStart.headline=Confirm that you have started the payment portfolio.pending.step2_buyer.confirmStart.msg=Did you initiate the {0} payment to your trading partner? portfolio.pending.step2_buyer.confirmStart.yes=Yes, I have started the payment diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/FasterPaymentsForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/FasterPaymentsForm.java index b23aca149d7..1e9028f71be 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/FasterPaymentsForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/FasterPaymentsForm.java @@ -44,6 +44,10 @@ public class FasterPaymentsForm extends PaymentMethodForm { public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountPayload paymentAccountPayload) { + if (!((FasterPaymentsAccountPayload) paymentAccountPayload).getHolderName().isEmpty()) { + addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.owner"), + ((FasterPaymentsAccountPayload) paymentAccountPayload).getHolderName()); + } // do not translate as it is used in English only addCompactTopLabelTextField(gridPane, ++gridRow, UK_SORT_CODE, ((FasterPaymentsAccountPayload) paymentAccountPayload).getSortCode()); @@ -54,11 +58,16 @@ public static int addFormForBuyer(GridPane gridPane, int gridRow, private final FasterPaymentsAccount fasterPaymentsAccount; + private InputTextField holderNameInputTextField; private InputTextField accountNrInputTextField; private InputTextField sortCodeInputTextField; - public FasterPaymentsForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, InputValidator inputValidator, GridPane gridPane, - int gridRow, CoinFormatter formatter) { + public FasterPaymentsForm(PaymentAccount paymentAccount, + AccountAgeWitnessService accountAgeWitnessService, + InputValidator inputValidator, + GridPane gridPane, + int gridRow, + CoinFormatter formatter) { super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter); this.fasterPaymentsAccount = (FasterPaymentsAccount) paymentAccount; } @@ -66,6 +75,13 @@ public FasterPaymentsForm(PaymentAccount paymentAccount, AccountAgeWitnessServic @Override 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) -> { + fasterPaymentsAccount.setHolderName(newValue); + updateFromInputs(); + }); + // do not translate as it is used in English only sortCodeInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, UK_SORT_CODE); sortCodeInputTextField.setValidator(inputValidator); @@ -102,6 +118,10 @@ public void addFormForDisplayAccount() { fasterPaymentsAccount.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE); addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"), Res.get(fasterPaymentsAccount.getPaymentMethod().getId())); + if (!fasterPaymentsAccount.getHolderName().isEmpty()) { + addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.account.owner"), + fasterPaymentsAccount.getHolderName()); + } // do not translate as it is used in English only addCompactTopLabelTextField(gridPane, ++gridRow, UK_SORT_CODE, fasterPaymentsAccount.getSortCode()); TextField field = addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.accountNr"), @@ -116,6 +136,7 @@ public void addFormForDisplayAccount() { @Override public void updateAllInputsValid() { allInputsValid.set(isAccountNameValid() + && holderNameInputTextField.getValidator().validate(fasterPaymentsAccount.getHolderName()).isValid && sortCodeInputTextField.getValidator().validate(fasterPaymentsAccount.getSortCode()).isValid && accountNrInputTextField.getValidator().validate(fasterPaymentsAccount.getAccountNr()).isValid && fasterPaymentsAccount.getTradeCurrencies().size() > 0); From a957fb167a15f43204b0f2ee212d471ba7a0caab Mon Sep 17 00:00:00 2001 From: Steven Barclay Date: Wed, 25 Mar 2020 17:48:06 +0800 Subject: [PATCH 3/4] Add popup to advise user to recreate Faster Payments account Open an info popup in the take/create offer view, upon choosing to take or make a new offer, to instruct the user to recreate their old Faster Payments account with an owner full name (and preserved salt). Also show the popup upon manual selection of any old (i.e. missing full name) Faster Payments account from the trading account combo box, analogously to the ClearXchange (Zelle) warning popup logic. (Also eliminate slight differences between the private 'maybeShow[ClearXchange|FasterPayments]Warning' methods in TakeOfferView and MutableOfferView, to make the code easier to deduplicate in future.) --- .../resources/i18n/displayStrings.properties | 8 +- .../desktop/main/offer/MutableOfferView.java | 16 +++- .../main/offer/takeoffer/TakeOfferView.java | 77 +++++++++++-------- .../main/java/bisq/desktop/util/GUIUtil.java | 18 ++++- 4 files changed, 80 insertions(+), 39 deletions(-) diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index c5e947f4983..ec49d08dcf3 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -3020,7 +3020,13 @@ If you have not fulfilled the above requirements you will lose your security dep For the {0} seller it is highly recommended \ to get in contact with the {1} buyer by using the provided email address or mobile number to verify that he or she \ is really the owner of the Zelle (ClearXchange) account. - +payment.fasterPayments.newRequirements.info=When using Faster Payments some banks have started verifying the receiver''s \ + full name. Your current Faster Payments account only specifies a UK bank account number and sort code. This used to be \ + sufficient, but may not be now for some sender''s banks. New Faster Payments accounts in Bisq now include an owner \ + full name. Please consider recreating your account in Bisq to provide future {0} buyers with a recipient name.\n\n\ + When recreating a Faster Payments account, take care to copy the account age verification salt from your old account \ + and use the same sort code and account number. (The owner full name or account name need not be the same, however.) \ + This preserves the public hash, so that the new account need not be aged or signed from scratch. payment.moneyGram.info=When using MoneyGram the BTC buyer has to send the Authorisation number and a photo of the receipt by email to the BTC seller. \ The receipt must clearly show the seller's full name, country, state and the amount. The buyer will get displayed the seller's email in the trade process. payment.westernUnion.info=When using Western Union the BTC buyer has to send the MTCN (tracking number) and a photo of the receipt by email to the BTC seller. \ diff --git a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferView.java b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferView.java index 94919fe1541..7351baf2472 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferView.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferView.java @@ -51,6 +51,7 @@ import bisq.core.locale.TradeCurrency; import bisq.core.offer.Offer; import bisq.core.offer.OfferPayload; +import bisq.core.payment.FasterPaymentsAccount; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.PaymentMethod; import bisq.core.user.DontShowAgainLookup; @@ -170,7 +171,7 @@ public abstract class MutableOfferView> exten protected int gridRow = 0; private final List editOfferElements = new ArrayList<>(); - private boolean clearXchangeWarningDisplayed, isActivated; + private boolean clearXchangeWarningDisplayed, fasterPaymentsWarningDisplayed, isActivated; private InfoInputTextField marketBasedPriceInfoInputTextField, volumeInfoInputTextField, buyerSecurityDepositInfoInputTextField; private AutoTooltipSlideToggleButton tradeFeeInBtcToggle, tradeFeeInBsqToggle; @@ -492,8 +493,16 @@ private void maybeShowClearXchangeWarning(PaymentAccount paymentAccount) { if (paymentAccount.getPaymentMethod().getId().equals(PaymentMethod.CLEAR_X_CHANGE_ID) && !clearXchangeWarningDisplayed) { clearXchangeWarningDisplayed = true; - UserThread.runAfter(GUIUtil::showClearXchangeWarning, - 500, TimeUnit.MILLISECONDS); + UserThread.runAfter(GUIUtil::showClearXchangeWarning, 500, TimeUnit.MILLISECONDS); + } + } + + private void maybeShowFasterPaymentsWarning(PaymentAccount paymentAccount) { + if (paymentAccount.getPaymentMethod().getId().equals(PaymentMethod.FASTER_PAYMENTS_ID) && + ((FasterPaymentsAccount) paymentAccount).getHolderName().isEmpty() && + !fasterPaymentsWarningDisplayed) { + fasterPaymentsWarningDisplayed = true; + UserThread.runAfter(() -> GUIUtil.showFasterPaymentsWarning(navigation), 500, TimeUnit.MILLISECONDS); } } @@ -505,6 +514,7 @@ protected void onPaymentAccountsComboBoxSelected() { PaymentAccount paymentAccount = paymentAccountsComboBox.getSelectionModel().getSelectedItem(); if (paymentAccount != null) { maybeShowClearXchangeWarning(paymentAccount); + maybeShowFasterPaymentsWarning(paymentAccount); currencySelection.setVisible(paymentAccount.hasMultipleCurrencies()); currencySelection.setManaged(paymentAccount.hasMultipleCurrencies()); diff --git a/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferView.java b/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferView.java index 324dc3ceb07..94f35caaca7 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferView.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferView.java @@ -51,6 +51,7 @@ import bisq.core.locale.Res; import bisq.core.offer.Offer; import bisq.core.offer.OfferPayload; +import bisq.core.payment.FasterPaymentsAccount; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.PaymentMethod; import bisq.core.user.DontShowAgainLookup; @@ -159,7 +160,7 @@ public class TakeOfferView extends ActivatableViewAndModel amountFocusedListener, getShowWalletFundedNotificationListener; private InfoInputTextField volumeInfoTextField; @@ -283,14 +284,14 @@ protected void activate() { priceDescriptionLabel.setText(CurrencyUtil.getPriceWithCurrencyCode(currencyCode)); volumeDescriptionLabel.setText(model.volumeDescriptionLabel.get()); - if (model.getPossiblePaymentAccounts().size() > 1) { + PaymentAccount lastPaymentAccount = model.getLastSelectedPaymentAccount(); + if (model.getPossiblePaymentAccounts().size() > 1) { new Popup().headLine(Res.get("popup.info.multiplePaymentAccounts.headline")) .information(Res.get("popup.info.multiplePaymentAccounts.msg")) .dontShowAgainId("MultiplePaymentAccountsAvailableWarning") .show(); - PaymentAccount lastPaymentAccount = model.getLastSelectedPaymentAccount(); paymentAccountsComboBox.setItems(model.getPossiblePaymentAccounts()); paymentAccountsComboBox.getSelectionModel().select(lastPaymentAccount); model.onPaymentAccountSelected(lastPaymentAccount); @@ -299,7 +300,8 @@ protected void activate() { balanceTextField.setTargetAmount(model.dataModel.getTotalToPayAsCoin().get()); - maybeShowClearXchangeWarning(); + maybeShowClearXchangeWarning(lastPaymentAccount); + maybeShowFasterPaymentsWarning(lastPaymentAccount); if (!DevEnv.isDaoActivated() && !model.isRange()) { nextButton.setVisible(false); @@ -647,7 +649,6 @@ private void removeBindings() { takeOfferButton.disableProperty().unbind(); } - @SuppressWarnings("PointlessBooleanExpression") private void addSubscriptions() { errorPopupDisplayed = new SimpleBooleanProperty(); offerWarningSubscription = EasyBind.subscribe(model.offerWarning, newValue -> { @@ -712,29 +713,27 @@ private void addSubscriptions() { }); showTransactionPublishedScreenSubscription = EasyBind.subscribe(model.showTransactionPublishedScreen, newValue -> { - //noinspection ConstantConditions if (newValue && DevEnv.isDevMode()) { close(); - } else //noinspection ConstantConditions,ConstantConditions - if (newValue && model.getTrade() != null && !model.getTrade().hasFailed()) { - String key = "takeOfferSuccessInfo"; - if (DontShowAgainLookup.showAgain(key)) { - UserThread.runAfter(() -> new Popup().headLine(Res.get("takeOffer.success.headline")) - .feedback(Res.get("takeOffer.success.info")) - .actionButtonTextWithGoTo("navigation.portfolio.pending") - .dontShowAgainId(key) - .onAction(() -> { - UserThread.runAfter( - () -> navigation.navigateTo(MainView.class, PortfolioView.class, PendingTradesView.class) - , 100, TimeUnit.MILLISECONDS); - close(); - }) - .onClose(this::close) - .show(), 1); - } else { - close(); - } + } else if (newValue && model.getTrade() != null && !model.getTrade().hasFailed()) { + String key = "takeOfferSuccessInfo"; + if (DontShowAgainLookup.showAgain(key)) { + UserThread.runAfter(() -> new Popup().headLine(Res.get("takeOffer.success.headline")) + .feedback(Res.get("takeOffer.success.info")) + .actionButtonTextWithGoTo("navigation.portfolio.pending") + .dontShowAgainId(key) + .onAction(() -> { + UserThread.runAfter( + () -> navigation.navigateTo(MainView.class, PortfolioView.class, PendingTradesView.class) + , 100, TimeUnit.MILLISECONDS); + close(); + }) + .onClose(this::close) + .show(), 1); + } else { + close(); } + } }); /* noSufficientFeeBinding = EasyBind.combine(model.dataModel.getIsWalletFunded(), model.dataModel.isMainNet, model.dataModel.isFeeFromFundingTxSufficient, @@ -837,8 +836,12 @@ private void addPaymentGroup() { paymentAccountsComboBox.setVisible(false); paymentAccountsComboBox.setManaged(false); paymentAccountsComboBox.setOnAction(e -> { - maybeShowClearXchangeWarning(); - model.onPaymentAccountSelected(paymentAccountsComboBox.getSelectionModel().getSelectedItem()); + PaymentAccount paymentAccount = paymentAccountsComboBox.getSelectionModel().getSelectedItem(); + if (paymentAccount != null) { + maybeShowClearXchangeWarning(paymentAccount); + maybeShowFasterPaymentsWarning(paymentAccount); + } + model.onPaymentAccountSelected(paymentAccount); }); paymentMethodLabel = paymentAccountTuple.second; @@ -898,9 +901,7 @@ private void addButtons() { nextButton = tuple.first; nextButton.setMaxWidth(200); nextButton.setDefaultButton(true); - nextButton.setOnAction(e -> { - showNextStepAfterAmountIsSet(); - }); + nextButton.setOnAction(e -> showNextStepAfterAmountIsSet()); cancelButton1 = tuple.second; cancelButton1.setMaxWidth(200); @@ -1236,12 +1237,20 @@ else if (model.dataModel.getBsqBalance().isZero()) .show(); } - private void maybeShowClearXchangeWarning() { - if (model.getPaymentMethod().getId().equals(PaymentMethod.CLEAR_X_CHANGE_ID) && + private void maybeShowClearXchangeWarning(PaymentAccount paymentAccount) { + if (paymentAccount.getPaymentMethod().getId().equals(PaymentMethod.CLEAR_X_CHANGE_ID) && !clearXchangeWarningDisplayed) { clearXchangeWarningDisplayed = true; - UserThread.runAfter(GUIUtil::showClearXchangeWarning, - 500, TimeUnit.MILLISECONDS); + UserThread.runAfter(GUIUtil::showClearXchangeWarning, 500, TimeUnit.MILLISECONDS); + } + } + + private void maybeShowFasterPaymentsWarning(PaymentAccount paymentAccount) { + if (paymentAccount.getPaymentMethod().getId().equals(PaymentMethod.FASTER_PAYMENTS_ID) && + ((FasterPaymentsAccount) paymentAccount).getHolderName().isEmpty() && + !fasterPaymentsWarningDisplayed) { + fasterPaymentsWarningDisplayed = true; + UserThread.runAfter(() -> GUIUtil.showFasterPaymentsWarning(navigation), 500, TimeUnit.MILLISECONDS); } } diff --git a/desktop/src/main/java/bisq/desktop/util/GUIUtil.java b/desktop/src/main/java/bisq/desktop/util/GUIUtil.java index fbab24cc684..fb66e3f3a00 100644 --- a/desktop/src/main/java/bisq/desktop/util/GUIUtil.java +++ b/desktop/src/main/java/bisq/desktop/util/GUIUtil.java @@ -170,7 +170,9 @@ public static void setPreferences(Preferences preferences) { GUIUtil.preferences = preferences; } - public static String getUserLanguage() { return preferences.getUserLanguage(); } + public static String getUserLanguage() { + return preferences.getUserLanguage(); + } public static double getScrollbarWidth(Node scrollablePane) { Node node = scrollablePane.lookup(".scroll-bar"); @@ -700,6 +702,20 @@ public static void showClearXchangeWarning() { .show(); } + public static void showFasterPaymentsWarning(Navigation navigation) { + String key = "recreateFasterPaymentsAccount"; + String currencyName = Config.baseCurrencyNetwork().getCurrencyName(); + new Popup().information(Res.get("payment.fasterPayments.newRequirements.info", currencyName)) + .width(900) + .actionButtonTextWithGoTo("navigation.account") + .onAction(() -> { + navigation.setReturnPath(navigation.getCurrentPath()); + navigation.navigateTo(MainView.class, AccountView.class, FiatAccountsView.class); + }) + .dontShowAgainId(key) + .show(); + } + public static String getBitcoinURI(String address, Coin amount, String label) { return address != null ? BitcoinURI.convertToBitcoinURI(Address.fromBase58(Config.baseCurrencyNetworkParameters(), From d84130ff5b82b4a236ad4b540e975db566f23f80 Mon Sep 17 00:00:00 2001 From: Steven Barclay Date: Fri, 27 Mar 2020 14:10:37 +0800 Subject: [PATCH 4/4] Improve popup text + layout of Faster Payments buyer form fields Display the account number on the same row as the sort code in the trade step view, to prevent scrolling with the extra name field (as suggested in the code review). (This also affects the layout of old accounts without the extra field.) Also apply the suggested popup text simplifications. --- .../resources/i18n/displayStrings.properties | 20 +++++++++---------- .../paymentmethods/FasterPaymentsForm.java | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index ec49d08dcf3..cbabec0c54c 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -621,10 +621,9 @@ portfolio.pending.step2_buyer.halCashInfo.headline=Send HalCash code portfolio.pending.step2_buyer.halCashInfo.msg=You need to send a text message with the HalCash code as well as the \ trade ID ({0}) to the BTC seller.\nThe seller''s mobile nr. is {1}.\n\n\ Did you send the code to the seller? -portfolio.pending.step2_buyer.fasterPaymentsHolderNameInfo=Some banks might require the receiver's name. \ - The UK sort code and account number used to be sufficient for a Faster Payment transfer, but since then some banks \ - have started verifying the receiver's name. For this reason, accounts created in old Bisq clients do not provide the \ - trade partner with an owner full name. Please use trade chat to avoid any issues in such cases. +portfolio.pending.step2_buyer.fasterPaymentsHolderNameInfo=Some banks might verify the receiver's name. \ + Faster Payments accounts created in old Bisq clients do not provide the receiver's name, \ + so please use trade chat to obtain it (if needed). portfolio.pending.step2_buyer.confirmStart.headline=Confirm that you have started the payment portfolio.pending.step2_buyer.confirmStart.msg=Did you initiate the {0} payment to your trading partner? portfolio.pending.step2_buyer.confirmStart.yes=Yes, I have started the payment @@ -3020,13 +3019,12 @@ If you have not fulfilled the above requirements you will lose your security dep For the {0} seller it is highly recommended \ to get in contact with the {1} buyer by using the provided email address or mobile number to verify that he or she \ is really the owner of the Zelle (ClearXchange) account. -payment.fasterPayments.newRequirements.info=When using Faster Payments some banks have started verifying the receiver''s \ - full name. Your current Faster Payments account only specifies a UK bank account number and sort code. This used to be \ - sufficient, but may not be now for some sender''s banks. New Faster Payments accounts in Bisq now include an owner \ - full name. Please consider recreating your account in Bisq to provide future {0} buyers with a recipient name.\n\n\ - When recreating a Faster Payments account, take care to copy the account age verification salt from your old account \ - and use the same sort code and account number. (The owner full name or account name need not be the same, however.) \ - This preserves the public hash, so that the new account need not be aged or signed from scratch. +payment.fasterPayments.newRequirements.info=Some banks have started verifying the receiver''s full name for Faster \ + Payments transfers. Your current Faster Payments account does not specify a full name.\n\n\ + Please consider recreating your Faster Payments account in Bisq to provide future {0} buyers with a full name.\n\n\ + When you recreate the account, make sure to copy the precise sort code, account number and account age verification \ + salt values from your old account to your new account. This will ensure your existing account''s age and signing \ + status are preserved. payment.moneyGram.info=When using MoneyGram the BTC buyer has to send the Authorisation number and a photo of the receipt by email to the BTC seller. \ The receipt must clearly show the seller's full name, country, state and the amount. The buyer will get displayed the seller's email in the trade process. payment.westernUnion.info=When using Western Union the BTC buyer has to send the MTCN (tracking number) and a photo of the receipt by email to the BTC seller. \ diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/FasterPaymentsForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/FasterPaymentsForm.java index 1e9028f71be..e431b1ce7ef 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/FasterPaymentsForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/FasterPaymentsForm.java @@ -51,7 +51,7 @@ public static int addFormForBuyer(GridPane gridPane, int gridRow, // do not translate as it is used in English only addCompactTopLabelTextField(gridPane, ++gridRow, UK_SORT_CODE, ((FasterPaymentsAccountPayload) paymentAccountPayload).getSortCode()); - addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.accountNr"), + addCompactTopLabelTextField(gridPane, gridRow, 1, Res.get("payment.accountNr"), ((FasterPaymentsAccountPayload) paymentAccountPayload).getAccountNr()); return gridRow; }