diff --git a/multidoge-0.1.6-bins.md5 b/multidoge-0.1.6-bins.md5
index 396e6f391..1ea31ef49 100644
--- a/multidoge-0.1.6-bins.md5
+++ b/multidoge-0.1.6-bins.md5
@@ -1,3 +1,3 @@
-956C8F38EB9004F17FEE5B42DCC9FA48 multidoge-0.1.5.dmg
-E92E3364D34F35876CF14D631D90C32C multidoge-0.1.5-linux.jar
-989ACDE5C65B29357C8F3935AD4B896C multidoge-0.1.5-windows-setup.exe
+956C8F38EB9004F17FEE5B42DCC9FA48 multidoge-0.1.6.dmg
+E92E3364D34F35876CF14D631D90C32C multidoge-0.1.6-linux.jar
+989ACDE5C65B29357C8F3935AD4B896C multidoge-0.1.6-windows-setup.exe
diff --git a/multidoge-0.1.7-bins.md5 b/multidoge-0.1.7-bins.md5
new file mode 100644
index 000000000..6a4c3fba1
--- /dev/null
+++ b/multidoge-0.1.7-bins.md5
@@ -0,0 +1,3 @@
+6277491E0889942F5C0213A8CA6BA1DA multidoge-0.1.7.dmg
+E69A81B1E86C7AA72D3B36D0D5FB4218 multidoge-0.1.7-linux.jar
+6AF7401318F4E3858933CD841074C3B6 multidoge-0.1.7-windows-setup.exe
diff --git a/pom.xml b/pom.xml
index 4178c0638..9903caf14 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
4.0.0
org.multibit
multidoge
- 0.1.6
+ 0.1.7
MultiDoge
A Java Swing client for Dogecoin
https://multidoge.org
@@ -685,52 +685,10 @@
xchange-core
${xchange.version}
-
+
com.xeiam.xchange
- xchange-mtgox
- ${xchange.version}
-
-
-
- com.xeiam.xchange
- xchange-cavirtex
- ${xchange.version}
-
-
-
- com.xeiam.xchange
- xchange-openexchangerates
- ${xchange.version}
-
-
-
- com.xeiam.xchange
- xchange-btce
- ${xchange.version}
-
-
-
- com.xeiam.xchange
- xchange-bitstamp
- ${xchange.version}
-
-
-
- com.xeiam.xchange
- xchange-campbx
- ${xchange.version}
-
-
-
- com.xeiam.xchange
- xchange-btcchina
- ${xchange.version}
-
-
-
- com.xeiam.xchange
- xchange-kraken
+ xchange-poloniex
${xchange.version}
@@ -819,7 +777,7 @@
0.10.3-MB-ALICE
- 2.0.0-SNAPSHOT
+ 3.1.0
1.47.0.2
diff --git a/release_notes.txt b/release_notes.txt
index 03aeae71c..04bc4a463 100644
--- a/release_notes.txt
+++ b/release_notes.txt
@@ -1,4 +1,7 @@
MultiDoge release notes:
-14 Oct 2015: 0.1.6
-+ Fix syncing issue preventing to sync further than Oct 12
+29 Jan 2016: 0.1.7
++ Update XChange to 3.1.0
++ Replace Cryptsy with Poloniex as source for the DOGE/BTC exchange rate
++ BTC/Fiat exchange rates are provided by BitcoinAverage
++ Updated checkpoints
\ No newline at end of file
diff --git a/release_notes_full.txt b/release_notes_full.txt
index e64c6ce75..843f8d533 100644
--- a/release_notes_full.txt
+++ b/release_notes_full.txt
@@ -1,4 +1,9 @@
MultiDoge release notes:
+29 Jan 2016: 0.1.7
++ Update XChange to 3.1.0
++ Replace Cryptsy with Poloniex as source for the DOGE/BTC exchange rate
++ BTC/Fiat exchange rates are provided by BitcoinAverage
++ Updated checkpoints
14 Oct 2015: 0.1.6
+ Fix syncing issue preventing to sync further than Oct 12
diff --git a/src/main/java/org/multibit/MultiBit.java b/src/main/java/org/multibit/MultiBit.java
index d97453dbc..130de1429 100644
--- a/src/main/java/org/multibit/MultiBit.java
+++ b/src/main/java/org/multibit/MultiBit.java
@@ -31,6 +31,7 @@
import org.multibit.model.bitcoin.WalletData;
import org.multibit.model.core.CoreModel;
import org.multibit.model.exchange.ConnectHttps;
+import org.multibit.model.exchange.ExchangeData;
import org.multibit.model.exchange.ExchangeModel;
import org.multibit.network.*;
import org.multibit.platform.GenericApplication;
@@ -611,6 +612,14 @@ public void run() {
// Just sync the blockchain without a replay task being involved.
ReplayManager.INSTANCE.downloadBlockChain();
}
+
+ // Upgrade path from cryptsy
+ if (bitcoinController.getModel().getUserPreference(ExchangeModel.TICKER_FIRST_ROW_EXCHANGE).equals(ExchangeData.CRYPTS_EXCHANGE_NAME)) {
+ bitcoinController.getModel().setUserPreference(ExchangeModel.TICKER_FIRST_ROW_EXCHANGE, ExchangeData.POLONIEX_EXCHANGE_NAME);
+ }
+ if (bitcoinController.getModel().getUserPreference(ExchangeModel.TICKER_SECOND_ROW_EXCHANGE).equals(ExchangeData.CRYPTS_EXCHANGE_NAME)) {
+ bitcoinController.getModel().setUserPreference(ExchangeModel.TICKER_SECOND_ROW_EXCHANGE, ExchangeData.POLONIEX_EXCHANGE_NAME);
+ }
} catch (Exception e) {
// An odd unrecoverable error occurred.
e.printStackTrace();
diff --git a/src/main/java/org/multibit/exchange/CurrencyConverter.java b/src/main/java/org/multibit/exchange/CurrencyConverter.java
index b5cad0202..0b0dbe9c0 100644
--- a/src/main/java/org/multibit/exchange/CurrencyConverter.java
+++ b/src/main/java/org/multibit/exchange/CurrencyConverter.java
@@ -88,12 +88,6 @@ public void initialise(Controller controller) {
String currencyCode = controller.getModel().getUserPreference(ExchangeModel.TICKER_FIRST_ROW_CURRENCY);
String exchange = controller.getModel().getUserPreference(ExchangeModel.TICKER_FIRST_ROW_EXCHANGE);
String newCurrencyCode = currencyCode;
- if (ExchangeData.BITCOIN_CHARTS_EXCHANGE_NAME.equals(exchange)) {
- // Use only the last three characters - the currency code.
- if (currencyCode.length() >= 3) {
- newCurrencyCode = currencyCode.substring(currencyCode.length() - 3);
- }
- }
initialise(controller, newCurrencyCode);
}
diff --git a/src/main/java/org/multibit/exchange/TickerTimerTask.java b/src/main/java/org/multibit/exchange/TickerTimerTask.java
index 3f119e340..491b5e3d8 100644
--- a/src/main/java/org/multibit/exchange/TickerTimerTask.java
+++ b/src/main/java/org/multibit/exchange/TickerTimerTask.java
@@ -15,13 +15,16 @@
*/
package org.multibit.exchange;
+import java.io.IOException;
import java.math.BigDecimal;
-import java.math.RoundingMode;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.TimerTask;
-import com.xeiam.xchange.bitcoinaverage.service.BitcoinaverageBaseService;
+import com.xeiam.xchange.exceptions.ExchangeException;
+import com.xeiam.xchange.poloniex.PoloniexExchange;
+import com.xeiam.xchange.service.polling.marketdata.PollingMarketDataService;
import org.joda.money.BigMoney;
import org.joda.money.CurrencyUnit;
@@ -29,7 +32,6 @@
import org.multibit.controller.exchange.ExchangeController;
import org.multibit.model.exchange.ExchangeData;
import org.multibit.model.exchange.ExchangeModel;
-import org.multibit.utils.DogeUtils;
import org.multibit.viewsystem.swing.MultiBitFrame;
import org.slf4j.Logger;
@@ -37,11 +39,8 @@
import com.xeiam.xchange.Exchange;
import com.xeiam.xchange.ExchangeFactory;
-import com.xeiam.xchange.ExchangeSpecification;
-import com.xeiam.xchange.currency.Currencies;
import com.xeiam.xchange.currency.CurrencyPair;
import com.xeiam.xchange.dto.marketdata.Ticker;
-import com.xeiam.xchange.service.polling.PollingMarketDataService;
/**
* TimerTask to poll currency exchanges for ticker data process
@@ -67,7 +66,8 @@ public class TickerTimerTask extends TimerTask {
private String shortExchangeName;
private String currency;
private Exchange exchange;
- private PollingMarketDataService marketDataService;
+ private PollingMarketDataService marketDataServiceBTC;
+ private PollingMarketDataService marketDataServiceDOGE;
private List exchangeSymbols;
/**
@@ -122,7 +122,7 @@ public void run() {
}
}
- if (marketDataService != null) {
+ if (marketDataServiceBTC != null && marketDataServiceDOGE != null) {
if (exchangeSymbols != null) {
// Only get data from server if ticker is being shown if
// currency conversion is switched on.
@@ -139,141 +139,86 @@ public void run() {
// of currency units per BTC
boolean invertedRates = false;
- // Is the currency pair the other way round ie
- // base currency = other, counter currency = BTC
- boolean reverseRates = ExchangeData.doesExchangeUseReverseRates(shortExchangeName);
CurrencyPair currencyPairToUse = null;
for (CurrencyPair loopSymbolPair : exchangeSymbols) {
- if (ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equals(shortExchangeName)) {
- if (loopSymbolPair.baseSymbol.equals(currency)) {
- getItFromTheServer = true;
- invertedRates = true;
- currencyPairToUse = loopSymbolPair;
- break;
- }
- } else {
- if ("BTC".equals(loopSymbolPair.baseSymbol) && loopSymbolPair.counterSymbol.equals(currency)) {
- getItFromTheServer = true;
- currencyPairToUse = loopSymbolPair;
- break;
- }
- if ("BTC".equals(loopSymbolPair.baseSymbol) && loopSymbolPair.counterSymbol.equals(currency)) {
- getItFromTheServer = true;
- invertedRates = true;
- currencyPairToUse = loopSymbolPair;
- break;
- }
+ if ("BTC".equals(loopSymbolPair.baseSymbol) && loopSymbolPair.counterSymbol.equals(currency)) {
+ getItFromTheServer = true;
+ currencyPairToUse = loopSymbolPair;
+ break;
+ }
+ if ("BTC".equals(loopSymbolPair.counterSymbol) && loopSymbolPair.baseSymbol.equals(currency)) {
+ getItFromTheServer = true;
+ invertedRates = true;
+ currencyPairToUse = loopSymbolPair;
+ break;
}
}
if (getItFromTheServer) {
- BigMoney last = null;
- BigMoney bid = null;
- BigMoney ask = null;
-
- Ticker loopTicker;
-
- if (ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equals(shortExchangeName)) {
- log.debug("Getting loopTicker for " + currency + " USD");
- loopTicker = marketDataService.getTicker(new CurrencyPair(currency, Currencies.USD));
- System.out.println("loopTicker = " + loopTicker);
- Ticker btcUsdTicker = null;
- log.debug("Getting btcUsdTicker for BTC/USD");
- btcUsdTicker = marketDataService.getTicker(new CurrencyPair(Currencies.BTC, Currencies.USD));
- System.out.println("btcUsdTicker = " + btcUsdTicker);
-
- BigMoney usdBtcRateMoney = BigMoney.of(CurrencyUnit.USD, btcUsdTicker.getLast());
- BigDecimal usdBtcRate = null;
- if (usdBtcRateMoney != null) {
- usdBtcRate = usdBtcRateMoney.getAmount();
- if (loopTicker.getLast() != null) {
- last = BigMoney.of(CurrencyUnit.USD,loopTicker.getLast()).dividedBy(usdBtcRate, RoundingMode.HALF_EVEN);
- }
- if (loopTicker.getBid() != null) {
- bid = BigMoney.of(CurrencyUnit.USD,loopTicker.getBid()).dividedBy(usdBtcRate, RoundingMode.HALF_EVEN);
- }
- if (loopTicker.getAsk() != null) {
- ask = BigMoney.of(CurrencyUnit.USD,loopTicker.getAsk()).dividedBy(usdBtcRate, RoundingMode.HALF_EVEN);
- }
+ BigMoney lastBTC, bidBTC, askBTC, lastDOGE, bidDOGE, askDOGE;
+ Ticker tickerBTC, tickerDOGE;
+
+ log.debug("Getting ticker for " + currencyPairToUse.baseSymbol + " "
+ + currencyPairToUse.counterSymbol);
+ tickerBTC = marketDataServiceBTC.getTicker(currencyPairToUse);
+ tickerDOGE = marketDataServiceDOGE.getTicker(CurrencyPair.DOGE_BTC);
+
+ log.debug("Got ticker for " + currencyPairToUse.baseSymbol + " "
+ + currencyPairToUse.counterSymbol);
+ lastBTC = BigMoney.of(CurrencyUnit.USD,tickerBTC.getLast());
+ bidBTC = BigMoney.of(CurrencyUnit.USD,tickerBTC.getBid());
+ askBTC = BigMoney.of(CurrencyUnit.USD,tickerBTC.getAsk());
+ lastDOGE = BigMoney.of(CurrencyUnit.USD,tickerDOGE.getLast());
+ bidDOGE = BigMoney.of(CurrencyUnit.USD,tickerDOGE.getBid());
+ askDOGE = BigMoney.of(CurrencyUnit.USD,tickerDOGE.getAsk());
+
+ if (invertedRates) {
+ if (!lastBTC.getAmount().equals(BigDecimal.ZERO)) {
+ lastBTC = BigMoney.of(lastBTC.getCurrencyUnit(), BigDecimal.ONE.divide(lastBTC.getAmount(),
+ NUMBER_OF_SIGNIFICANT_DIGITS, BigDecimal.ROUND_HALF_EVEN));
+ } else {
+ lastBTC = null;
}
- } else {
- log.debug("Getting ticker for " + currencyPairToUse.baseSymbol + " "
- + currencyPairToUse.counterSymbol);
- loopTicker = marketDataService.getTicker(currencyPairToUse);
-
- log.debug("Got ticker for " + currencyPairToUse.baseSymbol + " "
- + currencyPairToUse.counterSymbol);
- last = BigMoney.of(CurrencyUnit.USD,loopTicker.getLast());
- bid = BigMoney.of(CurrencyUnit.USD,loopTicker.getBid());
- ask = BigMoney.of(CurrencyUnit.USD,loopTicker.getAsk());
-
- if (invertedRates && !reverseRates) {
- if (last != null && last.getAmount() != BigDecimal.ZERO) {
- last = BigMoney.of(last.getCurrencyUnit(), BigDecimal.ONE.divide(last.getAmount(),
- NUMBER_OF_SIGNIFICANT_DIGITS, BigDecimal.ROUND_HALF_EVEN));
- } else {
- last = null;
- }
- if (bid != null && bid.getAmount() != BigDecimal.ZERO) {
- bid = BigMoney.of(bid.getCurrencyUnit(), BigDecimal.ONE.divide(bid.getAmount(),
- NUMBER_OF_SIGNIFICANT_DIGITS, BigDecimal.ROUND_HALF_EVEN));
- } else {
- bid = null;
- }
-
- if (ask != null && ask.getAmount() != BigDecimal.ZERO) {
- ask = BigMoney.of(ask.getCurrencyUnit(), BigDecimal.ONE.divide(ask.getAmount(),
- NUMBER_OF_SIGNIFICANT_DIGITS, BigDecimal.ROUND_HALF_EVEN));
- } else {
- ask = null;
- }
+ if (!bidBTC.getAmount().equals(BigDecimal.ZERO)) {
+ bidBTC = BigMoney.of(bidBTC.getCurrencyUnit(), BigDecimal.ONE.divide(bidBTC.getAmount(),
+ NUMBER_OF_SIGNIFICANT_DIGITS, BigDecimal.ROUND_HALF_EVEN));
+ } else {
+ bidBTC = null;
}
- if (invertedRates) {
- if (reverseRates) {
- // USD/ BTC, reciprocal rate
- currency = currencyPairToUse.baseSymbol;
- } else {
- // BTC/ USD, reciprocal rate
- currency = currencyPairToUse.counterSymbol;
- }
+ if (!askBTC.getAmount().equals(BigDecimal.ZERO)) {
+ askBTC = BigMoney.of(askBTC.getCurrencyUnit(), BigDecimal.ONE.divide(askBTC.getAmount(),
+ NUMBER_OF_SIGNIFICANT_DIGITS, BigDecimal.ROUND_HALF_EVEN));
} else {
- if (reverseRates) {
- // USD/ BTC, normal rate
- currency = currencyPairToUse.baseSymbol;
- } else {
- // BTC/ USD, normal rate
- currency = currencyPairToUse.counterSymbol;
- }
+ askBTC = null;
}
}
- log.debug("Getting DOGE conversion");
- float dogeRate = DogeUtils.requestDogeBtcConversion();
- if (dogeRate == 0f)
- {
- log.debug("Problem getting DOGE conversion");
- return;
+ if (invertedRates) {
+ // BTC/ USD, reciprocal rate
+ currency = currencyPairToUse.counterSymbol;
+ } else {
+ // BTC/ USD, normal rate
+ currency = currencyPairToUse.counterSymbol;
}
- this.exchangeController.getModel().getExchangeData(shortExchangeName).setLastPrice(currency, last.multipliedBy(dogeRate));
- this.exchangeController.getModel().getExchangeData(shortExchangeName).setLastBid(currency, bid.multipliedBy(dogeRate));
- this.exchangeController.getModel().getExchangeData(shortExchangeName).setLastAsk(currency, ask.multipliedBy(dogeRate));
+ if (lastBTC != null) {
+ this.exchangeController.getModel().getExchangeData(shortExchangeName).setLastPrice(currency, lastBTC.multipliedBy(lastDOGE.getAmount()));
+ }
+ if (bidBTC != null) {
+ this.exchangeController.getModel().getExchangeData(shortExchangeName).setLastBid(currency, bidBTC.multipliedBy(bidDOGE.getAmount()));
+ }
+ if (askBTC != null) {
+ this.exchangeController.getModel().getExchangeData(shortExchangeName).setLastAsk(currency, askBTC.multipliedBy(askDOGE.getAmount()));
+ }
log.debug("Exchange = " + shortExchangeName);
// Put the exchange rate into the currency converter.
- if (isFirstExchange) {
+ if (isFirstExchange && lastBTC != null) {
String newCurrencyCode = currency;
- if (ExchangeData.BITCOIN_CHARTS_EXCHANGE_NAME.equals(shortExchangeName)) {
- // Use only the last three characters - the
- // currency code.
- if (currency.length() >= 3) {
- newCurrencyCode = currency.substring(currency.length() - 3);
- }
- }
CurrencyConverter.INSTANCE.setCurrencyUnit(CurrencyUnit.of(newCurrencyCode));
- CurrencyConverter.INSTANCE.setRate(last.getAmount().multiply(BigDecimal.valueOf(dogeRate)));
+ CurrencyConverter.INSTANCE.setRate(lastBTC.getAmount().multiply(lastDOGE.getAmount()));
}
}
}
@@ -293,14 +238,24 @@ public void run() {
public void createExchangeObjects(String newExchangeName) {
exchange = createExchange(newExchangeName);
+ Exchange exchangeDOGE = ExchangeFactory.INSTANCE.createExchange(PoloniexExchange.class.getName());
if (exchange != null) {
+ try {
+ exchange.remoteInit();
+ exchangeDOGE.remoteInit();
+ } catch (IOException e) {
+ log.error("Could not contact exchanges for init!");
+ return;
+ }
+
// Interested in the public market data feed (no authentication).
- marketDataService = exchange.getPollingMarketDataService();
- log.debug("marketDataService = " + marketDataService);
+ marketDataServiceBTC = exchange.getPollingMarketDataService();
+ marketDataServiceDOGE = exchangeDOGE.getPollingMarketDataService();
+ log.debug("marketDataServiceBTC = " + marketDataServiceBTC);
// Get the list of available currencies.
- exchangeSymbols = BitcoinaverageBaseService.CURRENCY_PAIRS; // TODO: When XChange fixes that shit, refactor this shit...
+ exchangeSymbols = new ArrayList(exchange.getMetaData().getMarketMetaDataMap().keySet());
log.debug("exchangeSymbols = " + exchangeSymbols);
if (exchangeSymbols != null) {
@@ -310,26 +265,11 @@ public void createExchangeObjects(String newExchangeName) {
String baseCurrency = exchangeSymbols.get(i).baseSymbol;
String counterCurrency = exchangeSymbols.get(i).counterSymbol;
- if (ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equals(newExchangeName)) {
- if ("USD".equalsIgnoreCase(baseCurrency) && !"BTC".equalsIgnoreCase(counterCurrency)) {
- if (!"EEK".equalsIgnoreCase(counterCurrency) && !"CLF".equalsIgnoreCase(counterCurrency)
- && !"JEP".equalsIgnoreCase(counterCurrency) && ! "SVC".equalsIgnoreCase(counterCurrency)) {
- availableCurrencies.add(counterCurrency);
- }
- }
- if ("USD".equalsIgnoreCase(counterCurrency) && !"BTC".equalsIgnoreCase(baseCurrency)) {
- if (!"EEK".equalsIgnoreCase(baseCurrency) && !"CLF".equalsIgnoreCase(baseCurrency)
- && !"JEP".equalsIgnoreCase(baseCurrency) && ! "SVC".equalsIgnoreCase(baseCurrency)) {
- availableCurrencies.add(baseCurrency);
- }
- }
- } else {
- if ("BTC".equalsIgnoreCase(baseCurrency)) {
- availableCurrencies.add(counterCurrency);
- }
- if ("BTC".equalsIgnoreCase(counterCurrency)) {
- availableCurrencies.add(baseCurrency);
- }
+ if ("BTC".equalsIgnoreCase(baseCurrency)) {
+ availableCurrencies.add(counterCurrency);
+ }
+ if ("BTC".equalsIgnoreCase(counterCurrency)) {
+ availableCurrencies.add(baseCurrency);
}
}
ExchangeData.setAvailableCurrenciesForExchange(newExchangeName, availableCurrencies);
@@ -341,7 +281,7 @@ public void createExchangeObjects(String newExchangeName) {
* Create the exchange specified by the exchange class name specified e.g.
* BitcoinChartsExchange.class.getName();
*
- * @param exchangeClassName
+ * @param exchangeShortname
*/
private Exchange createExchange(String exchangeShortname) {
log.debug("creating exchange from exchangeShortname = " + exchangeShortname);
@@ -359,15 +299,7 @@ private Exchange createExchange(String exchangeShortname) {
}
Exchange exchangeToReturn;
- if (ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase(exchangeShortname)) {
- ExchangeSpecification exchangeSpecification = new ExchangeSpecification(exchangeClassname);
- exchangeSpecification.setPlainTextUri("http://openexchangerates.org");
- exchangeSpecification
- .setApiKey(controller.getModel().getUserPreference(ExchangeModel.OPEN_EXCHANGE_RATES_API_CODE));
- exchangeToReturn = ExchangeFactory.INSTANCE.createExchange(exchangeSpecification);
- } else {
- exchangeToReturn = ExchangeFactory.INSTANCE.createExchange(exchangeClassname);
- }
+ exchangeToReturn = ExchangeFactory.INSTANCE.createExchange(exchangeClassname);
if (this.exchangeController.getModel().getExchangeData(shortExchangeName) == null) {
ExchangeData exchangeData = new ExchangeData();
@@ -376,7 +308,7 @@ private Exchange createExchange(String exchangeShortname) {
}
return exchangeToReturn;
- } catch (com.xeiam.xchange.ExchangeException e) {
+ } catch (ExchangeException e) {
// Probably xchange is not on classpath - ticker will not run
// but error should not spread out from here to rest of MultiBit.
log.error(e.getClass().getName() + " " + e.getMessage());
diff --git a/src/main/java/org/multibit/model/exchange/ExchangeData.java b/src/main/java/org/multibit/model/exchange/ExchangeData.java
index 60db50408..8a2c15506 100644
--- a/src/main/java/org/multibit/model/exchange/ExchangeData.java
+++ b/src/main/java/org/multibit/model/exchange/ExchangeData.java
@@ -16,11 +16,6 @@
package org.multibit.model.exchange;
import com.xeiam.xchange.bitcoinaverage.BitcoinAverageExchange;
-import com.xeiam.xchange.bitstamp.BitstampExchange;
-import com.xeiam.xchange.btce.v3.BTCEExchange;
-import com.xeiam.xchange.campbx.CampBXExchange;
-import com.xeiam.xchange.oer.OERExchange;
-import com.xeiam.xchange.virtex.VirtExExchange;
import org.joda.money.BigMoney;
import java.util.ArrayList;
@@ -28,8 +23,6 @@
import java.util.HashMap;
import java.util.Map;
-//import com.xeiam.xchange.btcchina.BTCChinaExchange;
-
/**
*
* @author timmolter
@@ -39,17 +32,11 @@ public class ExchangeData {
public static final String EXCHANGE_NOT_SET = "NoExchangeSetYet";
- public static final String BITCOIN_CHARTS_EXCHANGE_NAME = "BitcoinCharts";
- public static final String BITSTAMP_EXCHANGE_NAME = "Bitstamp";
- public static final String BTCE_EXCHANGE_NAME = "BTC-E";
- public static final String CAMPBX_EXCHANGE_NAME = "CampBX";
- public static final String OPEN_EXCHANGE_RATES_EXCHANGE_NAME = "OpenExchangeRates";
- public static final String MT_GOX_EXCHANGE_NAME = "MtGox";
- public static final String VIRTEX_EXCHANGE_NAME = "VirtEx";
- public static final String CRYPTSY_EXCHANGE_NAME = "Cryptsy";
+ public static final String CRYPTS_EXCHANGE_NAME = "Cryptsy"; // Legacy
public static final String BITCOINAVERAGE_EXCHANGE_NAME = "BitcoinAverage";
+ public static final String POLONIEX_EXCHANGE_NAME = "Poloniex";
- public static final String DEFAULT_EXCHANGE = CRYPTSY_EXCHANGE_NAME;
+ public static final String DEFAULT_EXCHANGE = POLONIEX_EXCHANGE_NAME;
public static final String DEFAULT_CURRENCY = "USD";
@@ -61,7 +48,7 @@ public class ExchangeData {
}
public static final BigMoney DO_NOT_KNOW = null;
-
+
private String shortExchangeName;
private Map currencyToLastPriceMap;
private Map currencyToAskMap;
@@ -125,7 +112,7 @@ public static boolean doesExchangeUseReverseRates(String shortExchangeName) {
if (shortExchangeName == null) {
throw new IllegalArgumentException("Exchange name cannot be null");
}
- return BITCOIN_CHARTS_EXCHANGE_NAME.equals(shortExchangeName);
+ return false;
}
/**
@@ -133,13 +120,7 @@ public static boolean doesExchangeUseReverseRates(String shortExchangeName) {
* BTCChina not in the list as it does not seem reliable enough - drops connections (when used in UK)
*/
public static String[] getAvailableExchanges() {
-/* return new String[] { MT_GOX_EXCHANGE_NAME,
- BITSTAMP_EXCHANGE_NAME,
- BTCE_EXCHANGE_NAME,
- CAMPBX_EXCHANGE_NAME,
- OPEN_EXCHANGE_RATES_EXCHANGE_NAME,
- VIRTEX_EXCHANGE_NAME};*/
- return new String[] {CRYPTSY_EXCHANGE_NAME};
+ return new String[] {POLONIEX_EXCHANGE_NAME};
}
public static Collection getAvailableCurrenciesForExchange(String shortExchangeName) {
@@ -160,23 +141,7 @@ public static void setAvailableCurrenciesForExchange(String exchangeName, Collec
* Convert an exchange short name into a classname that can be used to create an Exchange.
*/
public static String convertExchangeShortNameToClassname(String shortExchangeName) {
- if (MT_GOX_EXCHANGE_NAME.equals(shortExchangeName)) {
- return "com.xeiam.xchange.mtgox.v2.MtGoxExchange";
- } else if (BITSTAMP_EXCHANGE_NAME.equalsIgnoreCase(shortExchangeName)) {
- return BitstampExchange.class.getName();
- } else if (BTCE_EXCHANGE_NAME.equalsIgnoreCase(shortExchangeName)) {
- return BTCEExchange.class.getName();
- //} else if (BTCCHINA_EXCHANGE_NAME.equalsIgnoreCase(shortExchangeName)) {
- // return BTCChinaExchange.class.getName();
- //} else if (KRAKEN_EXCHANGE_NAME.equalsIgnoreCase(shortExchangeName)) {
- // return KrakenExchange.class.getName();
- } else if (CAMPBX_EXCHANGE_NAME.equalsIgnoreCase(shortExchangeName)) {
- return CampBXExchange.class.getName();
- } else if (OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase(shortExchangeName)) {
- return OERExchange.class.getName();
- } else if (VIRTEX_EXCHANGE_NAME.equalsIgnoreCase(shortExchangeName)) {
- return VirtExExchange.class.getName();
- } else if (BITCOINAVERAGE_EXCHANGE_NAME.equalsIgnoreCase(shortExchangeName) || CRYPTSY_EXCHANGE_NAME.equals(shortExchangeName)) {
+ if (BITCOINAVERAGE_EXCHANGE_NAME.equalsIgnoreCase(shortExchangeName) || POLONIEX_EXCHANGE_NAME.equals(shortExchangeName)) {
return BitcoinAverageExchange.class.getName();
} else {
// Unidentified exchange.
diff --git a/src/main/java/org/multibit/model/exchange/ExchangeModel.java b/src/main/java/org/multibit/model/exchange/ExchangeModel.java
index a417cda2c..85e2b9979 100644
--- a/src/main/java/org/multibit/model/exchange/ExchangeModel.java
+++ b/src/main/java/org/multibit/model/exchange/ExchangeModel.java
@@ -48,7 +48,6 @@ public class ExchangeModel extends AbstractModel {
// Currency support.
public static final String SHOW_BITCOIN_CONVERTED_TO_FIAT = "showBitcoinConvertedToFiat"; // boolean
- public static final String OPEN_EXCHANGE_RATES_API_CODE = "openExchangeRatesApiCode";
private Map shortExchangeNameToExchangeMap;
diff --git a/src/main/java/org/multibit/utils/DogeUtils.java b/src/main/java/org/multibit/utils/DogeUtils.java
deleted file mode 100644
index ae494f33b..000000000
--- a/src/main/java/org/multibit/utils/DogeUtils.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package org.multibit.utils;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-/**
- * Created by Max on 06.02.14.
- */
-public class DogeUtils {
-
- private static Logger log = LoggerFactory.getLogger(DogeUtils.class);
-
- private static final URL DOGEPOOL_URL;
- private static final URL CRYPTSY_URL;
- private static final URL VIRCUREX_URL;
-
- static
- {
- try
- {
- DOGEPOOL_URL = new URL("http://dogepool.com/lastdoge");
- CRYPTSY_URL = new URL("http://pubapi.cryptsy.com/api.php?method=singlemarketdata&marketid=132");
- VIRCUREX_URL = new URL("https://vircurex.com/api/get_last_trade.json?base=DOGE&alt=BTC");
- }
- catch (final MalformedURLException x)
- {
- throw new RuntimeException(x); // cannot happen
- }
- }
-
- public static float requestDogeBtcConversion() {
- HttpURLConnection connection = null;
- Reader reader = null;
-
- try
- {
- connection = (HttpURLConnection) DOGEPOOL_URL.openConnection();
- connection.setConnectTimeout(Constants.HTTP_TIMEOUT_MS);
- connection.setReadTimeout(Constants.HTTP_TIMEOUT_MS);
- connection.connect();
-
- final int responseCode = connection.getResponseCode();
- if (responseCode == HttpURLConnection.HTTP_OK)
- {
- reader = new InputStreamReader(new BufferedInputStream(connection.getInputStream(), 1024), Constants.UTF_8);
- final StringBuilder content = new StringBuilder();
- Io.copy(reader, content);
-
- try
- {
- return Float.parseFloat(content.toString());
- } catch (NumberFormatException e)
- {
- log.debug("Hm, looks like dogepool changed their API...");
- return -1;
- }
-
- }
- else
- {
- log.debug("http status " + responseCode + " when fetching " + DOGEPOOL_URL);
- }
- }
- catch (final Exception x)
- {
- log.debug("problem reading exchange rates", x);
- }
- finally
- {
- if (reader != null)
- {
- try
- {
- reader.close();
- }
- catch (final IOException x)
- {
- // swallow
- }
- }
-
- if (connection != null)
- connection.disconnect();
- }
-
- return -1;
- }
-}
diff --git a/src/main/java/org/multibit/viewsystem/dataproviders/PreferencesDataProvider.java b/src/main/java/org/multibit/viewsystem/dataproviders/PreferencesDataProvider.java
index 5afbe2678..4e6f5dbb2 100644
--- a/src/main/java/org/multibit/viewsystem/dataproviders/PreferencesDataProvider.java
+++ b/src/main/java/org/multibit/viewsystem/dataproviders/PreferencesDataProvider.java
@@ -133,10 +133,5 @@ public interface PreferencesDataProvider extends DataProvider {
boolean getPreviousShowBitcoinConvertedToFiat();
- String getNewOpenExchangeRatesApiCode();
-
-
- String getPreviousOpenExchangeRatesApiCode();
-
boolean getNewMinimizeToTray();
}
diff --git a/src/main/java/org/multibit/viewsystem/swing/action/ShowPreferencesSubmitAction.java b/src/main/java/org/multibit/viewsystem/swing/action/ShowPreferencesSubmitAction.java
index a391dcb5a..5e6793478 100644
--- a/src/main/java/org/multibit/viewsystem/swing/action/ShowPreferencesSubmitAction.java
+++ b/src/main/java/org/multibit/viewsystem/swing/action/ShowPreferencesSubmitAction.java
@@ -311,15 +311,8 @@ public void actionPerformed(ActionEvent event) {
String newCurrency1 = dataProvider.getNewCurrency1();
if (newCurrency1 != null && !newCurrency1.equals(previousCurrency1)) {
controller.getModel().setUserPreference(ExchangeModel.TICKER_FIRST_ROW_CURRENCY, newCurrency1);
- String newCurrencyCode = newCurrency1;
- if (ExchangeData.BITCOIN_CHARTS_EXCHANGE_NAME.equals(newExchange1)) {
- // Use only the last three characters - the currency code.
- if (newCurrency1.length() >= 3) {
- newCurrencyCode = newCurrency1.substring(newCurrency1.length() - 3);
- }
- }
try {
- CurrencyConverter.INSTANCE.setCurrencyUnit(CurrencyUnit.of(newCurrencyCode));
+ CurrencyConverter.INSTANCE.setCurrencyUnit(CurrencyUnit.of(newCurrency1));
} catch ( org.joda.money.IllegalCurrencyException e) {
e.printStackTrace();
}
@@ -354,15 +347,6 @@ public void actionPerformed(ActionEvent event) {
wantToFireDataStructureChanged = true;
restartTickerTimer = true;
}
-
- String previousOerApicode = dataProvider.getPreviousOpenExchangeRatesApiCode();
- String newOerApiCode = dataProvider.getNewOpenExchangeRatesApiCode();
- if (newOerApiCode != null && !newOerApiCode.equals(previousOerApicode)) {
- wantToFireDataStructureChanged = true;
- restartTickerTimer = true;
-
- controller.getModel().setUserPreference(ExchangeModel.OPEN_EXCHANGE_RATES_API_CODE, newOerApiCode);
- }
// Can undo.
controller.getModel().setUserPreference(CoreModel.CAN_UNDO_PREFERENCES_CHANGES, "true");
diff --git a/src/main/java/org/multibit/viewsystem/swing/view/panels/ShowPreferencesPanel.java b/src/main/java/org/multibit/viewsystem/swing/view/panels/ShowPreferencesPanel.java
index db1235a70..c1f1f8718 100644
--- a/src/main/java/org/multibit/viewsystem/swing/view/panels/ShowPreferencesPanel.java
+++ b/src/main/java/org/multibit/viewsystem/swing/view/panels/ShowPreferencesPanel.java
@@ -76,9 +76,6 @@ public class ShowPreferencesPanel extends JPanel implements Viewable, Preference
private static final int EXCHANGE_COMBO_HEIGHT_DELTA = 15;
private static final int COMBO_WIDTH_DELTA = 150;
- private static final int API_CODE_FIELD_HEIGHT = 30;
- private static final int API_CODE_FIELD_WIDTH = 200;
-
private final Controller controller;
private final BitcoinController bitcoinController;
private final ExchangeController exchangeController;
@@ -146,16 +143,6 @@ public class ShowPreferencesPanel extends JPanel implements Viewable, Preference
private JComboBox lookAndFeelComboBox;
private String localisedSystemLookAndFeelName;
- private JPanel oerStent;
- private MultiBitTextField oerApiCodeTextField;
- private String haveShownErrorMessageForApiCode;
- private MultiBitButton getOerAppIdButton;
- private MultiBitLabel oerApiCodeLabel;
- private MultiBitLabel oerMessageLabel1, oerMessageLabel2;
- private String originalOERApiCode;
- public static final String OPEN_EXCHANGE_RATES_SIGN_UP_URI = "https://openexchangerates.org/signup/free?r=multibit";
- public static final int LENGTH_OF_OPEN_EXCHANGE_RATE_APP_ID = 32;
-
private Font selectedFont;
private static final int STENT_DELTA = 0;
@@ -171,7 +158,6 @@ public ShowPreferencesPanel(BitcoinController bitcoinController, ExchangeControl
this.mainFrame = mainFrame;
localisedSystemLookAndFeelName = controller.getLocaliser().getString("showPreferencesPanel.systemLookAndFeel");
- originalOERApiCode = controller.getModel().getUserPreference(ExchangeModel.OPEN_EXCHANGE_RATES_API_CODE);
initUI();
applyComponentOrientation(ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
@@ -256,9 +242,6 @@ public void displayView(DisplayHint displayHint) {
} else {
undoChangesButton.setEnabled(false);
}
-
- originalOERApiCode = controller.getModel().getUserPreference(ExchangeModel.OPEN_EXCHANGE_RATES_API_CODE);
- oerApiCodeTextField.setText(originalOERApiCode);
invalidate();
validate();
@@ -280,7 +263,7 @@ private void initUI() {
String[] keys = new String[] { "fontChooser.fontName", "fontChooser.fontStyle",
"fontChooser.fontSize", "showPreferencesPanel.ticker.exchange", "showPreferencesPanel.ticker.currency",
- "showPreferencesPanel.lookAndFeel", "showPreferencesPanel.oerLabel.text" };
+ "showPreferencesPanel.lookAndFeel"};
int stentWidth = MultiBitTitledPanel.calculateStentWidthForKeys(controller.getLocaliser(), keys, this) + STENT_DELTA;
GridBagConstraints constraints = new GridBagConstraints();
@@ -918,8 +901,7 @@ public void itemStateChanged(ItemEvent e) {
exchangeComboBox1.setOpaque(false);
FontMetrics fontMetrics = getFontMetrics(FontSizer.INSTANCE.getAdjustedDefaultFont());
- int textWidth = Math.max(fontMetrics.stringWidth(ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME), fontMetrics.stringWidth("USD"))
- + COMBO_WIDTH_DELTA;
+ int textWidth = fontMetrics.stringWidth("USD") + COMBO_WIDTH_DELTA;
Dimension preferredSize = new Dimension(textWidth + TICKER_COMBO_WIDTH_DELTA, fontMetrics.getHeight()
+ EXCHANGE_COMBO_HEIGHT_DELTA);
exchangeComboBox1.setPreferredSize(preferredSize);
@@ -943,20 +925,6 @@ public void itemStateChanged(ItemEvent e) {
constraints.anchor = GridBagConstraints.LINE_START;
tickerPanel.add(exchangeComboBox1, constraints);
- oerMessageLabel1 = new MultiBitLabel(" " + controller.getLocaliser().getString("showPreferencesPanel.getAppId.label"));
- oerMessageLabel1.setForeground(Color.GREEN.darker().darker());
- boolean showMessageLabel1 = isBrowserSupported() && ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase(exchangeToUse1)
- && (originalOERApiCode == null || originalOERApiCode.trim().length() == 0);
- oerMessageLabel1.setVisible(showMessageLabel1);
- constraints.fill = GridBagConstraints.NONE;
- constraints.gridx = 5;
- constraints.gridy = 15;
- constraints.weightx = 0.8;
- constraints.weighty = 0.6;
- constraints.gridwidth = 1;
- constraints.anchor = GridBagConstraints.LINE_START;
- tickerPanel.add(oerMessageLabel1, constraints);
-
MultiBitLabel currencyLabel1 = new MultiBitLabel(controller.getLocaliser()
.getString("showPreferencesPanel.ticker.currency"));
currencyLabel1.setHorizontalAlignment(JLabel.TRAILING);
@@ -1026,18 +994,6 @@ public void itemStateChanged(ItemEvent event) {
}
}
}
-
- // Enable the OpenExchangeRates App ID if required.
- boolean showOER = ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase(exchangeShortName) ||
- ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase((String) exchangeComboBox2.getSelectedItem());
- oerStent.setVisible(showOER);
- oerApiCodeLabel.setVisible(showOER);
- oerApiCodeTextField.setVisible(showOER);
- getOerAppIdButton.setVisible(showOER);
-
- boolean showMessageLabel = isBrowserSupported() && ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase(exchangeShortName)
- && (oerApiCodeTextField.getText() == null || oerApiCodeTextField.getText().trim().length() == 0);
- oerMessageLabel1.setVisible(showMessageLabel);
}
}
});
@@ -1142,18 +1098,6 @@ public void itemStateChanged(ItemEvent event) {
}
}
}
-
- // Enable the OpenExchangeRates App ID if required.
- boolean showOER = ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase(exchangeShortName) ||
- ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase((String) exchangeComboBox1.getSelectedItem());
- oerStent.setVisible(showOER);
- oerApiCodeLabel.setVisible(showOER);
- oerApiCodeTextField.setVisible(showOER);
- getOerAppIdButton.setVisible(showOER);
-
- boolean showMessageLabel = isBrowserSupported() && ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase(exchangeShortName)
- && (oerApiCodeTextField.getText() == null || oerApiCodeTextField.getText().trim().length() == 0);
- oerMessageLabel2.setVisible(showMessageLabel);
}
}
});
@@ -1167,21 +1111,6 @@ public void itemStateChanged(ItemEvent event) {
constraints.anchor = GridBagConstraints.LINE_START;
tickerPanel.add(exchangeComboBox2, constraints);
- oerMessageLabel2 = new MultiBitLabel(" " + controller.getLocaliser().getString("showPreferencesPanel.getAppId.label"));
- oerMessageLabel2.setForeground(Color.GREEN.darker().darker());
- boolean showMessageLabel2 = isBrowserSupported() && ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase(exchangeToUse2)
- && (originalOERApiCode == null || originalOERApiCode.trim().length() == 0);
- oerMessageLabel2.setVisible(showMessageLabel2);
- constraints.fill = GridBagConstraints.NONE;
- constraints.gridx = 5;
- constraints.gridy = 22;
- constraints.weightx = 0.8;
- constraints.weighty = 0.6;
- constraints.gridwidth = 1;
- constraints.anchor = GridBagConstraints.LINE_START;
- tickerPanel.add(oerMessageLabel2, constraints);
-
-
currencyLabel2 = new MultiBitLabel(controller.getLocaliser().getString("showPreferencesPanel.ticker.currency"));
currencyLabel2.setHorizontalAlignment(JLabel.TRAILING);
constraints.fill = GridBagConstraints.HORIZONTAL;
@@ -1254,178 +1183,9 @@ public void itemStateChanged(ItemEvent event) {
constraints.gridwidth = 1;
constraints.anchor = GridBagConstraints.LINE_END;
tickerPanel.add(fill1, constraints);
-
- boolean showOerSignup = ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase(exchangeToUse1) ||
- ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equalsIgnoreCase(exchangeToUse2);
-
- oerStent = MultiBitTitledPanel.createStent(12, 12);
- constraints.fill = GridBagConstraints.BOTH;
- constraints.gridx = 1;
- constraints.gridy = 26;
- constraints.weightx = 0.3;
- constraints.weighty = 0.3;
- constraints.gridwidth = 1;
- constraints.anchor = GridBagConstraints.LINE_START;
- oerStent.setVisible(showOerSignup);
- tickerPanel.add(oerStent, constraints);
-
- oerApiCodeLabel = new MultiBitLabel(controller.getLocaliser().getString("showPreferencesPanel.oerLabel.text"));
- oerApiCodeLabel.setToolTipText(HelpContentsPanel.createTooltipText(controller.getLocaliser().getString("showPreferencesPanel.oerLabel.tooltip")));
- oerApiCodeLabel.setVisible(showOerSignup);
-
- oerApiCodeTextField = new MultiBitTextField("", 25, controller);
- oerApiCodeTextField.setHorizontalAlignment(JLabel.LEADING);
- oerApiCodeTextField.setMinimumSize(new Dimension(API_CODE_FIELD_WIDTH, API_CODE_FIELD_HEIGHT));
- oerApiCodeTextField.setPreferredSize(new Dimension(API_CODE_FIELD_WIDTH, API_CODE_FIELD_HEIGHT));
- oerApiCodeTextField.setMaximumSize(new Dimension(API_CODE_FIELD_WIDTH, API_CODE_FIELD_HEIGHT));
- oerApiCodeTextField.setVisible(showOerSignup);
- oerApiCodeTextField.setText(originalOERApiCode);
- oerApiCodeTextField.addFocusListener(new FocusListener() {
- @Override
- public void focusGained(FocusEvent arg0) {
- }
-
- @Override
- public void focusLost(FocusEvent arg0) {
- String apiCode = oerApiCodeTextField.getText();
- if (apiCode != null && !(WhitespaceTrimmer.trim(apiCode).length() == 0)
- && !apiCode.equals(controller.getModel().getUserPreference(ExchangeModel.OPEN_EXCHANGE_RATES_API_CODE))) {
- // New API code.
- // Check its length
- if (!(apiCode.trim().length() == LENGTH_OF_OPEN_EXCHANGE_RATE_APP_ID)
- && !apiCode.equals(haveShownErrorMessageForApiCode)) {
- haveShownErrorMessageForApiCode = apiCode;
- // Give user a message that App ID is not in the correct format.
- JOptionPane.showMessageDialog(null, new String[] {controller.getLocaliser().getString("showPreferencesPanel.oerValidationError.text1"), " ",
- controller.getLocaliser().getString("showPreferencesPanel.oerValidationError.text2"),
- controller.getLocaliser().getString("showPreferencesPanel.oerValidationError.text3")},
- controller.getLocaliser().getString("showPreferencesPanel.oerValidationError.title"),
- JOptionPane.ERROR_MESSAGE, ImageLoader.createImageIcon(ImageLoader.EXCLAMATION_MARK_ICON_FILE));
- return;
- }
- }
- updateApiCode();
- }});
- oerApiCodeTextField.addActionListener(new ActionListener(){
- @Override
- public void actionPerformed(ActionEvent arg0) {
- String apiCode = oerApiCodeTextField.getText();
- if (apiCode != null && !(WhitespaceTrimmer.trim(apiCode).length() == 0) && !apiCode.equals(controller.getModel().getUserPreference(ExchangeModel.OPEN_EXCHANGE_RATES_API_CODE))) {
- // New API code.
- // Check its length
- if (!(apiCode.trim().length() == LENGTH_OF_OPEN_EXCHANGE_RATE_APP_ID)
- && !apiCode.equals(haveShownErrorMessageForApiCode)) {
- haveShownErrorMessageForApiCode = apiCode;
- // Give user a message that App ID is not in the correct format.
- JOptionPane.showMessageDialog(null, new String[] {controller.getLocaliser().getString("showPreferencesPanel.oerValidationError.text1"),
- controller.getLocaliser().getString("showPreferencesPanel.oerValidationError.text2"),
- controller.getLocaliser().getString("showPreferencesPanel.oerValidationError.text3")},
- controller.getLocaliser().getString("showPreferencesPanel.oerValidationError.title"),
- JOptionPane.ERROR_MESSAGE, ImageLoader.createImageIcon(ImageLoader.EXCLAMATION_MARK_ICON_FILE));
- return;
- }
- }
- updateApiCode();
- }});
-
- constraints.fill = GridBagConstraints.NONE;
- constraints.gridx = 1;
- constraints.gridy = 27;
- constraints.weightx = 0.3;
- constraints.weighty = 0.3;
- constraints.gridwidth = 1;
- constraints.anchor = GridBagConstraints.LINE_END;
- tickerPanel.add(oerApiCodeLabel, constraints);
-
- constraints.fill = GridBagConstraints.NONE;
- constraints.gridx = 4;
- constraints.gridy = 27;
- constraints.weightx = 0.3;
- constraints.weighty = 0.3;
- constraints.gridwidth = 2;
- constraints.anchor = GridBagConstraints.LINE_START;
- tickerPanel.add(oerApiCodeTextField, constraints);
-
- if (isBrowserSupported()) {
- getOerAppIdButton = new MultiBitButton(controller.getLocaliser().getString("showPreferencesPanel.getAppId.text"));
- getOerAppIdButton.setToolTipText(controller.getLocaliser().getString("showPreferencesPanel.getAppId.tooltip"));
- getOerAppIdButton.setVisible(showOerSignup);
-
- getOerAppIdButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent arg0) {
- try {
- openURI(new URI(OPEN_EXCHANGE_RATES_SIGN_UP_URI));
- } catch (URISyntaxException e) {
- log.debug(e.getMessage());
- }
- }});
-
- constraints.fill = GridBagConstraints.NONE;
- constraints.gridx = 4;
- constraints.gridy = 28;
- constraints.weightx = 1;
- constraints.weighty = 1;
- constraints.gridwidth = 1;
- constraints.anchor = GridBagConstraints.LINE_START;
- tickerPanel.add(getOerAppIdButton, constraints);
- }
return tickerPanel;
}
-
- private void updateApiCode() {
- String apiCode = oerApiCodeTextField.getText();
- if (apiCode != null && !(WhitespaceTrimmer.trim(apiCode).length() == 0) && !apiCode.equals(controller.getModel().getUserPreference(ExchangeModel.OPEN_EXCHANGE_RATES_API_CODE))) {
- // New API code.
- apiCode = WhitespaceTrimmer.trim(apiCode);
- oerApiCodeTextField.setText(apiCode);
-
- controller.getModel().setUserPreference(ExchangeModel.OPEN_EXCHANGE_RATES_API_CODE, apiCode);
- if (ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equals((String)exchangeComboBox1.getSelectedItem())) {
- if (mainFrame != null && mainFrame.getTickerTimerTask1() != null) {
- TickerTimerTask tickerTimerTask = mainFrame.getTickerTimerTask1();
- synchronized (tickerTimerTask) {
- tickerTimerTask.createExchangeObjects(ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME);
- currencyComboBox1.removeAllItems();
- Collection currenciesToUse = ExchangeData.getAvailableCurrenciesForExchange(ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME);
- if (currenciesToUse != null) {
- for (String currency : currenciesToUse) {
- String loopItem = currency;
- String description = CurrencyConverter.INSTANCE.getCurrencyCodeToDescriptionMap().get(currency);
- if (description != null && description.trim().length() > 0) {
- loopItem = loopItem + " (" + description + ")";
- }
- currencyComboBox1.addItem(loopItem);
- }
- }
- }
- }
- oerMessageLabel1.setVisible(false);
- }
- if (ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME.equals((String)exchangeComboBox2.getSelectedItem())) {
- if (mainFrame != null && mainFrame.getTickerTimerTask2() != null) {
- TickerTimerTask tickerTimerTask = mainFrame.getTickerTimerTask2();
- synchronized (tickerTimerTask) {
- tickerTimerTask.createExchangeObjects(ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME);
- currencyComboBox2.removeAllItems();
- Collection currenciesToUse = ExchangeData.getAvailableCurrenciesForExchange(ExchangeData.OPEN_EXCHANGE_RATES_EXCHANGE_NAME);
- if (currenciesToUse != null) {
- for (String currency : currenciesToUse) {
- String loopItem = currency;
- String description = CurrencyConverter.INSTANCE.getCurrencyCodeToDescriptionMap().get(currency);
- if (description != null && description.trim().length() > 0) {
- loopItem = loopItem + " (" + description + ")";
- }
- currencyComboBox2.addItem(loopItem);
- }
- }
- }
- }
- oerMessageLabel2.setVisible(false);
- }
- }
- }
private JPanel createBrowserIntegrationPanel(int stentWidth) {
MultiBitTitledPanel browserIntegrationPanel = new MultiBitTitledPanel(controller.getLocaliser().getString(
@@ -1595,7 +1355,6 @@ private void enableTickerSecondRow(boolean enableTickerSecondRow) {
exchangeComboBox2.setEnabled(enableTickerSecondRow);
currencyLabel2.setEnabled(enableTickerSecondRow);
currencyComboBox2.setEnabled(enableTickerSecondRow);
- oerMessageLabel2.setEnabled(enableTickerSecondRow);
}
private ImageIcon createImageIcon(String text) {
@@ -1756,21 +1515,11 @@ public View getViewId() {
public String getPreviousUndoChangesText() {
return controller.getLocaliser().getString("undoPreferencesChangesSubmitAction.text");
}
-
- @Override
- public String getPreviousOpenExchangeRatesApiCode() {
- return originalOERApiCode;
- }
@Override
public boolean getNewMinimizeToTray() {
return minimizeToTrayCheckBox.isSelected();
}
-
- @Override
- public String getNewOpenExchangeRatesApiCode() {
- return oerApiCodeTextField.getText();
- }
@Override
diff --git a/src/main/resources/multidoge.checkpoints b/src/main/resources/multidoge.checkpoints
index ff04bc389..de3d10316 100644
Binary files a/src/main/resources/multidoge.checkpoints and b/src/main/resources/multidoge.checkpoints differ