diff --git a/src/main/java/cz/kamma/mining/Constants.java b/src/main/java/cz/kamma/mining/Constants.java index 2406681..e38cbde 100644 --- a/src/main/java/cz/kamma/mining/Constants.java +++ b/src/main/java/cz/kamma/mining/Constants.java @@ -2,7 +2,7 @@ package cz.kamma.mining; public interface Constants { - public static final String APP_VERSION = "v0.5"; + public static final String APP_VERSION = "v0.7"; public static final String COPYRIGHT = "2021"; public static final int DEFAULT_HTTP_TIMEOUT = 2000; } diff --git a/src/main/java/cz/kamma/mining/bean/MiningBean.java b/src/main/java/cz/kamma/mining/bean/MiningBean.java index 80aee51..084e9f6 100644 --- a/src/main/java/cz/kamma/mining/bean/MiningBean.java +++ b/src/main/java/cz/kamma/mining/bean/MiningBean.java @@ -23,20 +23,16 @@ public class MiningBean { List pool = new ArrayList<>(); List network = new ArrayList<>(); - String[] cryptoCur = new String[] { "btc", "ltc", "xrp", "eth" }; + String[] cryptoCur = new String[] { "btc", "ltc", "xrp", "eth"}; double[] lastPrices = new double[] { 0, 0, 0, 0 }; - String apikey = request.getParameter("apikey"); + String ltcapikey = request.getParameter("ltcapikey"); + String dogapikey = request.getParameter("dogapikey"); String ltcWallet = request.getParameter("ltc"); String xrpWallet = request.getParameter("xrp"); String ethWallet = request.getParameter("eth"); String currency = request.getParameter("cur"); - if (request.getParameter("apikey") == null) { - response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Invalid API key"); - return null; - } - if (currency == null || currency.equals("null") || currency.length() == 0) currency = "usd"; else @@ -135,9 +131,9 @@ public class MiningBean { } } - if (apikey != null && !"null".equals(apikey) && apikey.length() > 0) { + if (ltcapikey != null && !"null".equals(ltcapikey) && ltcapikey.length() > 0) { String miningJson = HttpHelper - .getStringResponse("https://www.litecoinpool.org/api?api_key=".concat(apikey)); + .getStringResponse("https://www.litecoinpool.org/api?api_key=".concat(ltcapikey)); if (miningJson != null && miningJson.length() > 0) { JSONObject full = new JSONObject(miningJson); JSONObject user = (JSONObject) full.get("user"); @@ -264,6 +260,116 @@ public class MiningBean { } } + if (dogapikey != null && !"null".equals(dogapikey) && dogapikey.length() > 0) { + String miningJson = HttpHelper + .getStringResponse("https://aikapool.com/doge/index.php?page=api&action=getuserworkers&api_key=" + + dogapikey + "&id=282608&_=1621333944761", 5000); + if (miningJson != null && miningJson.length() > 0) { + JSONObject full = new JSONObject(miningJson); + JSONObject user = (JSONObject) full.get("getuserworkers"); + JSONArray data = (JSONArray) user.get("data"); + KeyValue wi = new KeyValue(); + + for (Iterator it = data.iterator(); it.hasNext();) { + JSONObject workersJson = (JSONObject) it.next(); + wi = new KeyValue(); + wi.setKey("HashRate " + workersJson.getString("username")); + double hr = workersJson.getDouble("hashrate"); + wi.setValue(String.format("%.2f",(hr / 1000)) + " MH/s"); + workers.add(wi); + } + } + + miningJson = HttpHelper + .getStringResponse("https://aikapool.com/doge/index.php?page=api&action=getdashboarddata&api_key=" + + dogapikey + "&id=282608&_=1621333944761", 5000); + if (miningJson != null && miningJson.length() > 0) { + JSONObject full = new JSONObject(miningJson); + JSONObject user = (JSONObject) full.get("getdashboarddata"); + JSONObject data = (JSONObject) user.get("data"); + JSONObject net = (JSONObject) data.get("network"); + JSONObject pers = (JSONObject) data.get("personal"); + JSONObject estimates = (JSONObject) pers.get("estimates"); + JSONObject raw = (JSONObject) data.get("raw"); + KeyValue wi = new KeyValue(); + + wi = new KeyValue(); + wi.setKey("Next Payout"); + if (estimates.getDouble("payout") > 0) + wi.setValue(estimates.getDouble("payout") + " DOG"); + else + wi.setValue("Unknown"); + workers.add(wi); + + wi = new KeyValue(); + wi.setKey("Difficulty"); + if (net.getDouble("difficulty") > 0) + wi.setValue("" + net.getDouble("difficulty")); + else + wi.setValue("Unknown"); + network.add(wi); + + wi = new KeyValue(); + wi.setKey("Next Difficulty"); + if (net.getDouble("nextdifficulty") > 0) + wi.setValue("" + net.getDouble("nextdifficulty")); + else + wi.setValue("Unknown"); + network.add(wi); + + wi = new KeyValue(); + wi.setKey("Pool Hashrate"); + if (raw.getJSONObject("pool").getDouble("hashrate") > 0) + wi.setValue((raw.getJSONObject("pool").getDouble("hashrate") / 1000000) + " GH/s"); + else + wi.setValue("Unknown"); + network.add(wi); + + wi = new KeyValue(); + wi.setKey("Network Hashrate"); + if (raw.getJSONObject("network").getDouble("hashrate") > 0) + wi.setValue((raw.getJSONObject("network").getDouble("hashrate") / 1000000) + " GH/s"); + else + wi.setValue("Unknown"); + network.add(wi); + } + + miningJson = HttpHelper + .getStringResponse("https://aikapool.com/doge/index.php?page=api&action=getuserbalance&api_key=" + + dogapikey + "&id=282608&_=1621333944761", 5000); + if (miningJson != null && miningJson.length() > 0) { + JSONObject full = new JSONObject(miningJson); + JSONObject user = (JSONObject) full.get("getuserbalance"); + JSONObject data = (JSONObject) user.get("data"); + KeyValue wi = new KeyValue(); + + wi = new KeyValue(); + wi.setKey("Paid"); + if (data.getDouble("paid") >= 0) + wi.setValue(data.getDouble("paid") + " DOG"); + else + wi.setValue("Unknown"); + workers.add(wi); + + wi = new KeyValue(); + wi.setKey("Confirmed"); + if (data.getDouble("confirmed") >= 0) + wi.setValue(data.getDouble("confirmed") + " DOG"); + else + wi.setValue("Unknown"); + workers.add(wi); + + wi = new KeyValue(); + wi.setKey("Unconfirmed"); + if (data.getDouble("unconfirmed") >= 0) + wi.setValue(data.getDouble("unconfirmed") + " DOG"); + else + wi.setValue("Unknown"); + workers.add(wi); + + } + } + String res = "#PRICES##WORKERS##POOL##NETWORK#"; String tmp = ""; diff --git a/src/main/webapp/ajaxview.jsp b/src/main/webapp/ajaxview.jsp index 91b32ce..abbff0f 100644 --- a/src/main/webapp/ajaxview.jsp +++ b/src/main/webapp/ajaxview.jsp @@ -24,8 +24,8 @@ diff --git a/src/main/webapp/client.js b/src/main/webapp/client.js index 279a134..258cf3d 100644 --- a/src/main/webapp/client.js +++ b/src/main/webapp/client.js @@ -73,8 +73,8 @@ function ajaxGetXmlResponse() { } } -function AX_asynchUpdate(apikey, ltc, eth, xrp, cur) { - var data = 'ajaxMethod=asynchUpdate&apikey=' + apikey + '<c=' + ltc + 'ð=' + eth +function AX_asynchUpdate(ltcapikey, dogapikey, ltc, eth, xrp, cur) { + var data = 'ajaxMethod=asynchUpdate<capikey=' + ltcapikey + '&dogapikey=' + dogapikey + '<c=' + ltc + 'ð=' + eth + '&xrp=' + xrp+ '&cur=' + cur; ajaxSendRequest(data, AX_asynchUpdateResponse); } diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index 781d3a5..5b057c9 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -16,10 +16,16 @@
- + + type="text" name="ltcapikey" size="40" /> + + + +
litecoinpool.org API key (mandatory)litecoinpool.org LTC API key (optional)
aikapool.org DOGE API key (optional)
Litecoin wallet address (optional)