/************************************************************************************* * Copyright (C) 2014-2016 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 com.generalbytes.batm.server.extensions.watchlist.IWatchList; 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 (Currencies.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) { } } String preferedFiatCurrency = Currencies.USD; if (st.hasMoreTokens()) { preferedFiatCurrency = st.nextToken().toUpperCase(); } return new FixPriceRateSource(rate,preferedFiatCurrency); } } return null; } @Override public IPaymentProcessor createPaymentProcessor(String paymentProcessorLogin) { return null; //no payment processors available } @Override public Set getSupportedCryptoCurrencies() { Set result = new HashSet(); result.add(Currencies.LEO); return result; } @Override public Set getSupportedWatchListsNames() { return null; } @Override public IWatchList getWatchList(String name) { return null; } }