Skip to content

Commit

Permalink
Remove payment ID for cryptoNote coins
Browse files Browse the repository at this point in the history
  • Loading branch information
ManfredKarrer committed May 25, 2016
1 parent 3a61409 commit b917d90
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 49 deletions.
4 changes: 0 additions & 4 deletions core/src/main/java/io/bitsquare/locale/CurrencyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,6 @@ public static Optional<CryptoCurrency> getCryptoCurrency(String currencyCode) {
return getAllSortedCryptoCurrencies().stream().filter(e -> e.getCode().equals(currencyCode)).findAny();
}

public static boolean isCryptoNoteCoin(String currencyCode) {
return currencyCode.equals("XMR") || currencyCode.equals("BCN");
}

public static FiatCurrency getCurrencyByCountryCode(String countryCode) {
return new FiatCurrency(Currency.getInstance(new Locale(LanguageUtil.getDefaultLanguage(), countryCode)).getCurrencyCode());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@

import io.bitsquare.app.Version;

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 to avoid
// incompatibility from serialized data.
@Nullable

// TODO Not needed. Remove when we have an update which breaks backward compatibility
private String paymentId;

public CryptoCurrencyAccountContractData(String paymentMethod, String id, long maxTradePeriod) {
Expand All @@ -52,13 +49,4 @@ public String getPaymentDetails() {
public String getPaymentDetailsForTradePopup() {
return getPaymentDetails();
}

public void setPaymentId(@Nullable String paymentId) {
this.paymentId = paymentId;
}

@Nullable
public String getPaymentId() {
return paymentId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,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.CryptoCurrencyAccountContractData;
import io.bitsquare.payment.PaymentAccountContractData;
import io.bitsquare.trade.Trade;
import io.bitsquare.trade.protocol.trade.messages.PayDepositRequest;
Expand Down Expand Up @@ -64,12 +61,6 @@ protected void run() {

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 CryptoCurrencyAccountContractData &&
CurrencyUtil.isCryptoNoteCoin(processModel.getOffer().getCurrencyCode())) {
String paymentId = Hash.getHashAsHex(trade.getId()).substring(0, Math.min(32, trade.getId().length()));
((CryptoCurrencyAccountContractData) paymentAccountContractData).setPaymentId(paymentId);
}

processModel.tradingPeer.setAccountId(nonEmptyStringOf(payDepositRequest.takerAccountId));
trade.setTakeOfferFeeTxId(nonEmptyStringOf(payDepositRequest.takeOfferFeeTxId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,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.CryptoCurrencyAccountContractData;
import io.bitsquare.payment.PaymentAccountContractData;
import io.bitsquare.trade.Trade;
import io.bitsquare.trade.protocol.trade.messages.PublishDepositTxRequest;
Expand Down Expand Up @@ -51,12 +48,6 @@ protected void run() {

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 CryptoCurrencyAccountContractData &&
CurrencyUtil.isCryptoNoteCoin(processModel.getOffer().getCurrencyCode())) {
String paymentId = Hash.getHashAsHex(trade.getId()).substring(0, Math.min(32, trade.getId().length()));
((CryptoCurrencyAccountContractData) paymentAccountContractData).setPaymentId(paymentId);
}

processModel.tradingPeer.setAccountId(nonEmptyStringOf(publishDepositTxRequest.offererAccountId));
processModel.tradingPeer.setMultiSigPubKey(checkNotNull(publishDepositTxRequest.offererMultiSigPubKey));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ public class CryptoCurrencyForm extends PaymentMethodForm {

public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountContractData paymentAccountContractData, String labelTitle) {
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, labelTitle, ((CryptoCurrencyAccountContractData) paymentAccountContractData).getAddress());
if (((CryptoCurrencyAccountContractData) paymentAccountContractData).getPaymentId() != null)
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "Payment ID:", ((CryptoCurrencyAccountContractData) paymentAccountContractData).getPaymentId());

return gridRow;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import io.bitsquare.gui.util.Layout;
import io.bitsquare.locale.BSResources;
import io.bitsquare.locale.CountryUtil;
import io.bitsquare.payment.CryptoCurrencyAccountContractData;
import io.bitsquare.payment.PaymentAccountContractData;
import io.bitsquare.payment.PaymentMethod;
import io.bitsquare.trade.Contract;
Expand Down Expand Up @@ -110,13 +109,7 @@ private void addContent() {
if (showAcceptedBanks)
rows++;

boolean isPaymentIdAvailable = false;
PaymentAccountContractData sellerPaymentAccountContractData = contract.getSellerPaymentAccountContractData();
if (sellerPaymentAccountContractData instanceof CryptoCurrencyAccountContractData &&
((CryptoCurrencyAccountContractData) sellerPaymentAccountContractData).getPaymentId() != null) {
rows++;
isPaymentIdAvailable = true;
}
addTitledGroupBg(gridPane, ++rowIndex, rows, "Contract");
addLabelTextFieldWithCopyIcon(gridPane, rowIndex, "Offer ID:", offer.getId(),
Layout.FIRST_ROW_DISTANCE).second.setMouseTransparent(false);
Expand All @@ -138,9 +131,6 @@ private void addContent() {
BSResources.get(contract.getBuyerPaymentAccountContractData().getPaymentDetails())).second.setMouseTransparent(false);
addLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, "Seller payment details:",
BSResources.get(sellerPaymentAccountContractData.getPaymentDetails())).second.setMouseTransparent(false);
if (isPaymentIdAvailable)
addLabelTextField(gridPane, ++rowIndex, "Seller payment ID:",
((CryptoCurrencyAccountContractData) sellerPaymentAccountContractData).getPaymentId());

if (showAcceptedCountryCodes) {
String countries;
Expand Down

0 comments on commit b917d90

Please sign in to comment.