mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-05 05:04:15 -04:00
Tests for Payment accounts matches
This commit is contained in:
parent
94288021dd
commit
44445cd411
50 changed files with 863 additions and 236 deletions
|
@ -44,7 +44,7 @@ public class AlertManager {
|
|||
private final ObjectProperty<Alert> alertMessageProperty = new SimpleObjectProperty<>();
|
||||
|
||||
// Pub key for developer global alert message
|
||||
private static final String devPubKeyAsHex = "02682880ae61fc1ea9375198bf2b5594fc3ed28074d3f5f0ed907e38acc5fb1fdc";
|
||||
private static final String pubKeyAsHex = "036d8a1dfcb406886037d2381da006358722823e1940acc2598c844bbc0fd1026f";
|
||||
private ECKey alertSigningKey;
|
||||
|
||||
|
||||
|
@ -116,7 +116,7 @@ public class AlertManager {
|
|||
private boolean isKeyValid(String privKeyString) {
|
||||
try {
|
||||
alertSigningKey = ECKey.fromPrivate(new BigInteger(1, HEX.decode(privKeyString)));
|
||||
return devPubKeyAsHex.equals(Utils.HEX.encode(alertSigningKey.getPubKey()));
|
||||
return pubKeyAsHex.equals(Utils.HEX.encode(alertSigningKey.getPubKey()));
|
||||
} catch (Throwable t) {
|
||||
return false;
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ public class AlertManager {
|
|||
private boolean verifySignature(Alert alert) {
|
||||
String alertMessageAsHex = Utils.HEX.encode(alert.message.getBytes());
|
||||
try {
|
||||
ECKey.fromPublicOnly(HEX.decode(devPubKeyAsHex)).verifyMessage(alertMessageAsHex, alert.getSignatureAsBase64());
|
||||
ECKey.fromPublicOnly(HEX.decode(pubKeyAsHex)).verifyMessage(alertMessageAsHex, alert.getSignatureAsBase64());
|
||||
return true;
|
||||
} catch (SignatureException e) {
|
||||
log.warn("verifySignature failed");
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
package io.bitsquare.arbitration;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.name.Named;
|
||||
import io.bitsquare.app.ProgramArguments;
|
||||
import io.bitsquare.common.Timer;
|
||||
import io.bitsquare.common.UserThread;
|
||||
import io.bitsquare.common.crypto.KeyRing;
|
||||
|
@ -63,13 +61,11 @@ public class ArbitratorManager {
|
|||
private static final long RETRY_REPUBLISH_SEC = 5;
|
||||
private static final long REPEATED_REPUBLISH_AT_STARTUP_SEC = 60;
|
||||
|
||||
private static final String publicKeyForTesting = "027a381b5333a56e1cc3d90d3a7d07f26509adf7029ed06fc997c656621f8da1ee";
|
||||
|
||||
// Keys for invited arbitrators in bootstrapping phase (before registration is open to anyone and security payment is implemented)
|
||||
// For testing purpose here is a private key so anyone can setup an arbitrator for now.
|
||||
// The matching pubkey will be removed once we use real arbitrators.
|
||||
// PrivKey for testing: 6ac43ea1df2a290c1c8391736aa42e4339c5cb4f110ff0257a13b63211977b7a
|
||||
// Matching pubKey: 027a381b5333a56e1cc3d90d3a7d07f26509adf7029ed06fc997c656621f8da1ee
|
||||
// For developers we add here 2 test keys so one can setup an arbitrator by adding that test pubKey
|
||||
// to the publicKeys list and use the test PrivKey for arbitrator registration.
|
||||
// PrivKey for dev testing: 6ac43ea1df2a290c1c8391736aa42e4339c5cb4f110ff0257a13b63211977b7a
|
||||
// Matching pubKey for dev testing: 027a381b5333a56e1cc3d90d3a7d07f26509adf7029ed06fc997c656621f8da1ee
|
||||
private static final List<String> publicKeys = new ArrayList<>(Arrays.asList(
|
||||
"03697a499d24f497b3c46bf716318231e46c4e6a685a4e122d8e2a2b229fa1f4b8",
|
||||
"0365c6af94681dbee69de1851f98d4684063bf5c2d64b1c73ed5d90434f375a054",
|
||||
|
@ -87,8 +83,7 @@ public class ArbitratorManager {
|
|||
"03df837a3a0f3d858e82f3356b71d1285327f101f7c10b404abed2abc1c94e7169",
|
||||
"0203a90fb2ab698e524a5286f317a183a84327b8f8c3f7fa4a98fec9e1cefd6b72",
|
||||
"023c99cc073b851c892d8c43329ca3beb5d2213ee87111af49884e3ce66cbd5ba5",
|
||||
"0274f772a98d23e7a0251ab30d7121897b5aebd11a2f1e45ab654aa57503173245",
|
||||
"036d8a1dfcb406886037d2381da006358722823e1940acc2598c844bbc0fd1026f"
|
||||
"0274f772a98d23e7a0251ab30d7121897b5aebd11a2f1e45ab654aa57503173245"
|
||||
));
|
||||
|
||||
|
||||
|
@ -100,7 +95,6 @@ public class ArbitratorManager {
|
|||
private final ArbitratorService arbitratorService;
|
||||
private final User user;
|
||||
private final ObservableMap<NodeAddress, Arbitrator> arbitratorsObservableMap = FXCollections.observableHashMap();
|
||||
private final boolean isDevTest;
|
||||
private BootstrapListener bootstrapListener;
|
||||
private Timer republishArbitratorTimer, retryRepublishArbitratorTimer;
|
||||
|
||||
|
@ -110,8 +104,7 @@ public class ArbitratorManager {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public ArbitratorManager(@Named(ProgramArguments.DEV_TEST) boolean isDevTest, KeyRing keyRing, ArbitratorService arbitratorService, User user) {
|
||||
this.isDevTest = isDevTest;
|
||||
public ArbitratorManager(KeyRing keyRing, ArbitratorService arbitratorService, User user) {
|
||||
this.keyRing = keyRing;
|
||||
this.arbitratorService = arbitratorService;
|
||||
this.user = user;
|
||||
|
@ -242,7 +235,7 @@ public class ArbitratorManager {
|
|||
}
|
||||
|
||||
public boolean isPublicKeyInList(String pubKeyAsHex) {
|
||||
return isDevTest && pubKeyAsHex.equals(publicKeyForTesting) || publicKeys.contains(pubKeyAsHex);
|
||||
return publicKeys.contains(pubKeyAsHex);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,9 +18,7 @@
|
|||
package io.bitsquare.arbitration;
|
||||
|
||||
import com.google.inject.Singleton;
|
||||
import com.google.inject.name.Names;
|
||||
import io.bitsquare.app.AppModule;
|
||||
import io.bitsquare.app.ProgramArguments;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
@ -37,8 +35,5 @@ public class ArbitratorModule extends AppModule {
|
|||
bind(ArbitratorManager.class).in(Singleton.class);
|
||||
bind(DisputeManager.class).in(Singleton.class);
|
||||
bind(ArbitratorService.class).in(Singleton.class);
|
||||
|
||||
Boolean devTest = env.getProperty(ProgramArguments.DEV_TEST, boolean.class, false);
|
||||
bind(boolean.class).annotatedWith(Names.named(ProgramArguments.DEV_TEST)).toInstance(devTest);
|
||||
}
|
||||
}
|
||||
|
|
5
core/src/main/java/io/bitsquare/payment/BankAccount.java
Normal file
5
core/src/main/java/io/bitsquare/payment/BankAccount.java
Normal file
|
@ -0,0 +1,5 @@
|
|||
package io.bitsquare.payment;
|
||||
|
||||
public interface BankAccount {
|
||||
String getBankId();
|
||||
}
|
|
@ -23,7 +23,9 @@ import io.bitsquare.locale.CountryUtil;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public abstract class BankAccountContractData extends PaymentAccountContractData {
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class BankAccountContractData extends CountryBasedPaymentAccountContractData {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||
|
||||
|
@ -34,7 +36,9 @@ public abstract class BankAccountContractData extends PaymentAccountContractData
|
|||
protected String bankId;
|
||||
protected String branchId;
|
||||
protected String accountNr;
|
||||
protected String holderId;
|
||||
|
||||
@Nullable
|
||||
protected String holderTaxId;
|
||||
|
||||
public BankAccountContractData(String paymentMethod, String id, int maxTradePeriod) {
|
||||
super(paymentMethod, id, maxTradePeriod);
|
||||
|
@ -47,7 +51,7 @@ public abstract class BankAccountContractData extends PaymentAccountContractData
|
|||
|
||||
@Override
|
||||
public String getPaymentDetailsForTradePopup() {
|
||||
String holderIdString = BankUtil.requiresHolderId(countryCode) ? (getHolderIdLabel() + ": " + holderId + "\n") : "";
|
||||
String holderIdString = BankUtil.requiresHolderId(countryCode) ? (getHolderIdLabel() + ": " + holderTaxId + "\n") : "";
|
||||
return "Holder name: " + holderName + "\n" +
|
||||
"Bank name: " + bankName + "\n" +
|
||||
"Bank Nr.: " + bankId + "\n" +
|
||||
|
@ -98,12 +102,13 @@ public abstract class BankAccountContractData extends PaymentAccountContractData
|
|||
this.accountNr = accountNr;
|
||||
}
|
||||
|
||||
public String getHolderId() {
|
||||
return holderId;
|
||||
@Nullable
|
||||
public String getHolderTaxId() {
|
||||
return holderTaxId;
|
||||
}
|
||||
|
||||
public void setHolderId(String holderId) {
|
||||
this.holderId = holderId;
|
||||
public void setHolderTaxId(String holderTaxId) {
|
||||
this.holderTaxId = holderTaxId;
|
||||
}
|
||||
|
||||
public String getHolderIdLabel() {
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package io.bitsquare.payment;
|
||||
|
||||
public interface BankNameRestrictedBankAccount extends BankAccount {
|
||||
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* This file is part of Bitsquare.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.payment;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.locale.Country;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class CountryBasedPaymentAccount extends PaymentAccount {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(CountryBasedPaymentAccount.class);
|
||||
|
||||
@Nullable
|
||||
protected Country country;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
protected CountryBasedPaymentAccount(PaymentMethod paymentMethod) {
|
||||
super(paymentMethod);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Getter, Setter
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@Nullable
|
||||
public Country getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(@NotNull Country country) {
|
||||
this.country = country;
|
||||
((CountryBasedPaymentAccountContractData) contractData).setCountryCode(country.code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof CountryBasedPaymentAccount)) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
CountryBasedPaymentAccount that = (CountryBasedPaymentAccount) o;
|
||||
|
||||
return !(country != null ? !country.equals(that.country) : that.country != null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + (country != null ? country.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CountryBasedPaymentAccount{" +
|
||||
"country=" + country +
|
||||
"} " + super.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* This file is part of Bitsquare.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.payment;
|
||||
|
||||
import io.bitsquare.app.Version;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class CountryBasedPaymentAccountContractData extends PaymentAccountContractData {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||
|
||||
@Nullable
|
||||
protected String countryCode;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CountryBasedPaymentAccountContractData(String paymentMethodName, String id, int maxTradePeriod) {
|
||||
super(paymentMethodName, id, maxTradePeriod);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Getter, Setter
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void setCountryCode(@NotNull String countryCode) {
|
||||
this.countryCode = countryCode;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getCountryCode() {
|
||||
return countryCode;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Getter
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
abstract public String getPaymentDetails();
|
||||
|
||||
abstract public String getPaymentDetailsForTradePopup();
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof CountryBasedPaymentAccountContractData)) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
CountryBasedPaymentAccountContractData that = (CountryBasedPaymentAccountContractData) o;
|
||||
|
||||
return countryCode.equals(that.countryCode);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + countryCode.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CountryBasedPaymentAccountContractData{" +
|
||||
"countryCode='" + countryCode + '\'' +
|
||||
"} " + super.toString();
|
||||
}
|
||||
}
|
|
@ -19,26 +19,26 @@ package io.bitsquare.payment;
|
|||
|
||||
import io.bitsquare.app.Version;
|
||||
|
||||
public final class BlockChainAccount extends PaymentAccount {
|
||||
public final class CryptoCurrencyAccount extends PaymentAccount {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
|
||||
public BlockChainAccount() {
|
||||
public CryptoCurrencyAccount() {
|
||||
super(PaymentMethod.BLOCK_CHAINS);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PaymentAccountContractData setContractData() {
|
||||
return new BlockChainAccountContractData(paymentMethod.getId(), id, paymentMethod.getMaxTradePeriod());
|
||||
return new CryptoCurrencyAccountContractData(paymentMethod.getId(), id, paymentMethod.getMaxTradePeriod());
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
((BlockChainAccountContractData) contractData).setAddress(address);
|
||||
((CryptoCurrencyAccountContractData) contractData).setAddress(address);
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return ((BlockChainAccountContractData) contractData).getAddress();
|
||||
return ((CryptoCurrencyAccountContractData) contractData).getAddress();
|
||||
}
|
||||
}
|
|
@ -19,15 +19,19 @@ package io.bitsquare.payment;
|
|||
|
||||
import io.bitsquare.app.Version;
|
||||
|
||||
public final class BlockChainAccountContractData extends PaymentAccountContractData {
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class CryptoCurrencyAccountContractData extends PaymentAccountContractData {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||
|
||||
private String address;
|
||||
// used in crypto note coins. not supported now but hopefully in future, so leave it for now.
|
||||
// used in crypto note coins. not supported now but hopefully in future, so leave it for now to avoid
|
||||
// incompatibility from serialized data.
|
||||
@Nullable
|
||||
private String paymentId;
|
||||
|
||||
public BlockChainAccountContractData(String paymentMethod, String id, int maxTradePeriod) {
|
||||
public CryptoCurrencyAccountContractData(String paymentMethod, String id, int maxTradePeriod) {
|
||||
super(paymentMethod, id, maxTradePeriod);
|
||||
}
|
||||
|
||||
|
@ -49,10 +53,11 @@ public final class BlockChainAccountContractData extends PaymentAccountContractD
|
|||
return getPaymentDetails();
|
||||
}
|
||||
|
||||
public void setPaymentId(String paymentId) {
|
||||
public void setPaymentId(@Nullable String paymentId) {
|
||||
this.paymentId = paymentId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPaymentId() {
|
||||
return paymentId;
|
||||
}
|
|
@ -19,7 +19,7 @@ package io.bitsquare.payment;
|
|||
|
||||
import io.bitsquare.app.Version;
|
||||
|
||||
public final class NationalBankAccount extends PaymentAccount {
|
||||
public final class NationalBankAccount extends CountryBasedPaymentAccount implements SameCountryRestrictedBankAccount {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
|
@ -31,4 +31,14 @@ public final class NationalBankAccount extends PaymentAccount {
|
|||
protected PaymentAccountContractData setContractData() {
|
||||
return new NationalBankAccountContractData(paymentMethod.getId(), id, paymentMethod.getMaxTradePeriod());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBankId() {
|
||||
return ((BankAccountContractData) contractData).getBankId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCountryCode() {
|
||||
return getCountry() != null ? getCountry().code : "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import io.bitsquare.locale.CurrencyUtil;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
//TODO missing support for selected trade currency
|
||||
public final class OKPayAccount extends PaymentAccount {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
|
|
@ -25,6 +25,8 @@ public final class OKPayAccountContractData extends PaymentAccountContractData {
|
|||
|
||||
private String accountNr;
|
||||
|
||||
// TODO refactor PaymentAccountContractData to avoid null values (countryCode, country, selectedTradeCountry)
|
||||
|
||||
public OKPayAccountContractData(String paymentMethod, String id, int maxTradePeriod) {
|
||||
super(paymentMethod, id, maxTradePeriod);
|
||||
}
|
||||
|
|
|
@ -19,12 +19,10 @@ package io.bitsquare.payment;
|
|||
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.persistance.Persistable;
|
||||
import io.bitsquare.locale.Country;
|
||||
import io.bitsquare.locale.TradeCurrency;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -42,8 +40,6 @@ public abstract class PaymentAccount implements Persistable {
|
|||
protected String accountName;
|
||||
final List<TradeCurrency> tradeCurrencies = new ArrayList<>();
|
||||
protected TradeCurrency selectedTradeCurrency;
|
||||
@Nullable
|
||||
protected Country country = null;
|
||||
public final PaymentAccountContractData contractData;
|
||||
|
||||
|
||||
|
@ -97,7 +93,7 @@ public abstract class PaymentAccount implements Persistable {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
protected abstract PaymentAccountContractData setContractData();
|
||||
|
||||
|
||||
public String getAccountName() {
|
||||
return accountName;
|
||||
}
|
||||
|
@ -106,16 +102,6 @@ public abstract class PaymentAccount implements Persistable {
|
|||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Country getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(Country country) {
|
||||
this.country = country;
|
||||
contractData.setCountryCode(country.code);
|
||||
}
|
||||
|
||||
public void setSelectedTradeCurrency(TradeCurrency tradeCurrency) {
|
||||
selectedTradeCurrency = tradeCurrency;
|
||||
}
|
||||
|
@ -158,21 +144,47 @@ public abstract class PaymentAccount implements Persistable {
|
|||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Util
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof PaymentAccount)) return false;
|
||||
|
||||
PaymentAccount that = (PaymentAccount) o;
|
||||
|
||||
if (id != null ? !id.equals(that.id) : that.id != null) return false;
|
||||
if (creationDate != null ? !creationDate.equals(that.creationDate) : that.creationDate != null) return false;
|
||||
if (paymentMethod != null ? !paymentMethod.equals(that.paymentMethod) : that.paymentMethod != null)
|
||||
return false;
|
||||
if (accountName != null ? !accountName.equals(that.accountName) : that.accountName != null) return false;
|
||||
if (tradeCurrencies != null ? !tradeCurrencies.equals(that.tradeCurrencies) : that.tradeCurrencies != null)
|
||||
return false;
|
||||
if (selectedTradeCurrency != null ? !selectedTradeCurrency.equals(that.selectedTradeCurrency) : that.selectedTradeCurrency != null)
|
||||
return false;
|
||||
return !(contractData != null ? !contractData.equals(that.contractData) : that.contractData != null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id != null ? id.hashCode() : 0;
|
||||
result = 31 * result + (creationDate != null ? creationDate.hashCode() : 0);
|
||||
result = 31 * result + (paymentMethod != null ? paymentMethod.hashCode() : 0);
|
||||
result = 31 * result + (accountName != null ? accountName.hashCode() : 0);
|
||||
result = 31 * result + (tradeCurrencies != null ? tradeCurrencies.hashCode() : 0);
|
||||
result = 31 * result + (selectedTradeCurrency != null ? selectedTradeCurrency.hashCode() : 0);
|
||||
result = 31 * result + (contractData != null ? contractData.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return contractData.toString() + '\'' +
|
||||
"PaymentAccount{" +
|
||||
return "PaymentAccount{" +
|
||||
"id='" + id + '\'' +
|
||||
", creationDate=" + creationDate +
|
||||
", paymentMethod=" + paymentMethod +
|
||||
", accountName='" + accountName + '\'' +
|
||||
", tradeCurrencies=" + tradeCurrencies +
|
||||
", selectedTradeCurrency=" + selectedTradeCurrency +
|
||||
", country=" + country +
|
||||
", contractData=" + contractData +
|
||||
'}';
|
||||
}
|
||||
|
|
|
@ -20,18 +20,13 @@ package io.bitsquare.payment;
|
|||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.common.wire.Payload;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class PaymentAccountContractData implements Payload {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||
|
||||
private final String paymentMethodName;
|
||||
private final String id;
|
||||
private final int maxTradePeriod;
|
||||
|
||||
@Nullable
|
||||
protected String countryCode;
|
||||
protected final String paymentMethodName;
|
||||
protected final String id;
|
||||
protected final int maxTradePeriod;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -44,20 +39,6 @@ public abstract class PaymentAccountContractData implements Payload {
|
|||
this.maxTradePeriod = maxTradePeriod;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Getter, Setter
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void setCountryCode(String countryCode) {
|
||||
this.countryCode = countryCode;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getCountryCode() {
|
||||
return countryCode;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Getter
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -78,6 +59,7 @@ public abstract class PaymentAccountContractData implements Payload {
|
|||
return maxTradePeriod;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -88,8 +70,7 @@ public abstract class PaymentAccountContractData implements Payload {
|
|||
if (maxTradePeriod != that.maxTradePeriod) return false;
|
||||
if (paymentMethodName != null ? !paymentMethodName.equals(that.paymentMethodName) : that.paymentMethodName != null)
|
||||
return false;
|
||||
if (id != null ? !id.equals(that.id) : that.id != null) return false;
|
||||
return !(countryCode != null ? !countryCode.equals(that.countryCode) : that.countryCode != null);
|
||||
return !(id != null ? !id.equals(that.id) : that.id != null);
|
||||
|
||||
}
|
||||
|
||||
|
@ -98,7 +79,15 @@ public abstract class PaymentAccountContractData implements Payload {
|
|||
int result = paymentMethodName != null ? paymentMethodName.hashCode() : 0;
|
||||
result = 31 * result + (id != null ? id.hashCode() : 0);
|
||||
result = 31 * result + maxTradePeriod;
|
||||
result = 31 * result + (countryCode != null ? countryCode.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PaymentAccountContractData{" +
|
||||
"paymentMethodName='" + paymentMethodName + '\'' +
|
||||
", id='" + id + '\'' +
|
||||
", maxTradePeriod=" + maxTradePeriod +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,13 +37,13 @@ public abstract class PaymentAccountFactory implements Persistable {
|
|||
case PaymentMethod.SAME_BANK_ID:
|
||||
return new SameBankAccount();
|
||||
case PaymentMethod.SPECIFIC_BANKS_ID:
|
||||
return new SpecificBankAccount();
|
||||
return new SpecificBanksAccount();
|
||||
case PaymentMethod.ALI_PAY_ID:
|
||||
return new AliPayAccount();
|
||||
case PaymentMethod.SWISH_ID:
|
||||
return new SwishAccount();
|
||||
case PaymentMethod.BLOCK_CHAINS_ID:
|
||||
return new BlockChainAccount();
|
||||
return new CryptoCurrencyAccount();
|
||||
default:
|
||||
throw new RuntimeException("Not supported PaymentMethod: " + paymentMethod);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package io.bitsquare.payment;
|
|||
|
||||
import io.bitsquare.app.Version;
|
||||
|
||||
public final class SameBankAccount extends PaymentAccount {
|
||||
public final class SameBankAccount extends CountryBasedPaymentAccount implements BankNameRestrictedBankAccount, SameCountryRestrictedBankAccount {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
|
@ -32,7 +32,13 @@ public final class SameBankAccount extends PaymentAccount {
|
|||
return new SameBankAccountContractData(paymentMethod.getId(), id, paymentMethod.getMaxTradePeriod());
|
||||
}
|
||||
|
||||
public String getAcceptedBank() {
|
||||
return ((SameBankAccountContractData) contractData).getBankName();
|
||||
@Override
|
||||
public String getBankId() {
|
||||
return ((BankAccountContractData) contractData).getBankId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCountryCode() {
|
||||
return getCountry() != null ? getCountry().code : "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package io.bitsquare.payment;
|
||||
|
||||
public interface SameCountryRestrictedBankAccount extends BankAccount {
|
||||
String getCountryCode();
|
||||
}
|
|
@ -21,7 +21,7 @@ import io.bitsquare.app.Version;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public final class SepaAccount extends PaymentAccount {
|
||||
public final class SepaAccount extends CountryBasedPaymentAccount implements BankAccount {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
|
@ -34,6 +34,11 @@ public final class SepaAccount extends PaymentAccount {
|
|||
return new SepaAccountContractData(paymentMethod.getId(), id, paymentMethod.getMaxTradePeriod());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBankId() {
|
||||
return ((SepaAccountContractData) contractData).getBic();
|
||||
}
|
||||
|
||||
public void setHolderName(String holderName) {
|
||||
((SepaAccountContractData) contractData).setHolderName(holderName);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,8 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class SepaAccountContractData extends PaymentAccountContractData {
|
||||
// TODO refactor with BankAccountContractData
|
||||
public final class SepaAccountContractData extends CountryBasedPaymentAccountContractData {
|
||||
// That object is sent over the wire, so we need to take care of version compatibility.
|
||||
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
|
||||
|
||||
|
|
|
@ -21,11 +21,11 @@ import io.bitsquare.app.Version;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public final class SpecificBankAccount extends PaymentAccount {
|
||||
public final class SpecificBanksAccount extends CountryBasedPaymentAccount implements BankNameRestrictedBankAccount, SameCountryRestrictedBankAccount {
|
||||
// That object is saved to disc. We need to take care of changes to not break deserialization.
|
||||
private static final long serialVersionUID = Version.LOCAL_DB_VERSION;
|
||||
|
||||
public SpecificBankAccount() {
|
||||
public SpecificBanksAccount() {
|
||||
super(PaymentMethod.SPECIFIC_BANKS);
|
||||
}
|
||||
|
||||
|
@ -37,4 +37,14 @@ public final class SpecificBankAccount extends PaymentAccount {
|
|||
public ArrayList<String> getAcceptedBanks() {
|
||||
return ((SpecificBanksAccountContractData) contractData).getAcceptedBanks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBankId() {
|
||||
return ((SpecificBanksAccountContractData) contractData).getBankId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCountryCode() {
|
||||
return getCountry() != null ? getCountry().code : "";
|
||||
}
|
||||
}
|
|
@ -62,7 +62,7 @@ public final class SpecificBanksAccountContractData extends BankAccountContractD
|
|||
|
||||
@Override
|
||||
public String getPaymentDetailsForTradePopup() {
|
||||
String holderIdString = BankUtil.requiresHolderId(countryCode) ? (getHolderIdLabel() + ": " + holderId + "\n") : "";
|
||||
String holderIdString = BankUtil.requiresHolderId(countryCode) ? (getHolderIdLabel() + ": " + holderTaxId + "\n") : "";
|
||||
return "Holder name: " + holderName + "\n" +
|
||||
holderIdString +
|
||||
"Bank name: " + bankName + "\n" +
|
||||
|
|
|
@ -23,7 +23,6 @@ import io.bitsquare.common.crypto.KeyRing;
|
|||
import io.bitsquare.common.crypto.PubKeyRing;
|
||||
import io.bitsquare.common.handlers.ResultHandler;
|
||||
import io.bitsquare.common.util.JsonExclude;
|
||||
import io.bitsquare.locale.Country;
|
||||
import io.bitsquare.p2p.NodeAddress;
|
||||
import io.bitsquare.p2p.storage.payload.RequiresOwnerIsOnlinePayload;
|
||||
import io.bitsquare.p2p.storage.payload.StoragePayload;
|
||||
|
@ -84,9 +83,26 @@ public final class Offer implements StoragePayload, RequiresOwnerIsOnlinePayload
|
|||
// Instance fields
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private final String id;
|
||||
|
||||
// Fields for filtering offers
|
||||
private final Direction direction;
|
||||
private final String currencyCode;
|
||||
// payment method
|
||||
private final String paymentMethodName;
|
||||
@Nullable
|
||||
private final String countryCode;
|
||||
@Nullable
|
||||
private final ArrayList<String> acceptedCountryCodes;
|
||||
|
||||
@Nullable
|
||||
private final String bankId;
|
||||
@Nullable
|
||||
private final ArrayList<String> acceptedBankIds;
|
||||
|
||||
private final ArrayList<NodeAddress> arbitratorNodeAddresses;
|
||||
|
||||
|
||||
private final String id;
|
||||
private final long date;
|
||||
private final long protocolVersion;
|
||||
private final long fiatPrice;
|
||||
|
@ -95,17 +111,8 @@ public final class Offer implements StoragePayload, RequiresOwnerIsOnlinePayload
|
|||
private final NodeAddress offererNodeAddress;
|
||||
@JsonExclude
|
||||
private final PubKeyRing pubKeyRing;
|
||||
private final String paymentMethodName;
|
||||
@Nullable
|
||||
private final String paymentMethodCountryCode;
|
||||
private final String offererPaymentAccountId;
|
||||
|
||||
@Nullable
|
||||
private final ArrayList<String> acceptedCountryCodes;
|
||||
@Nullable
|
||||
private final ArrayList<String> acceptedBanks;
|
||||
private final ArrayList<NodeAddress> arbitratorNodeAddresses;
|
||||
|
||||
// Mutable property. Has to be set before offer is save in P2P network as it changes the objects hash!
|
||||
private String offerFeePaymentTxID;
|
||||
|
||||
|
@ -133,13 +140,14 @@ public final class Offer implements StoragePayload, RequiresOwnerIsOnlinePayload
|
|||
long fiatPrice,
|
||||
long amount,
|
||||
long minAmount,
|
||||
String paymentMethodName,
|
||||
String currencyCode,
|
||||
@Nullable Country paymentMethodCountry,
|
||||
String offererPaymentAccountId,
|
||||
ArrayList<NodeAddress> arbitratorNodeAddresses,
|
||||
String paymentMethodName,
|
||||
String offererPaymentAccountId,
|
||||
@Nullable String countryCode,
|
||||
@Nullable ArrayList<String> acceptedCountryCodes,
|
||||
@Nullable ArrayList<String> acceptedBanks) {
|
||||
@Nullable String bankId,
|
||||
@Nullable ArrayList<String> acceptedBankIds) {
|
||||
this.id = id;
|
||||
this.offererNodeAddress = offererNodeAddress;
|
||||
this.pubKeyRing = pubKeyRing;
|
||||
|
@ -147,13 +155,14 @@ public final class Offer implements StoragePayload, RequiresOwnerIsOnlinePayload
|
|||
this.fiatPrice = fiatPrice;
|
||||
this.amount = amount;
|
||||
this.minAmount = minAmount;
|
||||
this.paymentMethodName = paymentMethodName;
|
||||
this.currencyCode = currencyCode;
|
||||
this.paymentMethodCountryCode = paymentMethodCountry != null ? paymentMethodCountry.code : null;
|
||||
this.offererPaymentAccountId = offererPaymentAccountId;
|
||||
this.arbitratorNodeAddresses = arbitratorNodeAddresses;
|
||||
this.paymentMethodName = paymentMethodName;
|
||||
this.offererPaymentAccountId = offererPaymentAccountId;
|
||||
this.countryCode = countryCode;
|
||||
this.acceptedCountryCodes = acceptedCountryCodes;
|
||||
this.acceptedBanks = acceptedBanks;
|
||||
this.bankId = bankId;
|
||||
this.acceptedBankIds = acceptedBankIds;
|
||||
|
||||
protocolVersion = Version.TRADE_PROTOCOL_VERSION;
|
||||
|
||||
|
@ -331,8 +340,8 @@ public final class Offer implements StoragePayload, RequiresOwnerIsOnlinePayload
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public String getPaymentMethodCountryCode() {
|
||||
return paymentMethodCountryCode;
|
||||
public String getCountryCode() {
|
||||
return countryCode;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -341,8 +350,13 @@ public final class Offer implements StoragePayload, RequiresOwnerIsOnlinePayload
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public List<String> getAcceptedBanks() {
|
||||
return acceptedBanks;
|
||||
public List<String> getAcceptedBankIds() {
|
||||
return acceptedBankIds;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getBankId() {
|
||||
return bankId;
|
||||
}
|
||||
|
||||
public String getOfferFeePaymentTxID() {
|
||||
|
@ -392,13 +406,14 @@ public final class Offer implements StoragePayload, RequiresOwnerIsOnlinePayload
|
|||
if (pubKeyRing != null ? !pubKeyRing.equals(offer.pubKeyRing) : offer.pubKeyRing != null) return false;
|
||||
if (paymentMethodName != null ? !paymentMethodName.equals(offer.paymentMethodName) : offer.paymentMethodName != null)
|
||||
return false;
|
||||
if (paymentMethodCountryCode != null ? !paymentMethodCountryCode.equals(offer.paymentMethodCountryCode) : offer.paymentMethodCountryCode != null)
|
||||
if (countryCode != null ? !countryCode.equals(offer.countryCode) : offer.countryCode != null)
|
||||
return false;
|
||||
if (offererPaymentAccountId != null ? !offererPaymentAccountId.equals(offer.offererPaymentAccountId) : offer.offererPaymentAccountId != null)
|
||||
return false;
|
||||
if (acceptedCountryCodes != null ? !acceptedCountryCodes.equals(offer.acceptedCountryCodes) : offer.acceptedCountryCodes != null)
|
||||
return false;
|
||||
if (acceptedBanks != null ? !acceptedBanks.equals(offer.acceptedBanks) : offer.acceptedBanks != null)
|
||||
if (bankId != null ? !bankId.equals(offer.bankId) : offer.bankId != null) return false;
|
||||
if (acceptedBankIds != null ? !acceptedBankIds.equals(offer.acceptedBankIds) : offer.acceptedBankIds != null)
|
||||
return false;
|
||||
if (arbitratorNodeAddresses != null ? !arbitratorNodeAddresses.equals(offer.arbitratorNodeAddresses) : offer.arbitratorNodeAddresses != null)
|
||||
return false;
|
||||
|
@ -418,10 +433,11 @@ public final class Offer implements StoragePayload, RequiresOwnerIsOnlinePayload
|
|||
result = 31 * result + (offererNodeAddress != null ? offererNodeAddress.hashCode() : 0);
|
||||
result = 31 * result + (pubKeyRing != null ? pubKeyRing.hashCode() : 0);
|
||||
result = 31 * result + (paymentMethodName != null ? paymentMethodName.hashCode() : 0);
|
||||
result = 31 * result + (paymentMethodCountryCode != null ? paymentMethodCountryCode.hashCode() : 0);
|
||||
result = 31 * result + (countryCode != null ? countryCode.hashCode() : 0);
|
||||
result = 31 * result + (bankId != null ? bankId.hashCode() : 0);
|
||||
result = 31 * result + (offererPaymentAccountId != null ? offererPaymentAccountId.hashCode() : 0);
|
||||
result = 31 * result + (acceptedCountryCodes != null ? acceptedCountryCodes.hashCode() : 0);
|
||||
result = 31 * result + (acceptedBanks != null ? acceptedBanks.hashCode() : 0);
|
||||
result = 31 * result + (acceptedBankIds != null ? acceptedBankIds.hashCode() : 0);
|
||||
result = 31 * result + (arbitratorNodeAddresses != null ? arbitratorNodeAddresses.hashCode() : 0);
|
||||
result = 31 * result + (offerFeePaymentTxID != null ? offerFeePaymentTxID.hashCode() : 0);
|
||||
return result;
|
||||
|
@ -440,10 +456,11 @@ public final class Offer implements StoragePayload, RequiresOwnerIsOnlinePayload
|
|||
"\n\toffererAddress=" + offererNodeAddress +
|
||||
"\n\tpubKeyRing=" + pubKeyRing +
|
||||
"\n\tpaymentMethodName='" + paymentMethodName + '\'' +
|
||||
"\n\tpaymentMethodCountryCode='" + paymentMethodCountryCode + '\'' +
|
||||
"\n\tpaymentMethodCountryCode='" + countryCode + '\'' +
|
||||
"\n\toffererPaymentAccountId='" + offererPaymentAccountId + '\'' +
|
||||
"\n\tacceptedCountryCodes=" + acceptedCountryCodes +
|
||||
"\n\tacceptedBanks=" + acceptedBanks +
|
||||
"\n\tbankId=" + bankId +
|
||||
"\n\tacceptedBanks=" + acceptedBankIds +
|
||||
"\n\tarbitratorAddresses=" + arbitratorNodeAddresses +
|
||||
"\n\tofferFeePaymentTxID='" + offerFeePaymentTxID + '\'' +
|
||||
"\n\tstate=" + state +
|
||||
|
|
|
@ -20,7 +20,7 @@ package io.bitsquare.trade.protocol.trade.tasks.offerer;
|
|||
import io.bitsquare.common.crypto.Hash;
|
||||
import io.bitsquare.common.taskrunner.TaskRunner;
|
||||
import io.bitsquare.locale.CurrencyUtil;
|
||||
import io.bitsquare.payment.BlockChainAccountContractData;
|
||||
import io.bitsquare.payment.CryptoCurrencyAccountContractData;
|
||||
import io.bitsquare.payment.PaymentAccountContractData;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.protocol.trade.messages.PayDepositRequest;
|
||||
|
@ -64,10 +64,10 @@ public class ProcessPayDepositRequest extends TradeTask {
|
|||
PaymentAccountContractData paymentAccountContractData = checkNotNull(payDepositRequest.takerPaymentAccountContractData);
|
||||
processModel.tradingPeer.setPaymentAccountContractData(paymentAccountContractData);
|
||||
// We apply the payment ID in case its a cryptoNote coin. It is created form the hash of the trade ID
|
||||
if (paymentAccountContractData instanceof BlockChainAccountContractData &&
|
||||
if (paymentAccountContractData instanceof CryptoCurrencyAccountContractData &&
|
||||
CurrencyUtil.isCryptoNoteCoin(processModel.getOffer().getCurrencyCode())) {
|
||||
String paymentId = Hash.getHashAsHex(trade.getId()).substring(0, Math.min(32, trade.getId().length()));
|
||||
((BlockChainAccountContractData) paymentAccountContractData).setPaymentId(paymentId);
|
||||
((CryptoCurrencyAccountContractData) paymentAccountContractData).setPaymentId(paymentId);
|
||||
}
|
||||
|
||||
processModel.tradingPeer.setAccountId(nonEmptyStringOf(payDepositRequest.takerAccountId));
|
||||
|
|
|
@ -20,7 +20,7 @@ package io.bitsquare.trade.protocol.trade.tasks.taker;
|
|||
import io.bitsquare.common.crypto.Hash;
|
||||
import io.bitsquare.common.taskrunner.TaskRunner;
|
||||
import io.bitsquare.locale.CurrencyUtil;
|
||||
import io.bitsquare.payment.BlockChainAccountContractData;
|
||||
import io.bitsquare.payment.CryptoCurrencyAccountContractData;
|
||||
import io.bitsquare.payment.PaymentAccountContractData;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.protocol.trade.messages.PublishDepositTxRequest;
|
||||
|
@ -52,10 +52,10 @@ public class ProcessPublishDepositTxRequest extends TradeTask {
|
|||
PaymentAccountContractData paymentAccountContractData = checkNotNull(publishDepositTxRequest.offererPaymentAccountContractData);
|
||||
processModel.tradingPeer.setPaymentAccountContractData(paymentAccountContractData);
|
||||
// We apply the payment ID in case its a cryptoNote coin. It is created form the hash of the trade ID
|
||||
if (paymentAccountContractData instanceof BlockChainAccountContractData &&
|
||||
if (paymentAccountContractData instanceof CryptoCurrencyAccountContractData &&
|
||||
CurrencyUtil.isCryptoNoteCoin(processModel.getOffer().getCurrencyCode())) {
|
||||
String paymentId = Hash.getHashAsHex(trade.getId()).substring(0, Math.min(32, trade.getId().length()));
|
||||
((BlockChainAccountContractData) paymentAccountContractData).setPaymentId(paymentId);
|
||||
((CryptoCurrencyAccountContractData) paymentAccountContractData).setPaymentId(paymentId);
|
||||
}
|
||||
|
||||
processModel.tradingPeer.setAccountId(nonEmptyStringOf(publishDepositTxRequest.offererAccountId));
|
||||
|
|
|
@ -239,15 +239,17 @@ public final class User implements Persistable {
|
|||
}
|
||||
|
||||
public List<Arbitrator> getAcceptedArbitrators() {
|
||||
return acceptedArbitrators;
|
||||
return acceptedArbitrators != null ? acceptedArbitrators : new ArrayList<>();
|
||||
}
|
||||
|
||||
public List<NodeAddress> getAcceptedArbitratorAddresses() {
|
||||
return acceptedArbitrators.stream().map(Arbitrator::getArbitratorNodeAddress).collect(Collectors.toList());
|
||||
return acceptedArbitrators != null ?
|
||||
acceptedArbitrators.stream().map(Arbitrator::getArbitratorNodeAddress).collect(Collectors.toList()) :
|
||||
new ArrayList<>();
|
||||
}
|
||||
|
||||
public List<String> getAcceptedLanguageLocaleCodes() {
|
||||
return acceptedLanguageLocaleCodes;
|
||||
return acceptedLanguageLocaleCodes != null ? acceptedLanguageLocaleCodes : new ArrayList<>();
|
||||
}
|
||||
|
||||
/* public List<String> getArbitratorAddresses(List<String> idList) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue