Got RPC call to bitmonerod for last block header working.

This commit is contained in:
jwLappy
2015-12-06 13:40:42 -08:00
parent fa45a9e0cf
commit 83bb606ab0
3 changed files with 29 additions and 18 deletions
+2
View File
@@ -83,6 +83,8 @@ project(":core") {
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
compile "com.google.code.gson:gson:1.7.2"
}
}
@@ -1,19 +1,36 @@
package com.jw.lightwallet.screens;
import java.io.IOException;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.jw.lightwallet.LightWallet;
import com.jw.lightwallet.utils.DaemonRPC;
public class MainScreen extends AbstractScreen {
// Interface classes
DaemonRPC daemonrpc;
// Layout stuff
Table screenlayout;
TextButton daemonbutton;
TextButton walletbutton;
Table daemonlayout;
// Bitmonerod info variables
int blockheight;
int diff;
int hashrate;
float blockreward;
public MainScreen(LightWallet game) {
super(game);
daemonrpc = new DaemonRPC();
daemonrpc.getinfo();
daemonrpc = new DaemonRPC();
}
public void show() {
super.show();
}
}
@@ -1,33 +1,25 @@
package com.jw.lightwallet.utils;
import java.util.HashMap;
import java.util.Map;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Net.HttpMethods;
import com.badlogic.gdx.Net.HttpRequest;
import com.badlogic.gdx.Net.HttpResponse;
import com.badlogic.gdx.Net.HttpResponseListener;
import com.badlogic.gdx.net.HttpParametersUtils;
public class DaemonRPC {
public String address;
public Map params;
String status;
String getlastblock;
public DaemonRPC () {
address = "http://moneroclub.com:8880";
address = "http://node.moneroclub.com:8880/json_rpc";
getlastblock = "{\"jsonrpc\":\"2.0\",\"id\":\"test\",\"method\":\"getlastblockheader\",\"params\":[]}";
}
public void getinfo () {
Map params = new HashMap();
params.put("jsonrpc", "2.0");
params.put("id", "test");
params.put("method", "getinfo");
public void getinfo () {
HttpRequest httpGet = new HttpRequest(HttpMethods.POST);
httpGet.setUrl("http://somewhere.net");
httpGet.setContent(HttpParametersUtils.convertHttpParameters(params));
httpGet.setUrl(address);
httpGet.setContent(getlastblock);
Gdx.net.sendHttpRequest (httpGet, new HttpResponseListener() {
public void handleHttpResponse(HttpResponse httpResponse) {