diff --git a/src/main/java/cz/kamma/mining/Constants.java b/src/main/java/cz/kamma/mining/Constants.java index aaa7e68..2f42898 100644 --- a/src/main/java/cz/kamma/mining/Constants.java +++ b/src/main/java/cz/kamma/mining/Constants.java @@ -2,8 +2,8 @@ package cz.kamma.mining; public interface Constants { - public static final String APP_VERSION = "v0.9"; - public static final String COPYRIGHT = "2021"; + public static final String APP_VERSION = "v0.9.1"; + public static final String COPYRIGHT = "2024"; public static final int DEFAULT_HTTP_CONNECTION_TIMEOUT = 6000; public static final int DEFAULT_HTTP_READ_TIMEOUT = 18000; public static final int RELOAD_TIME = 25000; diff --git a/src/main/java/cz/kamma/mining/bean/MiningBean.java b/src/main/java/cz/kamma/mining/bean/MiningBean.java index b390d1f..413fa55 100644 --- a/src/main/java/cz/kamma/mining/bean/MiningBean.java +++ b/src/main/java/cz/kamma/mining/bean/MiningBean.java @@ -2,6 +2,7 @@ package cz.kamma.mining.bean; import java.io.BufferedReader; import java.io.InputStreamReader; +import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.text.SimpleDateFormat; @@ -84,8 +85,8 @@ public class MiningBean { lastPrices[pos] = price; if (price > 0d) - resultStr = curSym + String.format("%."+roundPrices[pos]+"f", (price)) + " (" + String.format("%.2f", (change)) - + "%)"; + resultStr = curSym + String.format("%." + roundPrices[pos] + "f", (price)) + " (" + + String.format("%.2f", (change)) + "%)"; else resultStr = "Unknown"; KeyValue wi = new KeyValue(); @@ -108,12 +109,13 @@ public class MiningBean { public void run() { try { if (ltcWallet != null && !"null".equals(ltcWallet) && ltcWallet.length() > 0) { - restRequest = getStringResponse( - "https://litecoinblockexplorer.net/address/".concat(ltcWallet)); - if (restRequest != null && restRequest.length() > 0 && restRequest.contains("Final Balance
")) { - int index = restRequest.indexOf("Final Balance
")+"Final Balance
".length(); - String text = restRequest.substring(index, index+11); - + restRequest = getStringResponse("https://litecoinblockexplorer.net/address/".concat(ltcWallet)); + if (restRequest != null && restRequest.length() > 0 + && restRequest.contains("Final Balance
")) { + int index = restRequest.indexOf("Final Balance
") + + "Final Balance
".length();
+ String text = restRequest.substring(index, index + 11);
+
double res = Double.parseDouble(text);
if (res > 0d) {
resultStr = res + " LTC " + curSym + String.format("%.2f", (res * lastPrices[1]));
@@ -138,13 +140,19 @@ public class MiningBean {
public void run() {
try {
if (xrpWallet != null && !"null".equals(xrpWallet) && xrpWallet.length() > 0) {
- restRequest = getStringResponse(
- "https://data.ripple.com/v2/accounts/".concat(xrpWallet).concat("/balances"));
+ String request = "{\r\n" + " \"method\": \"account_info\",\r\n" + " \"params\": [\r\n"
+ + " {\r\n" + " \"account\": \"" + xrpWallet + "\",\r\n"
+ + " \"ledger_index\": \"current\",\r\n" + " \"queue\": true\r\n"
+ + " }\r\n" + " ]\r\n" + "}";
+ restRequest = makeRequest("http://s1.ripple.com:51234", "POST", 5000, 5000, null,
+ request.getBytes());
if (restRequest != null && restRequest.length() > 0) {
JSONObject full = new JSONObject(restRequest);
- JSONArray balances = (JSONArray) full.get("balances");
- double res = balances.getJSONObject(0).getDouble("value");
+ String balance = (String) full.getJSONObject("result").getJSONObject("account_data")
+ .get("Balance");
+ double res = Double.valueOf(balance.toString());
if (res > 0d) {
+ res = res / 1000000;
resultStr = res + " XRP " + curSym + String.format("%.2f", (res * lastPrices[2]));
} else
resultStr = "Unknown";
@@ -590,6 +598,43 @@ public class MiningBean {
headers);
}
+ public String makeRequest(String urlStr, String method, int timeout, int readTimeout, Map