Merge branch 'master' into add-egulden

This commit is contained in:
Dennis Ruhe 2018-06-07 20:58:38 +02:00 committed by GitHub
commit f963adb04b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 553 additions and 316 deletions

13
.editorconfig Normal file
View File

@ -0,0 +1,13 @@
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
tab_width = 4
trim_trailing_whitespace = true
insert_final_newline = false

6
.gitignore vendored
View File

@ -8,4 +8,8 @@ out/
*.iml
target
install-libs.sh
.mvn-repo
.mvn-repo
..gitignore.swp
.project
.classpath
.settings/

View File

@ -21,7 +21,7 @@ Here is the list of functionality that can be extended with extenstions API:
Content
=======
* **server_extensions_api** - contains extension api that all extensions use to extend BATM Server's functionality.
* **server_extensions_extra** - reference extension implementation that implements BTC, LTC, DGB, DASH, FLASH, DOGE, NLG, ICG, NBT, GRS and MAX coin support functionality.
* **server_extensions_extra** - reference extension implementation that implements BTC, LTC, DGB, DASH, SYS, FLASH, DOGE, NLG, ICG, NBT, GRS and MAX coin support functionality.
* **server_extensions_test** - contains tester for testing the extensions without requirement of having a BATM server
Note for developers

Binary file not shown.

View File

@ -1,6 +1,5 @@
#Fri Feb 02 13:42:34 CET 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip

View File

@ -8,6 +8,7 @@ version = projectVersion
jar {
baseName 'batm_server_extensions_api'
archiveName "${baseName}.${extension}"
}
distributions {
@ -25,20 +26,22 @@ dependencies {
compile(group: 'com.sun.mail', name: 'javax.mail', version: '1.4.7')
}
publishing {
repositories {
maven {
credentials {
username gbArtifactoryUser
password gbArtifactoryPassword
if (hasProperty('gbArtifactoryUser') && hasProperty('gbArtifactoryPassword') && hasProperty('gbArtifactoryUploadUrl')) {
publishing {
repositories {
maven {
credentials {
username gbArtifactoryUser
password gbArtifactoryPassword
}
url gbArtifactoryUploadUrl
}
url gbArtifactoryUploadUrl
}
}
publications {
mavenJava(MavenPublication) {
from components.java
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
}
}

View File

@ -141,7 +141,7 @@ public enum Country {
LT("LT", "LTU", "Lithuania"),
LU("LU", "LUX", "Luxembourg"),
MO("MO", "MAC", "Macao"),
MK("MK", "MKD", "Macedonia (the former Yugoslav Republic of)"),
MK("MK", "MKD", "Macedonia"),
MG("MG", "MDG", "Madagascar"),
MW("MW", "MWI", "Malawi"),
MY("MY", "MYS", "Malaysia"),

View File

@ -46,10 +46,12 @@ public class Currencies {
public static final String POT = "POT";
public static final String SMART = "SMART";
public static final String START = "START";
public static final String SYS = "SYS"; // Syscoin 3
public static final String TKN = "TKN";
public static final String WDC = "WDC";
public static final String XMR = "XMR";
public static final String AMD = "AMD";
public static final String CAD = "CAD";
public static final String CHF = "CHF";
public static final String CNY = "CNY";
@ -58,6 +60,8 @@ public class Currencies {
public static final String GBP = "GBP";
public static final String HUF = "HUF";
public static final String JPY = "JPY";
public static final String MKD = "MKD";
public static final String MYR = "MYR";
public static final String SGD = "SGD";
public static final String USD = "USD";
public static final String XAF = "XAF";
@ -91,12 +95,14 @@ public class Currencies {
crypto.add(POT);
crypto.add(SMART);
crypto.add(START);
crypto.add(SYS);
crypto.add(TKN);
crypto.add(WDC);
crypto.add(XMR);
CRYPTO_CURRENCIES = Collections.unmodifiableList(crypto);
List<String> fiat = new ArrayList<>();
fiat.add(AMD);
fiat.add(CAD);
fiat.add(CHF);
fiat.add(CNY);
@ -105,6 +111,8 @@ public class Currencies {
fiat.add(GBP);
fiat.add(HUF);
fiat.add(JPY);
fiat.add(MKD);
fiat.add(MYR);
fiat.add(SGD);
fiat.add(USD);
fiat.add(XAF);

View File

@ -8,6 +8,7 @@ version = projectVersion
jar {
baseName 'batm_server_extensions_extra'
archiveName "${baseName}.${extension}"
}
configurations {
@ -22,7 +23,7 @@ artifacts {
}
dependencies {
compile project(':server_extensions_api');
compile project(':server_extensions_api')
compile(group: 'com.azazar', name: 'bitcoin-json-rpc-client', version: '1.0')
compile(group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25')
compile(group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25')
@ -31,11 +32,11 @@ dependencies {
compile(group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.8.0')
compile(group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.2')
compile(group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.2')
compile(group: 'org.knowm.xchange', name: 'xchange-core', version: '4.2.1')
compile(group: 'org.knowm.xchange', name: 'xchange-core', version: '4.2.3')
compile(group: 'com.google.guava', name: 'guava', version: '18.0')
compile(group: 'com.google.zxing', name: 'core', version: '2.3.0')
compile(group: 'org.knowm.xchange', name: 'xchange-bitfinex', version: '4.2.1')
compile(group: 'org.knowm.xchange', name: 'xchange-itbit', version: '4.2.1')
compile(group: 'org.knowm.xchange', name: 'xchange-bitfinex', version: '4.2.3')
compile(group: 'org.knowm.xchange', name: 'xchange-itbit', version: '4.2.3')
}
dependencySubstitutions {
@ -51,20 +52,22 @@ distributions {
}
}
publishing {
repositories {
maven {
credentials {
username gbArtifactoryUser
password gbArtifactoryPassword
if (hasProperty('gbArtifactoryUser') && hasProperty('gbArtifactoryPassword') && hasProperty('gbArtifactoryUploadUrl')) {
publishing {
repositories {
maven {
credentials {
username gbArtifactoryUser
password gbArtifactoryPassword
}
url gbArtifactoryUploadUrl
}
url gbArtifactoryUploadUrl
}
}
publications {
mavenJava(MavenPublication) {
from components.java
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
}

View File

@ -1,158 +0,0 @@
package com.generalbytes.batm.server.extensions.extra.dash.sources.coinmarketcap;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.math.BigDecimal;
/**
* Created by kkyovsky on 11/29/17.
*/
public class CMCTicker {
private String id;
private String name;
private String symbol;
private BigDecimal rank;
private BigDecimal price_usd;
private BigDecimal price_eur;
private BigDecimal price_btc;
@JsonProperty("24h_volume_usd")
private BigDecimal _24h_volume_usd;
private BigDecimal market_cap_usd;
private BigDecimal available_supply;
private BigDecimal total_supply;
private BigDecimal max_supply;
private BigDecimal percent_change_1h;
private BigDecimal percent_change_24h;
private BigDecimal percent_change_7d;
private long last_updated;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSymbol() {
return symbol;
}
public void setSymbol(String symbol) {
this.symbol = symbol;
}
public BigDecimal getRank() {
return rank;
}
public void setRank(BigDecimal rank) {
this.rank = rank;
}
public BigDecimal getPrice_usd() {
return price_usd;
}
public void setPrice_usd(BigDecimal price_usd) {
this.price_usd = price_usd;
}
public BigDecimal getPrice_eur() {
return price_eur;
}
public void setPrice_eur(BigDecimal price_eur) {
this.price_eur = price_eur;
}
public BigDecimal getPrice_btc() {
return price_btc;
}
public void setPrice_btc(BigDecimal price_btc) {
this.price_btc = price_btc;
}
public BigDecimal get_24h_volume_usd() {
return _24h_volume_usd;
}
public void set_24h_volume_usd(BigDecimal _24h_volume_usd) {
this._24h_volume_usd = _24h_volume_usd;
}
public BigDecimal getMarket_cap_usd() {
return market_cap_usd;
}
public void setMarket_cap_usd(BigDecimal market_cap_usd) {
this.market_cap_usd = market_cap_usd;
}
public BigDecimal getAvailable_supply() {
return available_supply;
}
public void setAvailable_supply(BigDecimal available_supply) {
this.available_supply = available_supply;
}
public BigDecimal getTotal_supply() {
return total_supply;
}
public void setTotal_supply(BigDecimal total_supply) {
this.total_supply = total_supply;
}
public BigDecimal getMax_supply() {
return max_supply;
}
public void setMax_supply(BigDecimal max_supply) {
this.max_supply = max_supply;
}
public BigDecimal getPercent_change_1h() {
return percent_change_1h;
}
public void setPercent_change_1h(BigDecimal percent_change_1h) {
this.percent_change_1h = percent_change_1h;
}
public BigDecimal getPercent_change_24h() {
return percent_change_24h;
}
public void setPercent_change_24h(BigDecimal percent_change_24h) {
this.percent_change_24h = percent_change_24h;
}
public BigDecimal getPercent_change_7d() {
return percent_change_7d;
}
public void setPercent_change_7d(BigDecimal percent_change_7d) {
this.percent_change_7d = percent_change_7d;
}
public long getLast_updated() {
return last_updated;
}
public void setLast_updated(long last_updated) {
this.last_updated = last_updated;
}
}

View File

@ -1,22 +1,23 @@
package com.generalbytes.batm.server.extensions.extra.dash.sources.coinmarketcap;
import com.generalbytes.batm.server.extensions.Currencies;
import com.generalbytes.batm.server.extensions.Currencies;
import com.generalbytes.batm.server.extensions.IRateSource;
import java.math.BigDecimal;
import java.util.HashSet;
import java.util.Set;
import java.util.HashMap;
import java.util.Map;
import si.mazi.rescu.RestProxyFactory;
/**
* Created by kkyovsky on 11/29/17.
*
* Modified by sidhujag on 6/3/2018
*/
public class CoinmarketcapRateSource implements IRateSource {
private ICoinmarketcapAPI api;
private static HashMap<String,Integer> coinIDs = new HashMap<String, Integer>();
private String preferredFiatCurrency = Currencies.USD;
public CoinmarketcapRateSource(String preferedFiatCurrency) {
@ -27,6 +28,20 @@ public class CoinmarketcapRateSource implements IRateSource {
if (Currencies.USD.equalsIgnoreCase(preferedFiatCurrency)) {
this.preferredFiatCurrency = Currencies.USD;
}
if (Currencies.CAD.equalsIgnoreCase(preferedFiatCurrency)) {
this.preferredFiatCurrency = Currencies.CAD;
}
coinIDs.put(Currencies.BTC, 1);
coinIDs.put(Currencies.SYS, 541);
coinIDs.put(Currencies.BCH, 1831);
coinIDs.put(Currencies.BTX, 1654);
coinIDs.put(Currencies.LTC, 2);
coinIDs.put(Currencies.ETH, 1027);
coinIDs.put(Currencies.DASH, 131);
coinIDs.put(Currencies.XMR, 328);
coinIDs.put(Currencies.POT, 122);
coinIDs.put(Currencies.FLASH, 1755);
coinIDs.put(Currencies.EFL, 234);
}
public CoinmarketcapRateSource() {
@ -37,6 +52,7 @@ public class CoinmarketcapRateSource implements IRateSource {
public Set<String> getCryptoCurrencies() {
Set<String> result = new HashSet<String>();
result.add(Currencies.BTC);
result.add(Currencies.SYS);
result.add(Currencies.BCH);
result.add(Currencies.BTX);
result.add(Currencies.LTC);
@ -54,6 +70,7 @@ public class CoinmarketcapRateSource implements IRateSource {
public Set<String> getFiatCurrencies() {
Set<String> result = new HashSet<String>();
result.add(Currencies.USD);
result.add(Currencies.CAD);
result.add(Currencies.EUR);
return result;
}
@ -71,40 +88,27 @@ public class CoinmarketcapRateSource implements IRateSource {
return null;
}
/**
* Cannot get specific ticker by coin code, only by name or 'id value'
* Get specific ID values for your coin from https://api.coinmarketcap.com/v2/listings/
* for instance data[105] -> id 234 for e-Gulden
*/
CMCTicker[] tickers;
if(Currencies.FLASH.equalsIgnoreCase(cryptoCurrency)) {
tickers = api.getTickers(cryptoCurrency, fiatCurrency);
} else if (Currencies.EFL.equalsIgnoreCase(cryptoCurrency)) {
tickers = api.getTickers("234", fiatCurrency);
} else {
tickers = api.getTickers(fiatCurrency);
Integer cryptoId = coinIDs.get(cryptoCurrency);
if(cryptoId == null){
return null;
}
for (int i = 0; i < tickers.length; i++) {
CMCTicker ticker = tickers[i];
System.out.println("Ticker symbol: " + ticker.getSymbol());
if (cryptoCurrency.equalsIgnoreCase(ticker.getSymbol())) {
if (Currencies.EUR.equalsIgnoreCase(fiatCurrency)) {
return ticker.getPrice_eur();
}else{
return ticker.getPrice_usd();
}
}
Map<String, Object> ticker = api.getTickers(cryptoId, fiatCurrency);
if(ticker == null){
return null;
}
return null;
Map<String, Object> data = (Map<String, Object>) ticker.get("data");
if(data == null){
return null;
}
Map<String, Object> quotes = (Map<String, Object>) data.get("quotes");
if(quotes == null){
return null;
}
Map<String, Object> quote = (Map<String, Object>) quotes.get(fiatCurrency);
if(quote == null){
return null;
}
double price = (double) quote.get("price");
return new BigDecimal(price).setScale(2, BigDecimal.ROUND_HALF_EVEN);
}
// public static void main(String[] args) {
// CoinmarketcapRateSource rs = new CoinmarketcapRateSource(Currencies.EUR);
// BigDecimal exchangeRateLast = rs.getExchangeRateLast(Currencies.BTC, Currencies.EUR);
// System.out.println("exchangeRateLast = " + exchangeRateLast);
// }
}

View File

@ -19,15 +19,11 @@ package com.generalbytes.batm.server.extensions.extra.dash.sources.coinmarketcap
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
@Path("/v1/ticker")
import java.util.Map;
@Path("/v2/ticker")
@Produces(MediaType.APPLICATION_JSON)
public interface ICoinmarketcapAPI {
@GET
@Path("/")
CMCTicker[] getTickers(@QueryParam("convert") String fiatCurrency);
@GET
@Path("/{cryptoToGet}/?convert={convert}")
CMCTicker[] getTickers(@PathParam("cryptoToGet") String cryptoToGet,@QueryParam("convert") String fiatCurrency);
@Path("/{id}/")
Map<String, Object> getTickers(@PathParam("id") Integer id, @QueryParam("convert") String fiatCurrency);
}

View File

@ -0,0 +1,52 @@
/*************************************************************************************
* 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.syscoin;
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 SyscoinAddressValidator implements ICryptoAddressValidator {
@Override
public boolean isAddressValid(String address) {
if (address.startsWith("S")) {
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;
}
}

View File

@ -0,0 +1,133 @@
/*************************************************************************************
* 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.syscoin;
import com.generalbytes.batm.server.extensions.*;
import com.generalbytes.batm.server.extensions.extra.syscoin.sources.FixPriceRateSource;
import com.generalbytes.batm.server.extensions.extra.dash.sources.coinmarketcap.CoinmarketcapRateSource;
import com.generalbytes.batm.server.extensions.extra.syscoin.wallets.syscoind.SyscoinRPCWallet;
import com.generalbytes.batm.server.extensions.watchlist.IWatchList;
import java.math.BigDecimal;
import java.util.*;
public class SyscoinExtension implements IExtension{
@Override
public String getName() {
return "BATM Syscoin extra extension";
}
@Override
public IExchange createExchange(String exchangeLogin) {
return null;
}
@Override
public IPaymentProcessor createPaymentProcessor(String paymentProcessorLogin) {
return null; //no payment processors available
}
@Override
public IWallet createWallet(String walletLogin) {
if (walletLogin !=null && !walletLogin.trim().isEmpty()) {
StringTokenizer st = new StringTokenizer(walletLogin,":");
String walletType = st.nextToken();
if ("syscoind".equalsIgnoreCase(walletType)) {
//"syscoind: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 SyscoinRPCWallet(rpcURL,accountName);
}
}
}
return null;
}
@Override
public ICryptoAddressValidator createAddressValidator(String cryptoCurrency) {
if (Currencies.SYS.equalsIgnoreCase(cryptoCurrency)) {
return new SyscoinAddressValidator();
}
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 ("syscoinfix".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);
} else if ("coinmarketcap".equalsIgnoreCase(exchangeType)) {
String preferedFiatCurrency = Currencies.USD;
if (st.hasMoreTokens()) {
preferedFiatCurrency = st.nextToken().toUpperCase();
}
return new CoinmarketcapRateSource(preferedFiatCurrency);
}
}
return null;
}
@Override
public Set<String> getSupportedCryptoCurrencies() {
Set<String> result = new HashSet<String>();
result.add(Currencies.SYS);
return result;
}
@Override
public Set<String> getSupportedWatchListsNames() {
return null;
}
@Override
public IWatchList getWatchList(String name) {
return null;
}
}

View File

@ -0,0 +1,60 @@
package com.generalbytes.batm.server.extensions.extra.syscoin.sources;
import com.generalbytes.batm.server.extensions.Currencies;
import com.generalbytes.batm.server.extensions.Currencies;
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;
private String preferedFiatCurrency = Currencies.USD;
public FixPriceRateSource(BigDecimal rate,String preferedFiatCurrency) {
this.rate = rate;
if (Currencies.EUR.equalsIgnoreCase(preferedFiatCurrency)) {
this.preferedFiatCurrency = Currencies.EUR;
}
if (Currencies.USD.equalsIgnoreCase(preferedFiatCurrency)) {
this.preferedFiatCurrency = Currencies.USD;
}
if (Currencies.CAD.equalsIgnoreCase(preferedFiatCurrency)) {
this.preferedFiatCurrency = Currencies.CAD;
}
}
@Override
public Set<String> getCryptoCurrencies() {
Set<String> result = new HashSet<String>();
result.add(Currencies.SYS);
return result;
}
@Override
public BigDecimal getExchangeRateLast(String cryptoCurrency, String fiatCurrency) {
if (Currencies.SYS.equalsIgnoreCase(cryptoCurrency)) {
return rate;
}
return null;
}
@Override
public Set<String> getFiatCurrencies() {
Set<String> result = new HashSet<String>();
result.add(Currencies.USD);
result.add(Currencies.CAD);
result.add(Currencies.EUR);
return result;
}
@Override
public String getPreferredFiatCurrency() {
return preferedFiatCurrency;
}
}

View File

@ -0,0 +1,119 @@
/*************************************************************************************
* 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.syscoin.wallets.syscoind;
import com.azazar.bitcoin.jsonrpcclient.BitcoinException;
import com.azazar.bitcoin.jsonrpcclient.BitcoinJSONRPCClient;
import com.generalbytes.batm.server.extensions.Currencies;
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 SyscoinRPCWallet implements IWallet{
private static final Logger log = LoggerFactory.getLogger(SyscoinRPCWallet.class);
private static final String CRYPTO_CURRENCY = Currencies.SYS;
public SyscoinRPCWallet(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, String description) {
if (!CRYPTO_CURRENCY.equalsIgnoreCase(cryptoCurrency)) {
log.error("Syscoind wallet error: unknown cryptocurrency.");
return null;
}
log.info("Syscoind 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("Syscoind 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("Syscoind wallet error: unknown cryptocurrency: " + cryptoCurrency);
return null;
}
try {
double balance = getClient(rpcURL).getBalance(accountName);
return BigDecimal.valueOf(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;
}
}

View File

@ -57,6 +57,7 @@
<ratesource prefix="coinmarketcap" name ="CoinMarketCap.com" >
<param name="fiatcurrency" />
<cryptocurrency>BTC</cryptocurrency>
<cryptocurrency>SYS</cryptocurrency>
<cryptocurrency>BCH</cryptocurrency>
<cryptocurrency>LTC</cryptocurrency>
<cryptocurrency>ETH</cryptocurrency>
@ -140,10 +141,6 @@
<cryptocurrency>FLASH</cryptocurrency>
<cryptocurrency>BTC</cryptocurrency>
</ratesource>
<!--ratesource prefix="coinmarketcap" name ="coinmarketcap.com" >
<param name="fiatcurrency" />
<cryptocurrency>FLASH</cryptocurrency>
</ratesource-->
<ratesource prefix="flashfix" name ="Fix Price" >
<param name="price" />
<cryptocurrency>FLASH</cryptocurrency>
@ -228,6 +225,22 @@
</ratesource>
<cryptologo cryptocurrency="DASH" file="dash.png"/>
</extension>
<extension class="com.generalbytes.batm.server.extensions.extra.syscoin.SyscoinExtension" >
<wallet prefix="syscoind" name="syscoind">
<param name="protocol" />
<param name="user" />
<param name="password" />
<param name="host" />
<param name="port" />
<param name="accountname" />
<cryptocurrency>SYS</cryptocurrency>
</wallet>
<ratesource prefix="syscoinfix" name ="Fix Price" >
<param name="price" />
<cryptocurrency>SYS</cryptocurrency>
</ratesource>
<cryptologo cryptocurrency="SYS" file="sys.png"/>
</extension>
<extension class="com.generalbytes.batm.server.extensions.extra.digibyte.DigiByteExtension" >
<wallet prefix="digibyted" name="Digibyted">
<param name="protocol" />
@ -415,10 +428,6 @@
<param name="price" />
<cryptocurrency>POT</cryptocurrency>
</ratesource>
<ratesource prefix="coinmarketcap" name ="coinmarketcap.com" >
<param name="fiatcurrency" />
<cryptocurrency>POT</cryptocurrency>
</ratesource>
<cryptologo cryptocurrency="POT" file="pot.png"/>
</extension>
<extension class="com.generalbytes.batm.server.extensions.extra.dexacoin.DexCoinSupport">
@ -448,10 +457,6 @@
<param name="accountname" />
<cryptocurrency>BTX</cryptocurrency>
</wallet>
<ratesource prefix="coinmarketcap" name ="coinmarketcap.com" >
<param name="fiatcurrency" />
<cryptocurrency>BTX</cryptocurrency>
</ratesource>
<ratesource prefix="btxfix" name ="Fix Price" >
<param name="price" />
<cryptocurrency>BTX</cryptocurrency>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -397,50 +397,46 @@ public class Tester {
final String preferredFiatCurrency = rs.getPreferredFiatCurrency();
final Set<String> fiatCurrencies = rs.getFiatCurrencies();
final Set<String> cryptoCurrencies = rs.getCryptoCurrencies();
System.out.println("Preferred Fiat Currency = " + preferredFiatCurrency);
System.out.println("Fiat Currencies:");
for (String fiatCurrency : fiatCurrencies) {
System.out.println(" " + fiatCurrency);
}
for (String selectedCryptoCurrency : cryptoCurrencies) {
System.out.println("Crypto Currency:");
System.out.println(" " + selectedCryptoCurrency);
final BigDecimal exchangeRateLast = rs.getExchangeRateLast(selectedCryptoCurrency, preferredFiatCurrency);
if (exchangeRateLast != null) {
System.out.println("Exchange Rate Last: 1 " + selectedCryptoCurrency + " = " + exchangeRateLast.stripTrailingZeros().toPlainString() + " " + preferredFiatCurrency);
}else{
System.err.println("Rate source returned NULL.");
}
System.out.println("Preferred Fiat Currency = " + preferredFiatCurrency);
System.out.println("Fiat Currencies:");
for (String fiatCurrency : fiatCurrencies) {
System.out.println(" " + fiatCurrency);
}
System.out.println("Crypto Currencies:");
String selectedCryptoCurrency = params;
for (String cryptoCurrency : cryptoCurrencies) {
if (selectedCryptoCurrency == null) {
selectedCryptoCurrency = cryptoCurrency;
}
System.out.println(" " + cryptoCurrency);
}
final BigDecimal exchangeRateLast = rs.getExchangeRateLast(selectedCryptoCurrency, preferredFiatCurrency);
if (exchangeRateLast != null) {
System.out.println("Exchange Rate Last: 1 " + selectedCryptoCurrency + " = " + exchangeRateLast.stripTrailingZeros().toPlainString() + " " + preferredFiatCurrency);
}else{
System.err.println("Rate source returned NULL.");
}
if (rs instanceof IRateSourceAdvanced) {
IRateSourceAdvanced rsa = (IRateSourceAdvanced)rs;
if (rs instanceof IRateSourceAdvanced) {
IRateSourceAdvanced rsa = (IRateSourceAdvanced)rs;
for (String fiatCurrency : fiatCurrencies) {
System.out.println("Checking price for " + fiatCurrency);
for (String fiatCurrency : fiatCurrencies) {
System.out.println("Checking price for " + fiatCurrency);
final BigDecimal buyPrice = rsa.getExchangeRateForBuy(selectedCryptoCurrency, fiatCurrency);
if (buyPrice != null) {
System.out.println("Buy Price: 1 " + selectedCryptoCurrency + " = " + buyPrice.stripTrailingZeros().toPlainString() + " " + fiatCurrency);
}else{
System.err.println("Rate source returned NULL on Buy Price.");
}
final BigDecimal buyPrice = rsa.getExchangeRateForBuy(selectedCryptoCurrency, fiatCurrency);
if (buyPrice != null) {
System.out.println("Buy Price: 1 " + selectedCryptoCurrency + " = " + buyPrice.stripTrailingZeros().toPlainString() + " " + fiatCurrency);
}else{
System.err.println("Rate source returned NULL on Buy Price.");
}
final BigDecimal sellPrice = rsa.getExchangeRateForSell(selectedCryptoCurrency, fiatCurrency);
if (sellPrice != null) {
System.out.println("Sell Price: 1 " + selectedCryptoCurrency + " = " + sellPrice.stripTrailingZeros().toPlainString() + " " + fiatCurrency);
}else{
System.err.println("Rate source returned NULL on Sell Price.");
}
final BigDecimal sellPrice = rsa.getExchangeRateForSell(selectedCryptoCurrency, fiatCurrency);
if (sellPrice != null) {
System.out.println("Sell Price: 1 " + selectedCryptoCurrency + " = " + sellPrice.stripTrailingZeros().toPlainString() + " " + fiatCurrency);
}else{
System.err.println("Rate source returned NULL on Sell Price.");
}
}
}
}
}
}
return;
}
}
@ -477,38 +473,38 @@ public class Tester {
}
private void getExchangeBalance(String name, String params) {
for (int i = 0; i < extensions.size(); i++) {
IExtension extension = extensions.get(i);
final IExchange e = extension.createExchange(name + ":" + params);
if (e != null) {
final String preferredFiatCurrency = e.getPreferredFiatCurrency();
final Set<String> cryptoCurrencies = e.getCryptoCurrencies();
final Set<String> fiatCurrencies = e.getFiatCurrencies();
for (int i = 0; i < extensions.size(); i++) {
IExtension extension = extensions.get(i);
final IExchange e = extension.createExchange(name + ":" + params);
if (e != null) {
final String preferredFiatCurrency = e.getPreferredFiatCurrency();
final Set<String> cryptoCurrencies = e.getCryptoCurrencies();
final Set<String> fiatCurrencies = e.getFiatCurrencies();
System.out.println("Preferred Fiat Currency = " + preferredFiatCurrency);
System.out.println("Crypto Currencies:");
String selectedCryptoCurrency = null;
for (String cryptoCurrency : cryptoCurrencies) {
if (selectedCryptoCurrency == null) {
selectedCryptoCurrency = cryptoCurrency;
}
System.out.println(" " + cryptoCurrency);
}
System.out.println("Fiat Currencies:");
for (String fiatCurrency : fiatCurrencies) {
System.out.println(" " + fiatCurrency);
}
final BigDecimal balance = e.getCryptoBalance(selectedCryptoCurrency);
if (balance != null) {
System.out.println("Crypto Balance: " + balance.stripTrailingZeros().toPlainString() + " " + selectedCryptoCurrency);
}else{
System.err.println("Exchange returned NULL.");
}
final String depositAddress = e.getDepositAddress(selectedCryptoCurrency);
System.out.println("Deposit Address: " + depositAddress);
return;
}
}
System.out.println("Preferred Fiat Currency = " + preferredFiatCurrency);
System.out.println("Crypto Currencies:");
String selectedCryptoCurrency = null;
for (String cryptoCurrency : cryptoCurrencies) {
if (selectedCryptoCurrency == null) {
selectedCryptoCurrency = cryptoCurrency;
}
System.out.println(" " + cryptoCurrency);
}
System.out.println("Fiat Currencies:");
for (String fiatCurrency : fiatCurrencies) {
System.out.println(" " + fiatCurrency);
}
final BigDecimal balance = e.getCryptoBalance(selectedCryptoCurrency);
if (balance != null) {
System.out.println("Crypto Balance: " + balance.stripTrailingZeros().toPlainString() + " " + selectedCryptoCurrency);
}else{
System.err.println("Exchange returned NULL.");
}
final String depositAddress = e.getDepositAddress(selectedCryptoCurrency);
System.out.println("Deposit Address: " + depositAddress);
return;
}
}
System.err.println("Error: Exchange not found.");
}