Added LEOcoin support and fixprice rate source
This commit is contained in:
parent
001e23e392
commit
2fdece01ca
|
@ -23,6 +23,7 @@ public interface ICurrencies {
|
|||
public static final String LTC = "LTC";
|
||||
public static final String DOGE = "DOGE";
|
||||
public static final String MAX = "MAX";
|
||||
public static final String LEO = "LEO";
|
||||
|
||||
|
||||
public static final String CZK = "CZK";
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
<ratesource prefix="bitcoinaverage" name ="BitcoinAverage.com" >
|
||||
<cryptocurrency>BTC</cryptocurrency>
|
||||
</ratesource>
|
||||
<ratesource prefix="btcfix" name ="Fix Price" >
|
||||
<param name="price" />
|
||||
<cryptocurrency>BTC</cryptocurrency>
|
||||
</ratesource>
|
||||
<cryptologo cryptocurrency="BTC" file="btc.png"/>
|
||||
</extension>
|
||||
<extension class="com.generalbytes.batm.server.extensions.extra.dogecoin.DogecoinExtension">
|
||||
|
@ -33,6 +37,10 @@
|
|||
<ratesource prefix="dogeapi" name="DogeAPI.com" >
|
||||
<cryptocurrency>DOGE</cryptocurrency>
|
||||
</ratesource>
|
||||
<ratesource prefix="dogefix" name ="Fix Price" >
|
||||
<param name="price" />
|
||||
<cryptocurrency>DOGE</cryptocurrency>
|
||||
</ratesource>
|
||||
<cryptologo cryptocurrency="DOGE" file="doge.png"/>
|
||||
</extension>
|
||||
<extension class="com.generalbytes.batm.server.extensions.extra.litecoin.LitecoinExtension" >
|
||||
|
@ -49,6 +57,10 @@
|
|||
<cryptocurrency>LTC</cryptocurrency>
|
||||
<cryptocurrency>BTC</cryptocurrency>
|
||||
</ratesource>
|
||||
<ratesource prefix="ltcfix" name ="Fix Price" >
|
||||
<param name="price" />
|
||||
<cryptocurrency>LTC</cryptocurrency>
|
||||
</ratesource>
|
||||
<cryptologo cryptocurrency="LTC" file="ltc.png"/>
|
||||
</extension>
|
||||
<extension class="com.generalbytes.batm.server.extensions.extra.maxcoin.MaxcoinExtension" >
|
||||
|
@ -64,7 +76,27 @@
|
|||
<ratesource prefix="maxcointicker" name="Maxcointicker.com" >
|
||||
<cryptocurrency>MAX</cryptocurrency>
|
||||
</ratesource>
|
||||
<ratesource prefix="maxfix" name ="Fix Price" >
|
||||
<param name="price" />
|
||||
<cryptocurrency>MAX</cryptocurrency>
|
||||
</ratesource>
|
||||
<cryptologo cryptocurrency="MAX" file="max.png"/>
|
||||
</extension>
|
||||
<extension class="com.generalbytes.batm.server.extensions.extra.leocoin.LeocoinExtension" >
|
||||
<wallet prefix="leocoind" name="Leocoind">
|
||||
<param name="protocol" />
|
||||
<param name="user" />
|
||||
<param name="password" />
|
||||
<param name="host" />
|
||||
<param name="port" />
|
||||
<param name="accountname" />
|
||||
<cryptocurrency>LEO</cryptocurrency>
|
||||
</wallet>
|
||||
<ratesource prefix="leofix" name ="Fix Price" >
|
||||
<param name="price" />
|
||||
<cryptocurrency>LEO</cryptocurrency>
|
||||
</ratesource>
|
||||
<cryptologo cryptocurrency="LEO" file="leo.png"/>
|
||||
</extension>
|
||||
|
||||
</extensions>
|
Binary file not shown.
After Width: | Height: | Size: 6.4 KiB |
|
@ -19,8 +19,10 @@ package com.generalbytes.batm.server.extensions.extra.bitcoin;
|
|||
|
||||
import com.generalbytes.batm.server.extensions.*;
|
||||
import com.generalbytes.batm.server.extensions.extra.bitcoin.sources.BitcoinAverageRateSource;
|
||||
import com.generalbytes.batm.server.extensions.extra.bitcoin.sources.FixPriceRateSource;
|
||||
import com.generalbytes.batm.server.extensions.extra.bitcoin.wallets.bitcoind.BATMBitcoindRPCWallet;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
public class BitcoinExtension implements IExtension{
|
||||
|
@ -82,6 +84,15 @@ public class BitcoinExtension implements IExtension{
|
|||
|
||||
if ("bitcoinaverage".equalsIgnoreCase(exchangeType)) {
|
||||
return new BitcoinAverageRateSource();
|
||||
}else if ("btcfix".equalsIgnoreCase(exchangeType)) {
|
||||
BigDecimal rate = BigDecimal.ZERO;
|
||||
if (st.hasMoreTokens()) {
|
||||
try {
|
||||
rate = new BigDecimal(st.nextToken());
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
}
|
||||
return new FixPriceRateSource(rate);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package com.generalbytes.batm.server.extensions.extra.bitcoin.sources;
|
||||
|
||||
import com.generalbytes.batm.server.extensions.ICurrencies;
|
||||
import com.generalbytes.batm.server.extensions.IRateSource;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by b00lean on 7/31/14.
|
||||
*/
|
||||
public class FixPriceRateSource implements IRateSource {
|
||||
private BigDecimal rate = BigDecimal.ZERO;
|
||||
|
||||
public FixPriceRateSource(BigDecimal rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getCryptoCurrencies() {
|
||||
Set<String> result = new HashSet<String>();
|
||||
result.add(ICurrencies.BTC);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getExchangeRateLast(String cryptoCurrency, String fiatCurrency) {
|
||||
if (ICurrencies.BTC.equalsIgnoreCase(cryptoCurrency)) {
|
||||
return rate;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getFiatCurrencies() {
|
||||
Set<String> result = new HashSet<String>();
|
||||
result.add(ICurrencies.USD);
|
||||
result.add(ICurrencies.EUR);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -19,9 +19,11 @@ package com.generalbytes.batm.server.extensions.extra.dogecoin;
|
|||
|
||||
import com.generalbytes.batm.server.extensions.*;
|
||||
import com.generalbytes.batm.server.extensions.extra.dogecoin.sources.DogeAPIRateSource;
|
||||
import com.generalbytes.batm.server.extensions.extra.dogecoin.sources.FixPriceRateSource;
|
||||
import com.generalbytes.batm.server.extensions.extra.dogecoin.wallets.dogeapi.DogeAPIWallet;
|
||||
import com.generalbytes.batm.server.extensions.extra.dogecoin.wallets.dogecoind.DogecoindRPCWallet;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
public class DogecoinExtension implements IExtension{
|
||||
|
@ -91,6 +93,15 @@ public class DogecoinExtension implements IExtension{
|
|||
|
||||
if ("dogeapi".equalsIgnoreCase(exchangeType)) {
|
||||
return new DogeAPIRateSource();
|
||||
}else if ("dogefix".equalsIgnoreCase(exchangeType)) {
|
||||
BigDecimal rate = BigDecimal.ZERO;
|
||||
if (st.hasMoreTokens()) {
|
||||
try {
|
||||
rate = new BigDecimal(st.nextToken());
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
}
|
||||
return new FixPriceRateSource(rate);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package com.generalbytes.batm.server.extensions.extra.dogecoin.sources;
|
||||
|
||||
import com.generalbytes.batm.server.extensions.ICurrencies;
|
||||
import com.generalbytes.batm.server.extensions.IRateSource;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by b00lean on 7/31/14.
|
||||
*/
|
||||
public class FixPriceRateSource implements IRateSource {
|
||||
private BigDecimal rate = BigDecimal.ZERO;
|
||||
|
||||
public FixPriceRateSource(BigDecimal rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getCryptoCurrencies() {
|
||||
Set<String> result = new HashSet<String>();
|
||||
result.add(ICurrencies.DOGE);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getExchangeRateLast(String cryptoCurrency, String fiatCurrency) {
|
||||
if (!ICurrencies.DOGE.equalsIgnoreCase(cryptoCurrency)) {
|
||||
return rate;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getFiatCurrencies() {
|
||||
Set<String> result = new HashSet<String>();
|
||||
result.add(ICurrencies.USD);
|
||||
result.add(ICurrencies.EUR);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/*************************************************************************************
|
||||
* Copyright (C) 2014 GENERAL BYTES s.r.o. All rights reserved.
|
||||
*
|
||||
* This software may be distributed and modified under the terms of the GNU
|
||||
* General Public License version 2 (GPL2) as published by the Free Software
|
||||
* Foundation and appearing in the file GPL2.TXT included in the packaging of
|
||||
* this file. Please note that GPL2 Section 2[b] requires that all works based
|
||||
* on this software must also be made publicly available under the terms of
|
||||
* the GPL2 ("Copyleft").
|
||||
*
|
||||
* Contact information
|
||||
* -------------------
|
||||
*
|
||||
* GENERAL BYTES s.r.o.
|
||||
* Web : http://www.generalbytes.com
|
||||
*
|
||||
************************************************************************************/
|
||||
package com.generalbytes.batm.server.extensions.extra.leocoin;
|
||||
|
||||
import com.generalbytes.batm.server.coinutil.AddressFormatException;
|
||||
import com.generalbytes.batm.server.coinutil.Base58;
|
||||
import com.generalbytes.batm.server.extensions.ExtensionsUtil;
|
||||
import com.generalbytes.batm.server.extensions.ICryptoAddressValidator;
|
||||
|
||||
public class LeocoinAddressValidator implements ICryptoAddressValidator {
|
||||
|
||||
@Override
|
||||
public boolean isAddressValid(String address) {
|
||||
boolean result = isLeocoinAddressValid(address);
|
||||
if (!result) {
|
||||
result = isPaperWalletSupported() && ExtensionsUtil.isValidEmailAddress(address);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static boolean isLeocoinAddressValid(String address) {
|
||||
if (address.startsWith("L")) {
|
||||
try {
|
||||
Base58.decodeToBigInteger(address);
|
||||
Base58.decodeChecked(address);
|
||||
} catch (AddressFormatException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPaperWalletSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mustBeBase58Address() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
/*************************************************************************************
|
||||
* Copyright (C) 2014 GENERAL BYTES s.r.o. All rights reserved.
|
||||
*
|
||||
* This software may be distributed and modified under the terms of the GNU
|
||||
* General Public License version 2 (GPL2) as published by the Free Software
|
||||
* Foundation and appearing in the file GPL2.TXT included in the packaging of
|
||||
* this file. Please note that GPL2 Section 2[b] requires that all works based
|
||||
* on this software must also be made publicly available under the terms of
|
||||
* the GPL2 ("Copyleft").
|
||||
*
|
||||
* Contact information
|
||||
* -------------------
|
||||
*
|
||||
* GENERAL BYTES s.r.o.
|
||||
* Web : http://www.generalbytes.com
|
||||
*
|
||||
************************************************************************************/
|
||||
package com.generalbytes.batm.server.extensions.extra.leocoin;
|
||||
|
||||
import com.generalbytes.batm.server.extensions.*;
|
||||
import com.generalbytes.batm.server.extensions.extra.leocoin.sources.FixPriceRateSource;
|
||||
import com.generalbytes.batm.server.extensions.extra.leocoin.wallets.leocoind.LeocoindRPCWallet;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
public class LeocoinExtension implements IExtension{
|
||||
@Override
|
||||
public String getName() {
|
||||
return "BATM Leocoin extension";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IExchange createExchange(String exchangeLogin) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWallet createWallet(String walletLogin) {
|
||||
if (walletLogin !=null && !walletLogin.trim().isEmpty()) {
|
||||
StringTokenizer st = new StringTokenizer(walletLogin,":");
|
||||
String walletType = st.nextToken();
|
||||
|
||||
if ("leocoind".equalsIgnoreCase(walletType)) {
|
||||
//"leocoind:protocol:user:password:ip:port:accountname"
|
||||
|
||||
String protocol = st.nextToken();
|
||||
String username = st.nextToken();
|
||||
String password = st.nextToken();
|
||||
String hostname = st.nextToken();
|
||||
String port = st.nextToken();
|
||||
String accountName ="";
|
||||
if (st.hasMoreTokens()) {
|
||||
accountName = st.nextToken();
|
||||
}
|
||||
|
||||
|
||||
if (protocol != null && username != null && password != null && hostname !=null && port != null && accountName != null) {
|
||||
String rpcURL = protocol +"://" + username +":" + password + "@" + hostname +":" + port;
|
||||
return new LeocoindRPCWallet(rpcURL,accountName);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICryptoAddressValidator createAddressValidator(String cryptoCurrency) {
|
||||
if (ICurrencies.LEO.equalsIgnoreCase(cryptoCurrency)) {
|
||||
return new LeocoinAddressValidator();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPaperWalletGenerator createPaperWalletGenerator(String cryptoCurrency) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRateSource createRateSource(String sourceLogin) {
|
||||
if (sourceLogin != null && !sourceLogin.trim().isEmpty()) {
|
||||
StringTokenizer st = new StringTokenizer(sourceLogin,":");
|
||||
String exchangeType = st.nextToken();
|
||||
|
||||
if ("leofix".equalsIgnoreCase(exchangeType)) {
|
||||
BigDecimal rate = BigDecimal.ZERO;
|
||||
if (st.hasMoreTokens()) {
|
||||
try {
|
||||
rate = new BigDecimal(st.nextToken());
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
}
|
||||
return new FixPriceRateSource(rate);
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Set<String> getSupportedCryptoCurrencies() {
|
||||
Set<String> result = new HashSet<String>();
|
||||
result.add(ICurrencies.LEO);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.generalbytes.batm.server.extensions.extra.leocoin.sources;
|
||||
|
||||
import com.generalbytes.batm.server.extensions.ICurrencies;
|
||||
import com.generalbytes.batm.server.extensions.IRateSource;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by b00lean on 7/31/14.
|
||||
*/
|
||||
public class FixPriceRateSource implements IRateSource {
|
||||
private BigDecimal rate = BigDecimal.ZERO;
|
||||
|
||||
public FixPriceRateSource(BigDecimal rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getCryptoCurrencies() {
|
||||
Set<String> result = new HashSet<String>();
|
||||
result.add(ICurrencies.LEO);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getExchangeRateLast(String cryptoCurrency, String fiatCurrency) {
|
||||
if (ICurrencies.LEO.equalsIgnoreCase(cryptoCurrency)) {
|
||||
return rate;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getFiatCurrencies() {
|
||||
Set<String> result = new HashSet<String>();
|
||||
result.add(ICurrencies.USD);
|
||||
result.add(ICurrencies.EUR);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,120 @@
|
|||
/*************************************************************************************
|
||||
* Copyright (C) 2014 GENERAL BYTES s.r.o. All rights reserved.
|
||||
*
|
||||
* This software may be distributed and modified under the terms of the GNU
|
||||
* General Public License version 2 (GPL2) as published by the Free Software
|
||||
* Foundation and appearing in the file GPL2.TXT included in the packaging of
|
||||
* this file. Please note that GPL2 Section 2[b] requires that all works based
|
||||
* on this software must also be made publicly available under the terms of
|
||||
* the GPL2 ("Copyleft").
|
||||
*
|
||||
* Contact information
|
||||
* -------------------
|
||||
*
|
||||
* GENERAL BYTES s.r.o.
|
||||
* Web : http://www.generalbytes.com
|
||||
*
|
||||
************************************************************************************/
|
||||
package com.generalbytes.batm.server.extensions.extra.leocoin.wallets.leocoind;
|
||||
|
||||
import com.azazar.bitcoin.jsonrpcclient.BitcoinException;
|
||||
import com.azazar.bitcoin.jsonrpcclient.BitcoinJSONRPCClient;
|
||||
import com.generalbytes.batm.server.extensions.ICurrencies;
|
||||
import com.generalbytes.batm.server.extensions.IWallet;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class LeocoindRPCWallet implements IWallet{
|
||||
private static final Logger log = LoggerFactory.getLogger(LeocoindRPCWallet.class);
|
||||
private static final String CRYPTO_CURRENCY = ICurrencies.LEO;
|
||||
|
||||
public LeocoindRPCWallet(String rpcURL, String accountName) {
|
||||
this.rpcURL = rpcURL;
|
||||
this.accountName = accountName;
|
||||
}
|
||||
|
||||
private String rpcURL;
|
||||
private String accountName;
|
||||
|
||||
@Override
|
||||
public Set<String> getCryptoCurrencies() {
|
||||
Set<String> result = new HashSet<String>();
|
||||
result.add(CRYPTO_CURRENCY);
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferredCryptoCurrency() {
|
||||
return CRYPTO_CURRENCY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sendCoins(String destinationAddress, BigDecimal amount, String cryptoCurrency) {
|
||||
if (!CRYPTO_CURRENCY.equalsIgnoreCase(cryptoCurrency)) {
|
||||
log.error("Leocoind wallet error: unknown cryptocurrency.");
|
||||
return null;
|
||||
}
|
||||
|
||||
log.info("Leocoind sending coins from " + accountName + " to: " + destinationAddress + " " + amount);
|
||||
try {
|
||||
String result = getClient(rpcURL).sendFrom(accountName, destinationAddress,amount.doubleValue());
|
||||
log.debug("result = " + result);
|
||||
return result;
|
||||
} catch (BitcoinException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCryptoAddress(String cryptoCurrency) {
|
||||
if (!CRYPTO_CURRENCY.equalsIgnoreCase(cryptoCurrency)) {
|
||||
log.error("Leocoind wallet error: unknown cryptocurrency.");
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
List<String> addressesByAccount = getClient(rpcURL).getAddressesByAccount(accountName);
|
||||
if (addressesByAccount == null || addressesByAccount.size() == 0) {
|
||||
return null;
|
||||
}else{
|
||||
return addressesByAccount.get(0);
|
||||
}
|
||||
} catch (BitcoinException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getCryptoBalance(String cryptoCurrency) {
|
||||
if (!CRYPTO_CURRENCY.equalsIgnoreCase(cryptoCurrency)) {
|
||||
log.error("Leocoind wallet error: unknown cryptocurrency: " + cryptoCurrency);
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
double balance = getClient(rpcURL).getBalance(accountName);
|
||||
return new BigDecimal(balance);
|
||||
} catch (BitcoinException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private BitcoinJSONRPCClient getClient(String rpcURL) {
|
||||
try {
|
||||
return new BitcoinJSONRPCClient(rpcURL);
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -18,9 +18,11 @@
|
|||
package com.generalbytes.batm.server.extensions.extra.litecoin;
|
||||
|
||||
import com.generalbytes.batm.server.extensions.*;
|
||||
import com.generalbytes.batm.server.extensions.extra.litecoin.sources.FixPriceRateSource;
|
||||
import com.generalbytes.batm.server.extensions.extra.litecoin.sources.btce.BTCeRateSource;
|
||||
import com.generalbytes.batm.server.extensions.extra.litecoin.wallets.litecoind.LitecoindRPCWallet;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
public class LitecoinExtension implements IExtension{
|
||||
|
@ -84,8 +86,18 @@ public class LitecoinExtension implements IExtension{
|
|||
|
||||
if ("btce".equalsIgnoreCase(exchangeType)) {
|
||||
return new BTCeRateSource();
|
||||
}else if ("ltcfix".equalsIgnoreCase(exchangeType)) {
|
||||
BigDecimal rate = BigDecimal.ZERO;
|
||||
if (st.hasMoreTokens()) {
|
||||
try {
|
||||
rate = new BigDecimal(st.nextToken());
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
}
|
||||
return new FixPriceRateSource(rate);
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package com.generalbytes.batm.server.extensions.extra.litecoin.sources;
|
||||
|
||||
import com.generalbytes.batm.server.extensions.ICurrencies;
|
||||
import com.generalbytes.batm.server.extensions.IRateSource;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by b00lean on 7/31/14.
|
||||
*/
|
||||
public class FixPriceRateSource implements IRateSource {
|
||||
private BigDecimal rate = BigDecimal.ZERO;
|
||||
|
||||
public FixPriceRateSource(BigDecimal rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getCryptoCurrencies() {
|
||||
Set<String> result = new HashSet<String>();
|
||||
result.add(ICurrencies.LTC);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getExchangeRateLast(String cryptoCurrency, String fiatCurrency) {
|
||||
if (ICurrencies.LTC.equalsIgnoreCase(cryptoCurrency)) {
|
||||
return rate;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getFiatCurrencies() {
|
||||
Set<String> result = new HashSet<String>();
|
||||
result.add(ICurrencies.USD);
|
||||
result.add(ICurrencies.EUR);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -18,9 +18,11 @@
|
|||
package com.generalbytes.batm.server.extensions.extra.maxcoin;
|
||||
|
||||
import com.generalbytes.batm.server.extensions.*;
|
||||
import com.generalbytes.batm.server.extensions.extra.maxcoin.sources.FixPriceRateSource;
|
||||
import com.generalbytes.batm.server.extensions.extra.maxcoin.sources.MaxcoinTickerRateSource;
|
||||
import com.generalbytes.batm.server.extensions.extra.maxcoin.wallets.maxcoind.MaxcoindRPCWallet;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
@ -86,8 +88,18 @@ public class MaxcoinExtension implements IExtension{
|
|||
|
||||
if ("maxcointicker".equalsIgnoreCase(exchangeType)) {
|
||||
return new MaxcoinTickerRateSource();
|
||||
}else if ("maxfix".equalsIgnoreCase(exchangeType)) {
|
||||
BigDecimal rate = BigDecimal.ZERO;
|
||||
if (st.hasMoreTokens()) {
|
||||
try {
|
||||
rate = new BigDecimal(st.nextToken());
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
}
|
||||
return new FixPriceRateSource(rate);
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package com.generalbytes.batm.server.extensions.extra.maxcoin.sources;
|
||||
|
||||
import com.generalbytes.batm.server.extensions.ICurrencies;
|
||||
import com.generalbytes.batm.server.extensions.IRateSource;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by b00lean on 7/31/14.
|
||||
*/
|
||||
public class FixPriceRateSource implements IRateSource {
|
||||
private BigDecimal rate = BigDecimal.ZERO;
|
||||
|
||||
public FixPriceRateSource(BigDecimal rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getCryptoCurrencies() {
|
||||
Set<String> result = new HashSet<String>();
|
||||
result.add(ICurrencies.MAX);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getExchangeRateLast(String cryptoCurrency, String fiatCurrency) {
|
||||
if (ICurrencies.MAX.equalsIgnoreCase(cryptoCurrency)) {
|
||||
return rate;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getFiatCurrencies() {
|
||||
Set<String> result = new HashSet<String>();
|
||||
result.add(ICurrencies.USD);
|
||||
result.add(ICurrencies.EUR);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue