mirror of
https://github.com/jwinterm/LightWallet2.git
synced 2026-10-18 05:31:25 +02:00
Fixed tx reading and bunch of other stuff.
This commit is contained in:
@@ -19,6 +19,7 @@ com.badlogic.gdx.scenes.scene2d.ui.Button$ButtonStyle: {
|
||||
},
|
||||
com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle: {
|
||||
default: { down: default-round-down, up: default-round, font: default-font, fontColor: white, overFontColor: blue},
|
||||
tinytext: { down: default-round-down, up: default-round, font: tiny-font, fontColor: white, overFontColor: blue},
|
||||
toggle: { down: default-round-down, up: default-round, checked: default-round-down, font: default-font, fontColor: white, downFontColor: red }
|
||||
},
|
||||
com.badlogic.gdx.scenes.scene2d.ui.ScrollPane$ScrollPaneStyle: {
|
||||
|
||||
@@ -14,8 +14,6 @@ public class DaemonView {
|
||||
|
||||
LightWallet game;
|
||||
|
||||
Skin uiSkin;
|
||||
|
||||
Table daemonlayout;
|
||||
|
||||
Label nodelabel;
|
||||
@@ -37,51 +35,48 @@ public class DaemonView {
|
||||
public DaemonView (final LightWallet game) {
|
||||
|
||||
this.game = game;
|
||||
|
||||
uiSkin = new Skin(Gdx.files.internal("skin/uiskin.json"));
|
||||
|
||||
|
||||
daemonlayout = new Table();
|
||||
padvalue = 15;
|
||||
|
||||
|
||||
nodelabel = new Label("Node address: ", uiSkin);
|
||||
nodevalue = new Label(null, uiSkin);
|
||||
nodelabel = new Label("Node address: ", game.uiSkin);
|
||||
nodevalue = new Label(null, game.uiSkin);
|
||||
daemonlayout.add(nodelabel).pad(padvalue);
|
||||
daemonlayout.add(nodevalue).pad(padvalue).row();
|
||||
|
||||
statuslabel = new Label("Node status: ", uiSkin);
|
||||
statusvalue = new Label(null, uiSkin);
|
||||
statuslabel = new Label("Node status: ", game.uiSkin);
|
||||
statusvalue = new Label(null, game.uiSkin);
|
||||
daemonlayout.add(statuslabel).pad(padvalue);
|
||||
daemonlayout.add(statusvalue).pad(padvalue).row();
|
||||
|
||||
heightlabel = new Label("Block height: ", uiSkin);
|
||||
heightvalue = new Label(null, uiSkin);
|
||||
heightlabel = new Label("Block height: ", game.uiSkin);
|
||||
heightvalue = new Label(null, game.uiSkin);
|
||||
daemonlayout.add(heightlabel).pad(padvalue);
|
||||
daemonlayout.add(heightvalue).pad(padvalue).row();
|
||||
|
||||
hashratelabel = new Label("Network hashrate: ", uiSkin);
|
||||
hashratevalue = new Label(null, uiSkin);
|
||||
hashratelabel = new Label("Network hashrate: ", game.uiSkin);
|
||||
hashratevalue = new Label(null, game.uiSkin);
|
||||
daemonlayout.add(hashratelabel).pad(padvalue);
|
||||
daemonlayout.add(hashratevalue).pad(padvalue).row();
|
||||
|
||||
timelabel = new Label("Last block time: ", uiSkin);
|
||||
timevalue = new Label(null, uiSkin);
|
||||
timelabel = new Label("Last block time: ", game.uiSkin);
|
||||
timevalue = new Label(null, game.uiSkin);
|
||||
daemonlayout.add(timelabel).pad(padvalue);
|
||||
daemonlayout.add(timevalue).pad(padvalue).row();
|
||||
|
||||
rewardlabel = new Label("Last reward: ", uiSkin);
|
||||
rewardvalue = new Label(null, uiSkin);
|
||||
rewardlabel = new Label("Last reward: ", game.uiSkin);
|
||||
rewardvalue = new Label(null, game.uiSkin);
|
||||
daemonlayout.add(rewardlabel).pad(padvalue);
|
||||
daemonlayout.add(rewardvalue).pad(padvalue).row();
|
||||
daemonlayout.add(rewardvalue).pad(padvalue);
|
||||
|
||||
daemonlayout.add(new Label("", uiSkin));
|
||||
}
|
||||
|
||||
public void Update(DaemonValues daemonvalues) {
|
||||
nodevalue.setText(game.walletvalues.getNode());
|
||||
statusvalue.setText(daemonvalues.getStatus());
|
||||
Gdx.app.log(LightWallet.LOG, "Status value is: " + statusvalue.getText());
|
||||
if (statusvalue.getText().toString().equals("OK")) {statusvalue.setStyle(uiSkin.get("greenlabel", LabelStyle.class));}
|
||||
// Gdx.app.log(LightWallet.LOG, "Status value is: " + statusvalue.getText());
|
||||
if (statusvalue.getText().toString().equals("OK")) {statusvalue.setStyle(game.uiSkin.get("greenlabel", LabelStyle.class));}
|
||||
heightvalue.setText(String.valueOf(daemonvalues.getBlockheight()));
|
||||
hashratevalue.setText(new DecimalFormat("##.##").format(daemonvalues.getHashrate()) + " Mh/s");
|
||||
timevalue.setText(String.valueOf(new java.util.Date(daemonvalues.getLastblocktime()*1000)));
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
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.ScrollPane;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.jw.lightwallet.LightWallet;
|
||||
|
||||
public class HistoryView {
|
||||
|
||||
LightWallet game;
|
||||
|
||||
Table historylayout;
|
||||
|
||||
ScrollPane scroller;
|
||||
@@ -16,20 +17,19 @@ public class HistoryView {
|
||||
int padvalue;
|
||||
|
||||
|
||||
public HistoryView () {
|
||||
|
||||
Skin uiSkin = new Skin(Gdx.files.internal("skin/uiskin.json"));
|
||||
|
||||
public HistoryView (LightWallet game) {
|
||||
this.game = game;
|
||||
|
||||
historylayout = new Table();
|
||||
padvalue = 15;
|
||||
|
||||
container = new Table();
|
||||
scroller = new ScrollPane(container, uiSkin);
|
||||
scroller = new ScrollPane(container, game.uiSkin);
|
||||
|
||||
|
||||
historylayout.add(new Label("Transaction history (click to copy txid)", uiSkin)).row();
|
||||
historylayout.add(new Label("Type | Amount | Transaction ID", uiSkin)).row();
|
||||
historylayout.add(scroller).fill();
|
||||
historylayout.add(new Label("Transaction history (click to copy txid)", game.uiSkin)).row();
|
||||
historylayout.add(new Label("Type | Amount | Transaction ID", game.uiSkin)).row();
|
||||
historylayout.add(scroller);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
@@ -14,7 +15,6 @@ import com.badlogic.gdx.Input.Keys;
|
||||
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.Button;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
@@ -23,7 +23,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.AtomicQueue;
|
||||
import com.jw.lightwallet.LightWallet;
|
||||
import com.jw.lightwallet.daemon.DaemonRPC;
|
||||
@@ -79,6 +78,7 @@ public class MainScreen extends AbstractScreen {
|
||||
// Transaction processing stuff
|
||||
ArrayList<Tx> txlist;
|
||||
int txcount;
|
||||
DecimalFormat df;
|
||||
|
||||
|
||||
public MainScreen(final LightWallet game) {
|
||||
@@ -87,6 +87,7 @@ public class MainScreen extends AbstractScreen {
|
||||
wq = new AtomicQueue<String>(1000);
|
||||
txlist = new ArrayList<Tx>();
|
||||
txcount = 0;
|
||||
df = new DecimalFormat("#.############");
|
||||
|
||||
Skin uiSkin = new Skin(Gdx.files.internal("skin/uiskin.json"));
|
||||
|
||||
@@ -112,7 +113,6 @@ public class MainScreen extends AbstractScreen {
|
||||
daemonbutton.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked (InputEvent event, float x, float y) {
|
||||
System.out.println("Daemon button Pressed");
|
||||
viewcontainer.removeActor(viewcontainer.getChildren().get(0));
|
||||
viewcontainer.add(daemonview.daemonlayout);
|
||||
}
|
||||
@@ -121,7 +121,6 @@ public class MainScreen extends AbstractScreen {
|
||||
walletbutton.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked (InputEvent event, float x, float y) {
|
||||
System.out.println("Wallet button Pressed");
|
||||
viewcontainer.removeActor(viewcontainer.getChildren().get(0));
|
||||
viewcontainer.add(walletview.walletlayout);
|
||||
}
|
||||
@@ -130,7 +129,6 @@ public class MainScreen extends AbstractScreen {
|
||||
transferbutton.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked (InputEvent event, float x, float y) {
|
||||
System.out.println("Transfer button Pressed");
|
||||
viewcontainer.removeActor(viewcontainer.getChildren().get(0));
|
||||
viewcontainer.add(transactionview.txlayout);
|
||||
}
|
||||
@@ -139,7 +137,6 @@ public class MainScreen extends AbstractScreen {
|
||||
txhistorybutton.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked (InputEvent event, float x, float y) {
|
||||
System.out.println("History button Pressed");
|
||||
viewcontainer.removeActor(viewcontainer.getChildren().get(0));
|
||||
viewcontainer.add(historyview.historylayout);
|
||||
}
|
||||
@@ -155,8 +152,8 @@ public class MainScreen extends AbstractScreen {
|
||||
|
||||
daemonview = new DaemonView(game);
|
||||
walletview = new WalletView(game, walletsaverpc);
|
||||
transactionview = new TransactionView();
|
||||
historyview = new HistoryView();
|
||||
transactionview = new TransactionView(game);
|
||||
historyview = new HistoryView(game);
|
||||
viewcontainer.add(daemonview.daemonlayout).expand().fill();
|
||||
screenlayout.add(viewcontainer);
|
||||
|
||||
@@ -165,6 +162,9 @@ public class MainScreen extends AbstractScreen {
|
||||
screenlayout.top();
|
||||
// screenlayout.setDebug(true);
|
||||
stage.addActor(screenlayout);
|
||||
|
||||
// Check tx file
|
||||
dumptxlist();
|
||||
}
|
||||
|
||||
public void show() {
|
||||
@@ -210,6 +210,15 @@ public class MainScreen extends AbstractScreen {
|
||||
if (fivesectimer == true) {
|
||||
// Timer task to check balance from simplewallet
|
||||
balancerpc.getinfo(balancevalues);
|
||||
walletview.lockedvalue.setText(balancevalues.getLockedbalance().toString());
|
||||
walletview.unlockedvalue.setText(balancevalues.getUnlockedbalance().toString());
|
||||
if (balancevalues.isChecked()) {
|
||||
walletview.lockedvalue.setStyle(game.uiSkin.get("greenlabel", LabelStyle.class));
|
||||
walletview.unlockedvalue.setStyle(game.uiSkin.get("greenlabel", LabelStyle.class));
|
||||
} else {
|
||||
walletview.lockedvalue.setStyle(game.uiSkin.get("redlabel", LabelStyle.class));
|
||||
walletview.unlockedvalue.setStyle(game.uiSkin.get("redlabel", LabelStyle.class));
|
||||
}
|
||||
fivesectimer = false;
|
||||
accum5s = 0;
|
||||
}
|
||||
@@ -271,12 +280,10 @@ public class MainScreen extends AbstractScreen {
|
||||
public void readwalletqueue () {
|
||||
// Poll wallet thread and check block height and if transaction data is in output
|
||||
String queuepoll = wq.poll();
|
||||
// Gdx.app.log(LightWallet.LOG, "Queue result: " + queuepoll);
|
||||
try{
|
||||
// If the string contains "height" then update the daemon and wallet screen blockheight
|
||||
if (queuepoll != null && queuepoll.contains("height:")) {
|
||||
String height = queuepoll.split("height: ")[1].split(",")[0];
|
||||
Gdx.app.log(LightWallet.LOG, "Queue result: " + queuepoll);
|
||||
walletview.syncvalue.setText(height + " / " + daemonvalues.getBlockheight());
|
||||
if (height.equals(Integer.toString(daemonvalues.getBlockheight()))) {
|
||||
walletview.syncvalue.setStyle(game.uiSkin.get("greenlabel", LabelStyle.class));
|
||||
@@ -284,7 +291,6 @@ public class MainScreen extends AbstractScreen {
|
||||
}
|
||||
else if (queuepoll != null && queuepoll.contains("height ")) {
|
||||
String height = queuepoll.split("height ")[1].split(",")[0];
|
||||
Gdx.app.log(LightWallet.LOG, "Queue result: " + queuepoll);
|
||||
walletview.syncvalue.setText(height + " / " + daemonvalues.getBlockheight());
|
||||
if (height.equals(Integer.toString(daemonvalues.getBlockheight()))) {
|
||||
walletview.syncvalue.setStyle(game.uiSkin.get("greenlabel", LabelStyle.class));
|
||||
@@ -293,8 +299,6 @@ public class MainScreen extends AbstractScreen {
|
||||
// If the string contains "money" then create a tx and add it to the txlist
|
||||
else if (queuepoll != null && queuepoll.contains("money")) {
|
||||
txlist.add(Tx.StringToTx(queuepoll));
|
||||
// Gdx.app.log(LightWallet.LOG, "Found tx: " + txlist.get(txlist.size()-1).txid +
|
||||
// " of type " + txlist.get(txlist.size()-1).type + " and amount " + txlist.get(txlist.size()-1).amount);
|
||||
}
|
||||
// If the string contains "invalid password" then show popup and return to password screen
|
||||
else if (queuepoll != null && queuepoll.contains("invalid password")) {
|
||||
@@ -327,6 +331,7 @@ public class MainScreen extends AbstractScreen {
|
||||
// Cycle through list of transactions from queue in last 60 s
|
||||
if (txlist.size() > 0) {
|
||||
for (int i = 0; i < txlist.size(); i++) {
|
||||
Gdx.app.log(LightWallet.LOG, i + ": newtx is - " + newtx);
|
||||
// If newtx flag then create a new temporary tx
|
||||
if (newtx == true) {
|
||||
temptx = new Tx();
|
||||
@@ -335,18 +340,21 @@ public class MainScreen extends AbstractScreen {
|
||||
temptx.txid = txlist.get(i).txid;
|
||||
}
|
||||
// If newtx flag is false then append amount to temp tx
|
||||
else if (newtx = false) {
|
||||
else if (newtx == false) {
|
||||
temptx.amount += txlist.get(i).amount;
|
||||
}
|
||||
|
||||
newtx = false; // Change flag then run check in next if statement
|
||||
|
||||
// If the next tx is different or at the end of list, write current one to file and set flag
|
||||
if (i < txlist.size()-1 &&
|
||||
(!(txlist.get(i).txid.equals(txlist.get(i+1).txid)) || !(txlist.get(i).type.equals(txlist.get(i+1).type))
|
||||
|| i == txlist.size()-1)) {
|
||||
if ((i < txlist.size()-1 &&
|
||||
(!(txlist.get(i).txid.toString().equals(txlist.get(i+1).txid.toString())) ||
|
||||
(txlist.get(i).type != txlist.get(i+1).type)))
|
||||
|| i == txlist.size()-1) {
|
||||
PrintWriter txout;
|
||||
try {
|
||||
txout = new PrintWriter(new BufferedWriter(new FileWriter(game.walletvalues.getName() + "tx.txt", true)));
|
||||
txout.println(temptx.type + " | " + temptx.amount + " | " + temptx.txid);
|
||||
txout.println(temptx.type + " | " + df.format(temptx.amount) + " | " + temptx.txid);
|
||||
txout.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
@@ -362,30 +370,23 @@ public class MainScreen extends AbstractScreen {
|
||||
|
||||
// Read lines from tx file into history view and make buttons
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(game.walletvalues.getName() + "tx.txt"))) {
|
||||
|
||||
String line;
|
||||
int linenum = 0;
|
||||
while ((line = br.readLine()) != null) {
|
||||
|
||||
System.out.println(linenum + ": " + line);
|
||||
|
||||
while ((line = br.readLine()) != null) {
|
||||
if (linenum > 0) {
|
||||
if (txcount < linenum) {
|
||||
final TextButton tmpbtn = new TextButton(line, game.uiSkin);
|
||||
final TextButton tmpbtn = new TextButton(line, game.uiSkin, "tinytext");
|
||||
tmpbtn.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked (InputEvent event, float x, float y) {
|
||||
// Gdx.app.getClipboard().setContents(((String) tmpbtn.getText()).split(" | ")[2]);
|
||||
Gdx.app.getClipboard().setContents(tmpbtn.getText().toString());
|
||||
Gdx.app.getClipboard().setContents(tmpbtn.getText().toString().split(" | ")[4]);
|
||||
}
|
||||
});
|
||||
historyview.getContainer().add(tmpbtn).row();
|
||||
historyview.getContainer().add(tmpbtn).fillX().row();
|
||||
}
|
||||
}
|
||||
|
||||
linenum += 1;
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
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 {
|
||||
|
||||
LightWallet game;
|
||||
|
||||
Table txlayout;
|
||||
|
||||
Label addresslabel;
|
||||
@@ -25,35 +26,35 @@ public class TransactionView {
|
||||
int padvalue;
|
||||
|
||||
|
||||
public TransactionView () {
|
||||
|
||||
Skin uiSkin = new Skin(Gdx.files.internal("skin/uiskin.json"));
|
||||
|
||||
public TransactionView (LightWallet game) {
|
||||
this.game = game;
|
||||
|
||||
txlayout = new Table();
|
||||
padvalue = 15;
|
||||
|
||||
addresslabel = new Label("Send to address: ", uiSkin);
|
||||
addressvalue = new TextField("", uiSkin, "tinytext");
|
||||
addresslabel = new Label("Send to address: ", game.uiSkin);
|
||||
addressvalue = new TextField("", game.uiSkin, "tinytext");
|
||||
txlayout.add(addresslabel).pad(padvalue).width(100);
|
||||
txlayout.add(addressvalue).pad(padvalue).width(600).row();
|
||||
|
||||
amountlabel = new Label("Send amount XMR: ", uiSkin);
|
||||
amountvalue = new TextField("", uiSkin);
|
||||
amountlabel = new Label("Send amount XMR: ", game.uiSkin);
|
||||
amountvalue = new TextField("", game.uiSkin);
|
||||
txlayout.add(amountlabel).pad(padvalue).width(100);
|
||||
txlayout.add(amountvalue).pad(padvalue).width(100).row();
|
||||
|
||||
mixinlabel = new Label("Mixin level: ", uiSkin);
|
||||
mixinvalue = new TextField("", uiSkin);
|
||||
mixinlabel = new Label("Mixin level: ", game.uiSkin);
|
||||
mixinvalue = new TextField("", game.uiSkin);
|
||||
txlayout.add(mixinlabel).pad(padvalue).width(100);
|
||||
txlayout.add(mixinvalue).pad(padvalue).width(50).row();
|
||||
|
||||
idlabel = new Label("Payment id: ", uiSkin);
|
||||
idvalue = new TextField("", uiSkin, "tinytext");
|
||||
idlabel = new Label("Payment id: ", game.uiSkin);
|
||||
idvalue = new TextField("", game.uiSkin, "tinytext");
|
||||
txlayout.add(idlabel).pad(padvalue).width(100);
|
||||
txlayout.add(idvalue).pad(padvalue).width(600).row();
|
||||
|
||||
sendbtn = new TextButton("Payola!", uiSkin);
|
||||
txlayout.add(sendbtn).fill().expand().row();
|
||||
sendbtn = new TextButton("Payola!", game.uiSkin);
|
||||
txlayout.add(new Label("", game.uiSkin));
|
||||
txlayout.add(sendbtn);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.jw.lightwallet.screens;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||
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.utils.ClickListener;
|
||||
@@ -25,7 +24,9 @@ public class WalletView {
|
||||
Label unlockedlabel;
|
||||
Label unlockedvalue;
|
||||
Label lockedlabel;
|
||||
Label lockedvalue;
|
||||
Label lockedvalue;
|
||||
Label calcedlabel;
|
||||
Label calcedvalue;
|
||||
TextButton savewalletbtn;
|
||||
Label savewalletlabel;
|
||||
|
||||
@@ -37,7 +38,7 @@ public class WalletView {
|
||||
this.walletsaverpc = walletsaverpc;
|
||||
|
||||
walletlayout = new Table();
|
||||
padvalue = 16;
|
||||
padvalue = 10;
|
||||
|
||||
namelabel = new Label("Name: ", game.uiSkin);
|
||||
namevalue = new Label(game.walletvalues.getName(), game.uiSkin);
|
||||
@@ -65,7 +66,12 @@ public class WalletView {
|
||||
walletlayout.add(lockedlabel).pad(padvalue);
|
||||
walletlayout.add(lockedvalue).pad(padvalue).row();
|
||||
|
||||
savewalletbtn = new TextButton("Save wallet\n(will attempt autosave every 60 s)", game.uiSkin);
|
||||
calcedlabel = new Label("Calculated balance: ", game.uiSkin);
|
||||
calcedvalue = new Label("Loading...", game.uiSkin);
|
||||
walletlayout.add(calcedlabel).pad(padvalue);
|
||||
walletlayout.add(calcedvalue).pad(padvalue).row();
|
||||
|
||||
savewalletbtn = new TextButton("Save (attempts autosave every 60 s)", game.uiSkin);
|
||||
savewalletlabel = new Label("Not saved :(", game.uiSkin, "redlabel");
|
||||
walletlayout.add(savewalletbtn);
|
||||
walletlayout.add(savewalletlabel);
|
||||
|
||||
@@ -4,7 +4,14 @@ public class BalanceValues {
|
||||
|
||||
long unlockedbalance;
|
||||
long lockedbalance;
|
||||
boolean checked;
|
||||
|
||||
public boolean isChecked() {
|
||||
return checked;
|
||||
}
|
||||
public void setChecked(boolean checked) {
|
||||
this.checked = checked;
|
||||
}
|
||||
public Long getUnlockedbalance() {
|
||||
return unlockedbalance;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ public class Tx {
|
||||
|
||||
public static enum Type {SPENT, RECEIVED};
|
||||
public Type type;
|
||||
public long amount;
|
||||
public double amount;
|
||||
public String txid;
|
||||
|
||||
public Tx() {
|
||||
@@ -25,7 +25,7 @@ public class Tx {
|
||||
else {tx.type = Type.SPENT;}
|
||||
|
||||
// Get tx amount
|
||||
tx.amount = (long) (Double.parseDouble(txstring.split(": ")[1].split(",")[0]) * 1e12);
|
||||
tx.amount = Double.parseDouble(txstring.split(": ")[1].split(",")[0]);
|
||||
|
||||
// Get tx id
|
||||
String temptxid = txstring.split("<")[1];
|
||||
@@ -42,7 +42,7 @@ public class Tx {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public long getAmount() {
|
||||
public double getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,13 +31,12 @@ public class BalanceRPC {
|
||||
BalanceResponse balanceresponse = new Gson().fromJson(response, BalanceResponse.class);
|
||||
balancevalues.setLockedbalance(balanceresponse.getResult().getLockedbalance());
|
||||
balancevalues.setUnlockedbalance(balanceresponse.getResult().getUnlockedbalance());
|
||||
|
||||
balancevalues.setChecked(true);
|
||||
}
|
||||
|
||||
public void failed(Throwable t) {
|
||||
response = "failed";
|
||||
//System.out.print("Failed response status is: " + response);
|
||||
//do stuff here based on the failed attempt
|
||||
balancevalues.setChecked(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,10 +7,7 @@ import com.badlogic.gdx.Net.HttpResponse;
|
||||
import com.badlogic.gdx.Net.HttpResponseListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;
|
||||
import com.google.gson.Gson;
|
||||
import com.jw.lightwallet.LightWallet;
|
||||
import com.jw.lightwallet.screens.WalletView;
|
||||
import com.jw.lightwallet.utils.WalletSaveValues;
|
||||
|
||||
|
||||
public class WalletSaveRPC {
|
||||
|
||||
Reference in New Issue
Block a user