From 143dfdae2787df8cacaf810e89d72aa8dac4f92f Mon Sep 17 00:00:00 2001 From: jwinterm Date: Tue, 22 Dec 2015 08:56:38 -0800 Subject: [PATCH] Got wallet height read working and started tx layout. --- android/assets/skin/uiskin.json | 1 + core/src/com/jw/lightwallet/LightWallet.java | 21 ++- .../com/jw/lightwallet/daemon/DaemonRPC.java | 2 +- .../jw/lightwallet/daemon/DaemonResponse.java | 6 +- .../jw/lightwallet/daemon/DaemonResult.java | 24 ++++ .../jw/lightwallet/screens/CreateScreen.java | 3 +- .../jw/lightwallet/screens/DaemonView.java | 2 +- .../jw/lightwallet/screens/MainScreen.java | 123 ++++++++++++++--- .../lightwallet/screens/PasswordScreen.java | 126 ++++++++++++++++++ .../lightwallet/screens/TransactionView.java | 54 ++++++++ .../jw/lightwallet/screens/WalletView.java | 34 ++++- .../jw/lightwallet/utils/BalanceValues.java | 21 +++ .../com/jw/lightwallet/utils/Constants.java | 3 +- .../jw/lightwallet/utils/WalletValues.java | 12 +- .../com/jw/lightwallet/wallet/BalanceRPC.java | 49 +++++++ .../lightwallet/wallet/BalanceResponse.java | 31 +++++ .../jw/lightwallet/wallet/BalanceResult.java | 21 +++ desktop/log/dr-monero/block_proc.data | 0 desktop/log/dr-monero/blockchain_log.data | 0 desktop/log/dr-monero/down_sleep_log.data | 0 .../log/dr-monero/get_objects_calc_time.data | 0 desktop/log/dr-monero/limit_down.info | 0 desktop/log/dr-monero/limit_up.info | 0 desktop/log/dr-monero/net/in-all.data | 0 desktop/log/dr-monero/net/out-all.data | 0 desktop/log/dr-monero/net/req-all.data | 0 desktop/log/dr-monero/peers.data | 0 desktop/log/dr-monero/peers_limit.info | 0 desktop/log/dr-monero/up_sleep_log.data | 0 29 files changed, 504 insertions(+), 29 deletions(-) create mode 100644 core/src/com/jw/lightwallet/daemon/DaemonResult.java create mode 100644 core/src/com/jw/lightwallet/screens/PasswordScreen.java create mode 100644 core/src/com/jw/lightwallet/utils/BalanceValues.java create mode 100644 core/src/com/jw/lightwallet/wallet/BalanceRPC.java create mode 100644 core/src/com/jw/lightwallet/wallet/BalanceResponse.java create mode 100644 core/src/com/jw/lightwallet/wallet/BalanceResult.java create mode 100644 desktop/log/dr-monero/block_proc.data create mode 100644 desktop/log/dr-monero/blockchain_log.data create mode 100644 desktop/log/dr-monero/down_sleep_log.data create mode 100644 desktop/log/dr-monero/get_objects_calc_time.data create mode 100644 desktop/log/dr-monero/limit_down.info create mode 100644 desktop/log/dr-monero/limit_up.info create mode 100644 desktop/log/dr-monero/net/in-all.data create mode 100644 desktop/log/dr-monero/net/out-all.data create mode 100644 desktop/log/dr-monero/net/req-all.data create mode 100644 desktop/log/dr-monero/peers.data create mode 100644 desktop/log/dr-monero/peers_limit.info create mode 100644 desktop/log/dr-monero/up_sleep_log.data diff --git a/android/assets/skin/uiskin.json b/android/assets/skin/uiskin.json index acaa30c..dcc8af2 100644 --- a/android/assets/skin/uiskin.json +++ b/android/assets/skin/uiskin.json @@ -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 } diff --git a/core/src/com/jw/lightwallet/LightWallet.java b/core/src/com/jw/lightwallet/LightWallet.java index e8cea1a..d4f64b2 100644 --- a/core/src/com/jw/lightwallet/LightWallet.java +++ b/core/src/com/jw/lightwallet/LightWallet.java @@ -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));} } diff --git a/core/src/com/jw/lightwallet/daemon/DaemonRPC.java b/core/src/com/jw/lightwallet/daemon/DaemonRPC.java index 571aae9..6418f7f 100644 --- a/core/src/com/jw/lightwallet/daemon/DaemonRPC.java +++ b/core/src/com/jw/lightwallet/daemon/DaemonRPC.java @@ -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; diff --git a/core/src/com/jw/lightwallet/daemon/DaemonResponse.java b/core/src/com/jw/lightwallet/daemon/DaemonResponse.java index e7884e3..272b306 100644 --- a/core/src/com/jw/lightwallet/daemon/DaemonResponse.java +++ b/core/src/com/jw/lightwallet/daemon/DaemonResponse.java @@ -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; } diff --git a/core/src/com/jw/lightwallet/daemon/DaemonResult.java b/core/src/com/jw/lightwallet/daemon/DaemonResult.java new file mode 100644 index 0000000..ea9ea49 --- /dev/null +++ b/core/src/com/jw/lightwallet/daemon/DaemonResult.java @@ -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; + } + + + +} diff --git a/core/src/com/jw/lightwallet/screens/CreateScreen.java b/core/src/com/jw/lightwallet/screens/CreateScreen.java index 4022211..3ddacbe 100644 --- a/core/src/com/jw/lightwallet/screens/CreateScreen.java +++ b/core/src/com/jw/lightwallet/screens/CreateScreen.java @@ -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); diff --git a/core/src/com/jw/lightwallet/screens/DaemonView.java b/core/src/com/jw/lightwallet/screens/DaemonView.java index 4aaca88..09446a4 100644 --- a/core/src/com/jw/lightwallet/screens/DaemonView.java +++ b/core/src/com/jw/lightwallet/screens/DaemonView.java @@ -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"); diff --git a/core/src/com/jw/lightwallet/screens/MainScreen.java b/core/src/com/jw/lightwallet/screens/MainScreen.java index 3bed9c0..65a866b 100644 --- a/core/src/com/jw/lightwallet/screens/MainScreen.java +++ b/core/src/com/jw/lightwallet/screens/MainScreen.java @@ -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 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(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 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(); + + } + + } diff --git a/core/src/com/jw/lightwallet/screens/PasswordScreen.java b/core/src/com/jw/lightwallet/screens/PasswordScreen.java new file mode 100644 index 0000000..e0e84cc --- /dev/null +++ b/core/src/com/jw/lightwallet/screens/PasswordScreen.java @@ -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(); + + } + +} diff --git a/core/src/com/jw/lightwallet/screens/TransactionView.java b/core/src/com/jw/lightwallet/screens/TransactionView.java index b21943b..4b582db 100644 --- a/core/src/com/jw/lightwallet/screens/TransactionView.java +++ b/core/src/com/jw/lightwallet/screens/TransactionView.java @@ -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(); + + + } } diff --git a/core/src/com/jw/lightwallet/screens/WalletView.java b/core/src/com/jw/lightwallet/screens/WalletView.java index 2c81d91..50580d5 100644 --- a/core/src/com/jw/lightwallet/screens/WalletView.java +++ b/core/src/com/jw/lightwallet/screens/WalletView.java @@ -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(); + } } diff --git a/core/src/com/jw/lightwallet/utils/BalanceValues.java b/core/src/com/jw/lightwallet/utils/BalanceValues.java new file mode 100644 index 0000000..f4a36d0 --- /dev/null +++ b/core/src/com/jw/lightwallet/utils/BalanceValues.java @@ -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; + } + +} diff --git a/core/src/com/jw/lightwallet/utils/Constants.java b/core/src/com/jw/lightwallet/utils/Constants.java index f5c9001..dbbfc40 100644 --- a/core/src/com/jw/lightwallet/utils/Constants.java +++ b/core/src/com/jw/lightwallet/utils/Constants.java @@ -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"; } diff --git a/core/src/com/jw/lightwallet/utils/WalletValues.java b/core/src/com/jw/lightwallet/utils/WalletValues.java index 5cd4670..b0aaab8 100644 --- a/core/src/com/jw/lightwallet/utils/WalletValues.java +++ b/core/src/com/jw/lightwallet/utils/WalletValues.java @@ -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; + } + } diff --git a/core/src/com/jw/lightwallet/wallet/BalanceRPC.java b/core/src/com/jw/lightwallet/wallet/BalanceRPC.java new file mode 100644 index 0000000..22d2648 --- /dev/null +++ b/core/src/com/jw/lightwallet/wallet/BalanceRPC.java @@ -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 + } + }); + } +} diff --git a/core/src/com/jw/lightwallet/wallet/BalanceResponse.java b/core/src/com/jw/lightwallet/wallet/BalanceResponse.java new file mode 100644 index 0000000..eddbccd --- /dev/null +++ b/core/src/com/jw/lightwallet/wallet/BalanceResponse.java @@ -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; + } + + +} diff --git a/core/src/com/jw/lightwallet/wallet/BalanceResult.java b/core/src/com/jw/lightwallet/wallet/BalanceResult.java new file mode 100644 index 0000000..df7de98 --- /dev/null +++ b/core/src/com/jw/lightwallet/wallet/BalanceResult.java @@ -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; + } + +} diff --git a/desktop/log/dr-monero/block_proc.data b/desktop/log/dr-monero/block_proc.data new file mode 100644 index 0000000..e69de29 diff --git a/desktop/log/dr-monero/blockchain_log.data b/desktop/log/dr-monero/blockchain_log.data new file mode 100644 index 0000000..e69de29 diff --git a/desktop/log/dr-monero/down_sleep_log.data b/desktop/log/dr-monero/down_sleep_log.data new file mode 100644 index 0000000..e69de29 diff --git a/desktop/log/dr-monero/get_objects_calc_time.data b/desktop/log/dr-monero/get_objects_calc_time.data new file mode 100644 index 0000000..e69de29 diff --git a/desktop/log/dr-monero/limit_down.info b/desktop/log/dr-monero/limit_down.info new file mode 100644 index 0000000..e69de29 diff --git a/desktop/log/dr-monero/limit_up.info b/desktop/log/dr-monero/limit_up.info new file mode 100644 index 0000000..e69de29 diff --git a/desktop/log/dr-monero/net/in-all.data b/desktop/log/dr-monero/net/in-all.data new file mode 100644 index 0000000..e69de29 diff --git a/desktop/log/dr-monero/net/out-all.data b/desktop/log/dr-monero/net/out-all.data new file mode 100644 index 0000000..e69de29 diff --git a/desktop/log/dr-monero/net/req-all.data b/desktop/log/dr-monero/net/req-all.data new file mode 100644 index 0000000..e69de29 diff --git a/desktop/log/dr-monero/peers.data b/desktop/log/dr-monero/peers.data new file mode 100644 index 0000000..e69de29 diff --git a/desktop/log/dr-monero/peers_limit.info b/desktop/log/dr-monero/peers_limit.info new file mode 100644 index 0000000..e69de29 diff --git a/desktop/log/dr-monero/up_sleep_log.data b/desktop/log/dr-monero/up_sleep_log.data new file mode 100644 index 0000000..e69de29