mirror of
https://github.com/jwinterm/LightWallet2.git
synced 2026-10-17 05:21:26 +02:00
Got wallet height read working and started tx layout.
This commit is contained in:
@@ -46,6 +46,7 @@ com.badlogic.gdx.scenes.scene2d.ui.Slider$SliderStyle: {
|
||||
},
|
||||
com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle: {
|
||||
default: { font: default-font, fontColor: white }
|
||||
redlabel: { font: default-font, fontColor: red }
|
||||
},
|
||||
com.badlogic.gdx.scenes.scene2d.ui.TextField$TextFieldStyle: {
|
||||
default: { selection: selection, background: textfield, font: default-font, fontColor: white, cursor: cursor }
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package com.jw.lightwallet;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.badlogic.gdx.Game;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.jw.lightwallet.screens.MainScreen;
|
||||
import com.jw.lightwallet.screens.PasswordScreen;
|
||||
import com.jw.lightwallet.screens.WizardScreen;
|
||||
import com.jw.lightwallet.utils.WalletValues;
|
||||
|
||||
@@ -38,9 +42,24 @@ public class LightWallet extends Game {
|
||||
|
||||
// Check if config file exists, if not launch setup wizard
|
||||
File f = new File("lightwallet.conf");
|
||||
|
||||
if(f.exists() && !f.isDirectory()) {
|
||||
setScreen(new MainScreen(this));
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(f))) {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
if (line.contains("name: ")) {walletvalues.setName(line.split("name: ")[1]);}
|
||||
if (line.contains("Wallet address: ")) {walletvalues.setAddress(line.split("address: ")[1]);}
|
||||
if (line.contains("view key: ")) {walletvalues.setViewkey(line.split("view key: ")[1]);}
|
||||
if (line.contains("Node address: ")) {walletvalues.setNode(line.split("address: ")[1]);}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
Gdx.app.log(LightWallet.LOG, "Node address on startup is: " + walletvalues.getAddress());
|
||||
setScreen(new PasswordScreen(this));
|
||||
}
|
||||
|
||||
else {setScreen(new WizardScreen(this));}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.jw.lightwallet.daemon;
|
||||
package com.jw.lightwallet.daemon;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Net.HttpMethods;
|
||||
|
||||
@@ -4,7 +4,7 @@ public class DaemonResponse {
|
||||
|
||||
String id;
|
||||
String jsonrpc;
|
||||
Result result;
|
||||
DaemonResult result;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
@@ -18,10 +18,10 @@ public class DaemonResponse {
|
||||
public void setJsonrpc(String jsonrpc) {
|
||||
this.jsonrpc = jsonrpc;
|
||||
}
|
||||
public Result getResult() {
|
||||
public DaemonResult getResult() {
|
||||
return result;
|
||||
}
|
||||
public void setResult(Result result) {
|
||||
public void setResult(DaemonResult result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.jw.lightwallet.daemon;
|
||||
|
||||
public class DaemonResult {
|
||||
|
||||
BlockHeader block_header;
|
||||
String status;
|
||||
|
||||
|
||||
public BlockHeader getBlock_header() {
|
||||
return block_header;
|
||||
}
|
||||
public void setBlock_header(BlockHeader block_header) {
|
||||
this.block_header = block_header;
|
||||
}
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class CreateScreen extends AbstractScreen {
|
||||
pwrpttext.setPasswordMode(true);
|
||||
pwrpttext.setPasswordCharacter((char) 42);
|
||||
nodelabel = new Label("Node address: ", uiSkin);
|
||||
nodetext = new TextField(Constants.moneroclub, uiSkin);
|
||||
nodetext = new TextField(Constants.moneroclubdmn, uiSkin);
|
||||
inputtable.add(namelabel).width(200);
|
||||
inputtable.add(nametext).width(400).row();
|
||||
inputtable.add(pwlabel).width(200);
|
||||
@@ -229,6 +229,7 @@ public class CreateScreen extends AbstractScreen {
|
||||
game.walletvalues.setName(name);
|
||||
game.walletvalues.setPw(pw);
|
||||
game.walletvalues.setSeed(seed);
|
||||
game.walletvalues.setNode(nodetext.getText());;
|
||||
|
||||
PrintWriter infowriter = new PrintWriter(name + "info.txt", "UTF-8");
|
||||
infowriter.println("Wallet name: " + name);
|
||||
|
||||
@@ -69,7 +69,7 @@ public class DaemonView {
|
||||
}
|
||||
|
||||
public void Update(DaemonValues daemonvalues) {
|
||||
nodevalue.setText(Constants.moneroclub);
|
||||
nodevalue.setText(Constants.moneroclubdmn);
|
||||
statusvalue.setText(daemonvalues.getStatus());
|
||||
heightvalue.setText(String.valueOf(daemonvalues.getBlockheight()));
|
||||
hashratevalue.setText(new DecimalFormat("##.##").format(daemonvalues.getHashrate()) + " Mh/s");
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.jw.lightwallet.screens;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
@@ -9,11 +13,14 @@ import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.utils.AtomicQueue;
|
||||
import com.badlogic.gdx.utils.Timer;
|
||||
import com.jw.lightwallet.LightWallet;
|
||||
import com.jw.lightwallet.daemon.DaemonRPC;
|
||||
import com.jw.lightwallet.utils.BalanceValues;
|
||||
import com.jw.lightwallet.utils.Constants;
|
||||
import com.jw.lightwallet.utils.DaemonValues;
|
||||
import com.jw.lightwallet.wallet.BalanceRPC;
|
||||
|
||||
|
||||
public class MainScreen extends AbstractScreen {
|
||||
@@ -21,6 +28,9 @@ public class MainScreen extends AbstractScreen {
|
||||
DaemonRPC daemonrpc;
|
||||
DaemonValues daemonvalues;
|
||||
|
||||
BalanceRPC balancerpc;
|
||||
BalanceValues balancevalues;
|
||||
|
||||
// Layout stuff
|
||||
Stage stage;
|
||||
Table screenlayout;
|
||||
@@ -37,52 +47,72 @@ public class MainScreen extends AbstractScreen {
|
||||
Table viewcontainer;
|
||||
DaemonView daemonview;
|
||||
WalletView walletview;
|
||||
TransactionView transactionview;
|
||||
HistoryView historyview;
|
||||
|
||||
// Timer
|
||||
Timer timer;
|
||||
// Timers
|
||||
Timer daemontimer;
|
||||
Timer wallettimer;
|
||||
|
||||
// Wallet thread and queue stuff
|
||||
Process wp;
|
||||
BufferedReader wr;
|
||||
AtomicQueue<String> wq;
|
||||
|
||||
|
||||
public MainScreen(final LightWallet game) {
|
||||
super(game);
|
||||
|
||||
timer = new Timer();
|
||||
daemontimer = new Timer();
|
||||
wallettimer = new Timer();
|
||||
|
||||
Skin uiSkin = new Skin(Gdx.files.internal("skin/uiskin.json"));
|
||||
wq = new AtomicQueue<String>(10);
|
||||
|
||||
Skin uiSkin = new Skin(Gdx.files.internal("skin/uiskin.json"));
|
||||
|
||||
daemonrpc = new DaemonRPC();
|
||||
daemonvalues = new DaemonValues();
|
||||
daemonrpc = new DaemonRPC();
|
||||
daemonvalues = new DaemonValues();
|
||||
|
||||
balancerpc = new BalanceRPC();
|
||||
balancevalues = new BalanceValues();
|
||||
|
||||
stage = new Stage();
|
||||
stage = new Stage();
|
||||
Gdx.input.setInputProcessor(stage);
|
||||
|
||||
screenlayout = new Table();
|
||||
viewcontainer = new Table();
|
||||
screenlayout = new Table();
|
||||
viewcontainer = new Table();
|
||||
|
||||
logo = new Image(new Texture(Gdx.files.internal("logo.png")));
|
||||
|
||||
buttonrow = new Table();
|
||||
daemonbutton = new TextButton("Daemon", uiSkin);
|
||||
daemonbutton = new TextButton("Daemon", uiSkin);
|
||||
daemonbutton.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked (InputEvent event, float x, float y) {
|
||||
System.out.println("Daemon button Pressed");
|
||||
viewcontainer.removeActor(walletview.walletlayout);
|
||||
viewcontainer.removeActor(transactionview.txlayout);
|
||||
viewcontainer.add(daemonview.daemonlayout).expand().bottom();
|
||||
}
|
||||
});
|
||||
walletbutton = new TextButton("Wallet", uiSkin);
|
||||
walletbutton = new TextButton("Wallet", uiSkin);
|
||||
walletbutton.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked (InputEvent event, float x, float y) {
|
||||
System.out.println("Wallet button Pressed");
|
||||
viewcontainer.removeActor(daemonview.daemonlayout);
|
||||
viewcontainer.removeActor(transactionview.txlayout);
|
||||
viewcontainer.add(walletview.walletlayout).expand().bottom();
|
||||
}
|
||||
});
|
||||
transferbutton = new TextButton("Transfer", uiSkin);
|
||||
transferbutton = new TextButton("Transfer", uiSkin);
|
||||
transferbutton.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked (InputEvent event, float x, float y) {
|
||||
System.out.println("Transfer button Pressed");
|
||||
viewcontainer.removeActor(daemonview.daemonlayout);
|
||||
viewcontainer.removeActor(walletview.walletlayout);
|
||||
viewcontainer.add(transactionview.txlayout).expand().bottom();
|
||||
}
|
||||
});
|
||||
txhistorybutton = new TextButton("History", uiSkin);
|
||||
@@ -101,8 +131,10 @@ public class MainScreen extends AbstractScreen {
|
||||
|
||||
screenlayout.add(logo).pad(10).center().row();
|
||||
|
||||
daemonview = new DaemonView();
|
||||
walletview = new WalletView();
|
||||
daemonview = new DaemonView();
|
||||
walletview = new WalletView(game);
|
||||
transactionview = new TransactionView();
|
||||
historyview = new HistoryView();
|
||||
viewcontainer.add(daemonview.daemonlayout).expand().bottom();
|
||||
screenlayout.add(viewcontainer);
|
||||
|
||||
@@ -113,7 +145,39 @@ public class MainScreen extends AbstractScreen {
|
||||
public void show() {
|
||||
super.show();
|
||||
|
||||
timer.scheduleTask(new Timer.Task() {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// do something important here, asynchronously to the rendering thread
|
||||
try {
|
||||
Gdx.app.log(LightWallet.LOG, "Command is: " + "simplewallet --wallet-file " + game.walletvalues.getName()
|
||||
+ " --password " + game.walletvalues.getPw() + " --daemon-address " + game.walletvalues.getNode()
|
||||
+ " --rpc-bind-port 19091 --log-level 2");
|
||||
wp = Runtime.getRuntime().exec("simplewallet --wallet-file " + game.walletvalues.getName()
|
||||
+ " --password " + game.walletvalues.getPw() + " --daemon-address " + game.walletvalues.getNode()
|
||||
+ " --rpc-bind-port 19091 --log-level 2");
|
||||
wr = new BufferedReader(new InputStreamReader(wp.getInputStream()));
|
||||
while (true) {
|
||||
String str = wr.readLine();
|
||||
wq.put(str);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
// post a Runnable to the rendering thread that processes the result
|
||||
Gdx.app.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// process the result, e.g. add it to an Array<Result> field of the ApplicationListener.
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
|
||||
// Timer task to get network info from daemon
|
||||
daemontimer.scheduleTask(new Timer.Task() {
|
||||
@Override
|
||||
public void run() {
|
||||
daemonrpc.getinfo(daemonvalues);
|
||||
@@ -121,6 +185,25 @@ public class MainScreen extends AbstractScreen {
|
||||
}
|
||||
}, 1f, 10f);
|
||||
|
||||
// Timer task to get output from simplewallet logging and check balances
|
||||
wallettimer.scheduleTask(new Timer.Task() {
|
||||
@Override
|
||||
public void run() {
|
||||
String queuepoll = wq.poll();
|
||||
Gdx.app.log(LightWallet.LOG, "Queue result: " + queuepoll);
|
||||
try{
|
||||
|
||||
if (queuepoll != null && queuepoll.contains("height")) {
|
||||
String height = queuepoll.split("height: ")[1].split(",")[0];
|
||||
walletview.syncvalue.setText(height + " / " + daemonvalues.getBlockheight());
|
||||
}
|
||||
} catch (NullPointerException e){e.printStackTrace();}
|
||||
|
||||
balancerpc.getinfo(balancevalues);
|
||||
|
||||
}
|
||||
}, 1f, 1f);
|
||||
|
||||
}
|
||||
|
||||
public void render(float delta) {
|
||||
@@ -135,6 +218,16 @@ public class MainScreen extends AbstractScreen {
|
||||
super.dispose();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
// TODO Auto-generated method stub
|
||||
super.hide();
|
||||
wp.destroy();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.jw.lightwallet.screens;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.jw.lightwallet.LightWallet;
|
||||
|
||||
public class PasswordScreen extends AbstractScreen {
|
||||
|
||||
Stage stage;
|
||||
Table screenlayout;
|
||||
Skin uiSkin;
|
||||
int padvalue;
|
||||
|
||||
Image logo;
|
||||
Texture logotex;
|
||||
|
||||
Table textcontainer;
|
||||
String instruction;
|
||||
Label instructionlabel;
|
||||
|
||||
Table inputtable;
|
||||
|
||||
Label pwlabel;
|
||||
TextField pwtext;
|
||||
String pw;
|
||||
|
||||
Label nodelabel;
|
||||
TextField nodetext;
|
||||
String node;
|
||||
|
||||
Table buttontable;
|
||||
TextButton createbutton;
|
||||
|
||||
|
||||
public PasswordScreen(final LightWallet game) {
|
||||
super(game);
|
||||
System.out.print("CreateScreen creating.");
|
||||
|
||||
uiSkin = new Skin(Gdx.files.internal("skin/uiskin.json"));
|
||||
padvalue = 20;
|
||||
|
||||
stage = new Stage();
|
||||
Gdx.input.setInputProcessor(stage);
|
||||
|
||||
screenlayout = new Table();
|
||||
|
||||
logo = new Image(new Texture(Gdx.files.internal("logo.png")));
|
||||
//logo.scaleBy(0.02f);
|
||||
|
||||
instruction = "Please enter your password in the password field below for the wallet" + game.walletvalues.getName() + ". "
|
||||
+ "The node listed in lightwallet.conf is listed below as well; you may update it now if you like.";
|
||||
|
||||
instructionlabel= new Label(instruction, uiSkin);
|
||||
instructionlabel.setWrap(true);
|
||||
textcontainer = new Table();
|
||||
textcontainer.add(instructionlabel).width(600);
|
||||
|
||||
inputtable = new Table();
|
||||
|
||||
pwlabel = new Label("Password: ", uiSkin);
|
||||
pwtext = new TextField("", uiSkin);
|
||||
pwtext.setPasswordMode(true);
|
||||
pwtext.setPasswordCharacter((char) 42);
|
||||
|
||||
nodelabel = new Label("Node address: ", uiSkin);
|
||||
nodetext = new TextField(game.walletvalues.getNode(), uiSkin);
|
||||
|
||||
inputtable.add(pwlabel).width(200);
|
||||
inputtable.add(pwtext).width(400).row();
|
||||
|
||||
inputtable.add(nodelabel).width(200);
|
||||
inputtable.add(nodetext).width(400).row();
|
||||
|
||||
buttontable = new Table();
|
||||
createbutton = new TextButton("Proceed", uiSkin);
|
||||
createbutton.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked (InputEvent event, float x, float y) {
|
||||
pw = pwtext.getText();
|
||||
node = nodetext.getText();
|
||||
game.walletvalues.setPw(pw);
|
||||
game.walletvalues.setNode(node);
|
||||
game.setScreen(new MainScreen(game));
|
||||
}
|
||||
});
|
||||
buttontable.add(createbutton).width(150);
|
||||
|
||||
screenlayout.add(logo).pad(10).width(200).height(50).center().row();
|
||||
screenlayout.add(textcontainer).pad(padvalue).row();
|
||||
screenlayout.add(inputtable).pad(padvalue).row();
|
||||
screenlayout.add(buttontable).pad(padvalue).row();
|
||||
|
||||
screenlayout.setFillParent(true);
|
||||
stage.addActor(screenlayout);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void show() {
|
||||
super.show();
|
||||
|
||||
}
|
||||
|
||||
public void render(float delta) {
|
||||
super.render(delta);
|
||||
|
||||
stage.draw();
|
||||
stage.act(delta);
|
||||
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,59 @@
|
||||
package com.jw.lightwallet.screens;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
|
||||
import com.jw.lightwallet.LightWallet;
|
||||
|
||||
public class TransactionView {
|
||||
|
||||
Table txlayout;
|
||||
|
||||
Label addresslabel;
|
||||
TextField addressvalue;
|
||||
Label amountlabel;
|
||||
TextField amountvalue;
|
||||
Label mixinlabel;
|
||||
TextField mixinvalue;
|
||||
Label idlabel;
|
||||
TextField idvalue;
|
||||
|
||||
TextButton sendbtn;
|
||||
|
||||
int padvalue;
|
||||
|
||||
|
||||
public TransactionView () {
|
||||
|
||||
Skin uiSkin = new Skin(Gdx.files.internal("skin/uiskin.json"));
|
||||
|
||||
txlayout = new Table();
|
||||
padvalue = 15;
|
||||
|
||||
addresslabel = new Label("Send to address: ", uiSkin);
|
||||
addressvalue = new TextField("", uiSkin);
|
||||
txlayout.add(addresslabel).pad(padvalue);
|
||||
txlayout.add(addressvalue).pad(padvalue).row();
|
||||
|
||||
amountlabel = new Label("Send amount XMR: ", uiSkin);
|
||||
amountvalue = new TextField("", uiSkin);
|
||||
txlayout.add(amountlabel).pad(padvalue);
|
||||
txlayout.add(amountvalue).pad(padvalue).row();
|
||||
|
||||
mixinlabel = new Label("Mixin level: ", uiSkin);
|
||||
mixinvalue = new TextField("", uiSkin);
|
||||
txlayout.add(mixinlabel).pad(padvalue);
|
||||
txlayout.add(mixinvalue).pad(padvalue).row();
|
||||
|
||||
idlabel = new Label("Payment id: ", uiSkin);
|
||||
idvalue = new TextField("", uiSkin);
|
||||
txlayout.add(idlabel).pad(padvalue);
|
||||
txlayout.add(idvalue).pad(padvalue).row();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,13 +4,18 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.jw.lightwallet.LightWallet;
|
||||
|
||||
public class WalletView {
|
||||
|
||||
Table walletlayout;
|
||||
|
||||
Label namelabel;
|
||||
Label namevalue;
|
||||
Label addresslabel;
|
||||
Label addressvalue;
|
||||
Label synclabel;
|
||||
Label syncvalue;
|
||||
Label unlockedlabel;
|
||||
Label unlockedvalue;
|
||||
Label lockedlabel;
|
||||
@@ -19,17 +24,38 @@ public class WalletView {
|
||||
int padvalue;
|
||||
|
||||
|
||||
public WalletView () {
|
||||
public WalletView (LightWallet game) {
|
||||
|
||||
Skin uiSkin = new Skin(Gdx.files.internal("skin/uiskin.json"));
|
||||
|
||||
walletlayout = new Table();
|
||||
padvalue = 15;
|
||||
walletlayout = new Table();
|
||||
padvalue = 15;
|
||||
|
||||
namelabel = new Label("Name: ", uiSkin);
|
||||
namevalue = new Label(game.walletvalues.getName(), uiSkin);
|
||||
walletlayout.add(namelabel).pad(padvalue);
|
||||
walletlayout.add(namevalue).pad(padvalue).row();
|
||||
|
||||
addresslabel = new Label("Address: ", uiSkin);
|
||||
addressvalue = new Label("assssssssssssssddddddddddddddddddddddddddddssssssssssssssssssssssssssssssssffffffffffffffffd", uiSkin);
|
||||
addressvalue = new Label(game.walletvalues.getAddress(), uiSkin);
|
||||
addressvalue.setFontScale(0.2f, 0.2f);
|
||||
walletlayout.add(addresslabel).pad(padvalue);
|
||||
walletlayout.add(addressvalue).pad(padvalue).row();
|
||||
|
||||
synclabel = new Label("Wallet sync: ", uiSkin);
|
||||
syncvalue = new Label("0 / A lot", uiSkin, "redlabel");
|
||||
walletlayout.add(synclabel).pad(padvalue);
|
||||
walletlayout.add(syncvalue).pad(padvalue).row();
|
||||
|
||||
unlockedlabel = new Label("Unlocked balance: ", uiSkin);
|
||||
unlockedvalue = new Label("Loading...", uiSkin, "redlabel");
|
||||
walletlayout.add(unlockedlabel).pad(padvalue);
|
||||
walletlayout.add(unlockedvalue).pad(padvalue).row();
|
||||
|
||||
lockedlabel = new Label("Locked balance: ", uiSkin);
|
||||
lockedvalue = new Label("Loading...", uiSkin, "redlabel");
|
||||
walletlayout.add(lockedlabel).pad(padvalue);
|
||||
walletlayout.add(lockedvalue).pad(padvalue).row();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.jw.lightwallet.utils;
|
||||
|
||||
public class BalanceValues {
|
||||
|
||||
long unlockedbalance;
|
||||
long lockedbalance;
|
||||
|
||||
public Long getUnlockedbalance() {
|
||||
return unlockedbalance;
|
||||
}
|
||||
public void setUnlockedbalance(long unlockedbalance) {
|
||||
this.unlockedbalance = unlockedbalance;
|
||||
}
|
||||
public Long getLockedbalance() {
|
||||
return lockedbalance;
|
||||
}
|
||||
public void setLockedbalance(long lockedbalance) {
|
||||
this.lockedbalance = lockedbalance;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ public class Constants {
|
||||
public static final float WORLD_WIDTH = 800;
|
||||
public static final float WORLD_HEIGHT = 600;
|
||||
|
||||
public static final String moneroclub = "http://node.monoerclub.com/json_rpc:8880";
|
||||
public static final String moneroclubrpc = "http://node.moneroclub.com/json_rpc:8880";
|
||||
public static final String moneroclubdmn = "http://node.moneroclub.com:8880";
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,10 @@ public class WalletValues {
|
||||
String address;
|
||||
String viewkey;
|
||||
String seed;
|
||||
String node;
|
||||
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -38,7 +41,12 @@ public class WalletValues {
|
||||
public void setSeed(String seed) {
|
||||
this.seed = seed;
|
||||
}
|
||||
|
||||
|
||||
public String getNode() {
|
||||
return node;
|
||||
}
|
||||
public void setNode(String node) {
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.jw.lightwallet.wallet;
|
||||
|
||||
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.google.gson.Gson;
|
||||
import com.jw.lightwallet.utils.BalanceValues;
|
||||
|
||||
|
||||
public class BalanceRPC {
|
||||
public String swaddress;
|
||||
String response;
|
||||
String getbalance;
|
||||
|
||||
public BalanceRPC () {
|
||||
swaddress = "http://localhost:19091/json_rpc";
|
||||
getbalance = "{\"jsonrpc\":\"2.0\",\"id\":\"test\",\"method\":\"getbalance\",\"params\":[]}";
|
||||
}
|
||||
|
||||
public void getinfo (final BalanceValues balancevalues) {
|
||||
HttpRequest httpGet = new HttpRequest(HttpMethods.POST);
|
||||
httpGet.setUrl(swaddress);
|
||||
httpGet.setContent(getbalance);
|
||||
|
||||
Gdx.net.sendHttpRequest (httpGet, new HttpResponseListener() {
|
||||
public void handleHttpResponse(HttpResponse httpResponse) {
|
||||
response = httpResponse.getResultAsString();
|
||||
//System.out.print("Balance response: " + response);
|
||||
BalanceResponse balanceresponse = new Gson().fromJson(response, BalanceResponse.class);
|
||||
balancevalues.setLockedbalance(balanceresponse.getResult().getLockedbalance());
|
||||
balancevalues.setUnlockedbalance(balanceresponse.getResult().getUnlockedbalance());
|
||||
|
||||
}
|
||||
|
||||
public void failed(Throwable t) {
|
||||
response = "failed";
|
||||
//System.out.print("Failed response status is: " + response);
|
||||
//do stuff here based on the failed attempt
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelled() {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.jw.lightwallet.wallet;
|
||||
|
||||
import com.jw.lightwallet.wallet.BalanceResult;
|
||||
|
||||
public class BalanceResponse {
|
||||
|
||||
String id;
|
||||
String jsonrpc;
|
||||
BalanceResult result;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getJsonrpc() {
|
||||
return jsonrpc;
|
||||
}
|
||||
public void setJsonrpc(String jsonrpc) {
|
||||
this.jsonrpc = jsonrpc;
|
||||
}
|
||||
public BalanceResult getResult() {
|
||||
return result;
|
||||
}
|
||||
public void setResult(BalanceResult result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.jw.lightwallet.wallet;
|
||||
|
||||
public class BalanceResult {
|
||||
|
||||
long unlockedbalance;
|
||||
long lockedbalance;
|
||||
|
||||
public long getUnlockedbalance() {
|
||||
return unlockedbalance;
|
||||
}
|
||||
public void setUnlockedbalance(long unlockedbalance) {
|
||||
this.unlockedbalance = unlockedbalance;
|
||||
}
|
||||
public long getLockedbalance() {
|
||||
return lockedbalance;
|
||||
}
|
||||
public void setLockedbalance(long lockedbalance) {
|
||||
this.lockedbalance = lockedbalance;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user