From b917d90a70aa553fa78244a164a2eeeabebf95c3 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Wed, 25 May 2016 21:11:48 +0200 Subject: [PATCH] Remove payment ID for cryptoNote coins --- .../java/io/bitsquare/locale/CurrencyUtil.java | 4 ---- .../CryptoCurrencyAccountContractData.java | 16 ++-------------- .../tasks/offerer/ProcessPayDepositRequest.java | 9 --------- .../taker/ProcessPublishDepositTxRequest.java | 9 --------- .../paymentmethods/CryptoCurrencyForm.java | 3 --- .../main/overlays/windows/ContractWindow.java | 10 ---------- 6 files changed, 2 insertions(+), 49 deletions(-) diff --git a/core/src/main/java/io/bitsquare/locale/CurrencyUtil.java b/core/src/main/java/io/bitsquare/locale/CurrencyUtil.java index 13f7ae7171a..ad1895488ad 100644 --- a/core/src/main/java/io/bitsquare/locale/CurrencyUtil.java +++ b/core/src/main/java/io/bitsquare/locale/CurrencyUtil.java @@ -199,10 +199,6 @@ public static Optional 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()); } diff --git a/core/src/main/java/io/bitsquare/payment/CryptoCurrencyAccountContractData.java b/core/src/main/java/io/bitsquare/payment/CryptoCurrencyAccountContractData.java index e23808e91ed..de5189da32a 100644 --- a/core/src/main/java/io/bitsquare/payment/CryptoCurrencyAccountContractData.java +++ b/core/src/main/java/io/bitsquare/payment/CryptoCurrencyAccountContractData.java @@ -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) { @@ -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; - } } diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/tasks/offerer/ProcessPayDepositRequest.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/tasks/offerer/ProcessPayDepositRequest.java index 33f4cfc8129..359361f0223 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/tasks/offerer/ProcessPayDepositRequest.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/tasks/offerer/ProcessPayDepositRequest.java @@ -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; @@ -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)); diff --git a/core/src/main/java/io/bitsquare/trade/protocol/trade/tasks/taker/ProcessPublishDepositTxRequest.java b/core/src/main/java/io/bitsquare/trade/protocol/trade/tasks/taker/ProcessPublishDepositTxRequest.java index 8cbf762dde9..65b3e541e21 100644 --- a/core/src/main/java/io/bitsquare/trade/protocol/trade/tasks/taker/ProcessPublishDepositTxRequest.java +++ b/core/src/main/java/io/bitsquare/trade/protocol/trade/tasks/taker/ProcessPublishDepositTxRequest.java @@ -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; @@ -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)); diff --git a/gui/src/main/java/io/bitsquare/gui/components/paymentmethods/CryptoCurrencyForm.java b/gui/src/main/java/io/bitsquare/gui/components/paymentmethods/CryptoCurrencyForm.java index a603528be27..92ee0fe332d 100644 --- a/gui/src/main/java/io/bitsquare/gui/components/paymentmethods/CryptoCurrencyForm.java +++ b/gui/src/main/java/io/bitsquare/gui/components/paymentmethods/CryptoCurrencyForm.java @@ -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; } diff --git a/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/ContractWindow.java b/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/ContractWindow.java index ec1dff20789..4a4015a84bd 100644 --- a/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/ContractWindow.java +++ b/gui/src/main/java/io/bitsquare/gui/main/overlays/windows/ContractWindow.java @@ -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; @@ -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); @@ -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;