mirror of
https://github.com/jwinterm/LightWallet2.git
synced 2026-10-22 06:08:33 +02:00
Actually get everything working with user-agent, remove gson.
This commit is contained in:
@@ -35,12 +35,14 @@ public class LightWallet extends Game {
|
||||
|
||||
if (os.contains("Windows")) {
|
||||
simplewalletloc = dir + "\\" + "monero-wallet-cli.exe";
|
||||
System.out.println(simplewalletloc);
|
||||
} else {
|
||||
simplewalletloc = dir + "/" + "monero-wallet-cli";
|
||||
}
|
||||
System.out.println(simplewalletloc);
|
||||
|
||||
// Initialize logger and user interface skin
|
||||
Gdx.app.log(LightWallet.LOG, "Launching application in " + dir + " on " + os);
|
||||
uiSkin = new Skin(Gdx.files.internal("skin/uiskin.json"));
|
||||
uiSkin = new Skin(Gdx.files.internal("assets/skin/uiskin.json"));
|
||||
|
||||
// Check if config file exists, if not launch setup wizard
|
||||
File f = new File("lightwallet.conf");
|
||||
|
||||
@@ -25,6 +25,7 @@ public class BlockHeader {
|
||||
return difficulty;
|
||||
}
|
||||
public void setDifficulty(int difficulty) {
|
||||
System.out.println("Diff is now" + difficulty);
|
||||
this.difficulty = difficulty;
|
||||
}
|
||||
public String getHash() {
|
||||
|
||||
@@ -13,6 +13,8 @@ public class DaemonRPC {
|
||||
public String address;
|
||||
String response;
|
||||
String getlastblock;
|
||||
Gson gson;
|
||||
DaemonResponse daemonresponse = new DaemonResponse();
|
||||
|
||||
public DaemonRPC () {
|
||||
// address = "http://node.moneroclub.com:8880/json_rpc";
|
||||
@@ -28,19 +30,17 @@ public class DaemonRPC {
|
||||
Gdx.net.sendHttpRequest (httpGet, new HttpResponseListener() {
|
||||
public void handleHttpResponse(HttpResponse httpResponse) {
|
||||
response = httpResponse.getResultAsString();
|
||||
//System.out.print("1st time response" + response);
|
||||
DaemonResponse daemonresponse = new Gson().fromJson(response, DaemonResponse.class);
|
||||
//System.out.print("GSON response is" + daemonresponse.getId());
|
||||
daemonvalues.setBlockheight(daemonresponse.getResult().getBlock_header().getHeight());
|
||||
daemonvalues.setDiff((daemonresponse.getResult().getBlock_header().getDifficulty()));
|
||||
daemonvalues.setLastblocktime(daemonresponse.getResult().getBlock_header().getTimestamp());
|
||||
daemonvalues.setLastblockreward(daemonresponse.getResult().getBlock_header().getReward());
|
||||
daemonvalues.setStatus(daemonresponse.getResult().getStatus());
|
||||
// System.out.println("1st time response" + response);
|
||||
daemonvalues.setBlockheight(Integer.parseInt(response.split("height\": ")[1].split(",")[0]));
|
||||
daemonvalues.setDiff(Long.parseLong(response.split("difficulty\": ")[1].split(",")[0]));
|
||||
daemonvalues.setLastblocktime(Long.parseLong(response.split("difficulty\": ")[1].split(",")[0]));
|
||||
daemonvalues.setLastblockreward(Long.parseLong(response.split("reward\": ")[1].split(",")[0]));
|
||||
daemonvalues.setStatus("OK");
|
||||
}
|
||||
|
||||
public void failed(Throwable t) {
|
||||
response = "failed";
|
||||
//System.out.print("Failed response status is: " + response);
|
||||
System.out.print("Failed response status is: " + response);
|
||||
//do stuff here based on the failed attempt
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ public class DaemonResponse {
|
||||
String jsonrpc;
|
||||
DaemonResult result;
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ public class DaemonResult {
|
||||
|
||||
BlockHeader block_header;
|
||||
String status;
|
||||
|
||||
|
||||
|
||||
public BlockHeader getBlock_header() {
|
||||
return block_header;
|
||||
|
||||
@@ -18,7 +18,7 @@ public class AbstractScreen implements Screen {
|
||||
|
||||
public AbstractScreen (final LightWallet game) {
|
||||
this.game = game;
|
||||
this.font = new BitmapFont(Gdx.files.internal("fonts/bauchaomaicha.fnt"));
|
||||
this.font = new BitmapFont(Gdx.files.internal("assets/fonts/bauchaomaicha.fnt"));
|
||||
this.w = Gdx.graphics.getWidth();
|
||||
this.h = Gdx.graphics.getHeight();
|
||||
this.aspect = w/h;
|
||||
|
||||
@@ -61,7 +61,7 @@ public class CreateScreen extends AbstractScreen {
|
||||
super(game);
|
||||
System.out.print("CreateScreen creating.");
|
||||
|
||||
uiSkin = new Skin(Gdx.files.internal("skin/uiskin.json"));
|
||||
uiSkin = new Skin(Gdx.files.internal("assets/skin/uiskin.json"));
|
||||
padvalue = 20;
|
||||
|
||||
stage = new Stage();
|
||||
@@ -69,14 +69,14 @@ public class CreateScreen extends AbstractScreen {
|
||||
|
||||
screenlayout = new Table();
|
||||
|
||||
logo = new Image(new Texture(Gdx.files.internal("logo.png")));
|
||||
logo = new Image(new Texture(Gdx.files.internal("assets/logo.png")));
|
||||
//logo.scaleBy(0.02f);
|
||||
|
||||
instruction = "Please enter a name for your wallet in the \"Wallet name\" field. This is typically wallet.bin, "
|
||||
+ "but you can make it whatever you like (as long as it is alphanumberic and periods only). "
|
||||
+ "Then please enter a strong password for your wallet that you will use to unlock, and then repeat it to ensure it is correct. "
|
||||
+ "Your password can be any combination of characters and symbols on your keyboard (I think). "
|
||||
+ "The default bitmonerod node is set for moneroclub, if you want to run a local daemon change the node field to http://localhost:18081.";
|
||||
+ "The default bitmonerod node is set for moneroworld, if you want to run a local daemon change the node field to http://localhost:18081.";
|
||||
|
||||
instructionlabel= new Label(instruction, uiSkin);
|
||||
instructionlabel.setWrap(true);
|
||||
@@ -195,7 +195,7 @@ public class CreateScreen extends AbstractScreen {
|
||||
System.out.println("Starting creator");
|
||||
|
||||
try {
|
||||
Process wp = Runtime.getRuntime().exec("monero-wallet-cli --generate-new-wallet " + name + " --password " + pw);
|
||||
Process wp = Runtime.getRuntime().exec(simplewalletloc + " --generate-new-wallet " + name + " --password " + pw);
|
||||
Writer wr = new OutputStreamWriter( wp.getOutputStream() );
|
||||
BufferedReader rd = new BufferedReader( new InputStreamReader( wp.getInputStream() ) );
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public class DaemonView {
|
||||
public void Update(DaemonValues daemonvalues) {
|
||||
nodevalue.setText(game.walletvalues.getNode());
|
||||
statusvalue.setText(daemonvalues.getStatus());
|
||||
// Gdx.app.log(LightWallet.LOG, "Status value is: " + statusvalue.getText());
|
||||
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");
|
||||
|
||||
@@ -66,14 +66,14 @@ public class ImportKeysScreen extends AbstractScreen {
|
||||
|
||||
screenlayout = new Table();
|
||||
|
||||
logo = new Image(new Texture(Gdx.files.internal("logo.png")));
|
||||
logo = new Image(new Texture(Gdx.files.internal("assets/logo.png")));
|
||||
//logo.scaleBy(0.02f);
|
||||
|
||||
instruction = "Please enter the full path location of your .keys file to import in the file location field; , "
|
||||
+ "for instance: C:\\Users\\jw\\secretstuff\\wallet.keys or /home/jw/secretstuff/wallet.keys. "
|
||||
+ "Then please enter your password to unlock the wallet. "
|
||||
+ "The wallet keys file will be copied to the local directory and a new binary file will be created. "
|
||||
+ "The default bitmonerod node is set for moneroclub, if you want to run a local daemon change the node field to http://localhost:18081.";
|
||||
+ "The default bitmonerod node is set for moneroworld, if you want to run a local daemon change the node field to http://localhost:18081.";
|
||||
|
||||
instructionlabel= new Label(instruction, game.uiSkin);
|
||||
instructionlabel.setWrap(true);
|
||||
@@ -222,7 +222,7 @@ public class ImportKeysScreen extends AbstractScreen {
|
||||
|
||||
|
||||
try {
|
||||
Process wp = Runtime.getRuntime().exec("monero-wallet-cli --wallet-file " + name + " --password " + pw + " --daemon-address http://localhost:66666");
|
||||
Process wp = Runtime.getRuntime().exec(simplewalletloc + " --wallet-file " + name + " --password " + pw + " --daemon-address http://localhost:66666");
|
||||
Writer wr = new OutputStreamWriter( wp.getOutputStream() );
|
||||
BufferedReader rd = new BufferedReader( new InputStreamReader( wp.getInputStream() ) );
|
||||
|
||||
@@ -234,25 +234,37 @@ public class ImportKeysScreen extends AbstractScreen {
|
||||
game.walletvalues.setAddress(str.split("wallet: ")[1]);
|
||||
}
|
||||
i += 1;
|
||||
if (i > 5 && str.contains("****")) {
|
||||
if (i > 3 && str.contains("****")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
str = rd.readLine();
|
||||
str = rd.readLine();
|
||||
str = rd.readLine();
|
||||
str = rd.readLine();
|
||||
str = rd.readLine();
|
||||
|
||||
wr.write( "viewkey\n" );
|
||||
wr.flush();
|
||||
|
||||
str = rd.readLine();
|
||||
System.out.println(i + " " + str.split(": ")[1]);
|
||||
// str = rd.readLine();
|
||||
// System.out.println(i + " " + str.split(": ")[1]);
|
||||
System.out.println(i + " " + str);
|
||||
i += 1;
|
||||
game.walletvalues.setViewkey(str.split(": ")[1]);
|
||||
|
||||
// game.walletvalues.setViewkey(str.split(": ")[1]);
|
||||
game.walletvalues.setViewkey(str);
|
||||
str = rd.readLine();
|
||||
|
||||
wr.write( "seed\n" );
|
||||
wr.flush();
|
||||
|
||||
str = rd.readLine();
|
||||
System.out.println(i + " " + str.substring(str.indexOf(":"), str.length()));
|
||||
// str = rd.readLine();
|
||||
// System.out.println(i + " " + str.substring(str.indexOf(":"), str.length()));
|
||||
System.out.println(i + " " + str);
|
||||
i += 1;
|
||||
game.walletvalues.setSeed(str.substring(str.indexOf(":"), str.length()));
|
||||
// game.walletvalues.setSeed(str.substring(str.indexOf(":"), str.length()));
|
||||
game.walletvalues.setSeed(str);
|
||||
|
||||
wr.write( "exit\n" );
|
||||
wr.flush();
|
||||
|
||||
@@ -70,13 +70,13 @@ public class ImportSeedScreen extends AbstractScreen {
|
||||
|
||||
screenlayout = new Table();
|
||||
|
||||
logo = new Image(new Texture(Gdx.files.internal("logo.png")));
|
||||
logo = new Image(new Texture(Gdx.files.internal("assets/logo.png")));
|
||||
//logo.scaleBy(0.02f);
|
||||
|
||||
instruction = "Please enter a name for your wallet, the 25 word mnemonic seed to import in the seed field, "
|
||||
+ " a password to unlock the wallet in the password field, "
|
||||
+ "and then repeat the password to make sure you have it correct, this will be used to encrypt your newly restored wallet files. "
|
||||
+ "The default bitmonerod node is set for moneroclub, if you want to run a local daemon change the node field to http://localhost:18081.";
|
||||
+ "The default bitmonerod node is set for moneroworld, if you want to run a local daemon change the node field to http://localhost:18081.";
|
||||
|
||||
instructionlabel= new Label(instruction, game.uiSkin);
|
||||
instructionlabel.setWrap(true);
|
||||
@@ -233,7 +233,7 @@ public class ImportSeedScreen extends AbstractScreen {
|
||||
|
||||
|
||||
try {
|
||||
Process wp = Runtime.getRuntime().exec("monero-wallet-cli --restore-deterministic-wallet --daemon-address http://localhost:66666");
|
||||
Process wp = Runtime.getRuntime().exec(simplewalletloc + " --restore-deterministic-wallet --wallet-file " + name + " --password " + pw + " --daemon-address http://localhost:66666");
|
||||
Writer wr = new OutputStreamWriter( wp.getOutputStream() );
|
||||
BufferedReader rd = new BufferedReader( new InputStreamReader( wp.getInputStream() ) );
|
||||
|
||||
@@ -243,35 +243,16 @@ public class ImportSeedScreen extends AbstractScreen {
|
||||
str = rd.readLine();
|
||||
System.out.println(i + " " + str);
|
||||
i += 1;
|
||||
if (i > 1 && str.contains("Wallet")) {
|
||||
if (i > 0 && str.contains("Logging at")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
wr.write( name + "\n" );
|
||||
wr.flush();
|
||||
wr.write( pw + "\n" );
|
||||
wr.flush();
|
||||
|
||||
wr.write( seed + "\n" );
|
||||
wr.flush();
|
||||
|
||||
|
||||
MessageDigest md = null;
|
||||
String rando = name + Double.toString(Math.random());
|
||||
try {
|
||||
md = MessageDigest.getInstance("SHA-256");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
md.update(rando.getBytes("UTF-8")); // Change this to "UTF-16" if needed
|
||||
byte[] digest = md.digest();
|
||||
|
||||
game.walletvalues.setName(name);
|
||||
game.walletvalues.setPw(pw);
|
||||
game.walletvalues.setSeed(seed);
|
||||
game.walletvalues.setNode(nodetext.getText());
|
||||
game.walletvalues.setUserAgent(digest.toString());
|
||||
wr.write("0\n" );
|
||||
wr.flush();
|
||||
|
||||
|
||||
|
||||
while (true) {
|
||||
@@ -294,6 +275,23 @@ public class ImportSeedScreen extends AbstractScreen {
|
||||
|
||||
wr.write( "exit\n" );
|
||||
wr.flush();
|
||||
|
||||
MessageDigest md = null;
|
||||
String rando = name + Double.toString(Math.random());
|
||||
try {
|
||||
md = MessageDigest.getInstance("SHA-256");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
md.update(rando.getBytes("UTF-8")); // Change this to "UTF-16" if needed
|
||||
byte[] digest = md.digest();
|
||||
|
||||
game.walletvalues.setName(name);
|
||||
game.walletvalues.setPw(pw);
|
||||
game.walletvalues.setSeed(seed);
|
||||
game.walletvalues.setNode(nodetext.getText());
|
||||
game.walletvalues.setUserAgent(digest.toString());
|
||||
|
||||
|
||||
PrintWriter infowriter = new PrintWriter(name + "info.txt", "UTF-8");
|
||||
|
||||
@@ -95,12 +95,12 @@ public class MainScreen extends AbstractScreen {
|
||||
df = new DecimalFormat("#.############");
|
||||
height = "";
|
||||
|
||||
Skin uiSkin = new Skin(Gdx.files.internal("skin/uiskin.json"));
|
||||
Skin uiSkin = new Skin(Gdx.files.internal("assets/skin/uiskin.json"));
|
||||
|
||||
daemonrpc = new DaemonRPC();
|
||||
daemonvalues = new DaemonValues();
|
||||
|
||||
balancerpc = new BalanceRPC();
|
||||
balancerpc = new BalanceRPC(game);
|
||||
balancevalues = new BalanceValues();
|
||||
|
||||
walletsaverpc = new WalletSaveRPC(game);
|
||||
@@ -112,7 +112,7 @@ public class MainScreen extends AbstractScreen {
|
||||
screenlayout = new Table();
|
||||
viewcontainer = new Table();
|
||||
|
||||
logo = new Image(new Texture(Gdx.files.internal("logo.png")));
|
||||
logo = new Image(new Texture(Gdx.files.internal("assets/logo.png")));
|
||||
|
||||
buttonrow = new Table();
|
||||
daemonbutton = new TextButton("Daemon", uiSkin);
|
||||
@@ -216,16 +216,19 @@ public class MainScreen extends AbstractScreen {
|
||||
if (fivesectimer == true) {
|
||||
// Timer task to check balance from simplewallet
|
||||
balancerpc.getinfo(balancevalues);
|
||||
// Gdx.app.log(LightWallet.LOG, "Checked: " + balancevalues.getChecked());
|
||||
walletview.balancevalue.setText(df.format(balancevalues.getBalance()/1e12) + " XMR");
|
||||
walletview.unlockedvalue.setText(df.format(balancevalues.getUnlockedbalance()/1e12) + " XMR");
|
||||
if (balancevalues.isChecked()) {
|
||||
if (balancevalues.getChecked()) {
|
||||
// Gdx.app.log(LightWallet.LOG, "Balance is checked.");
|
||||
walletview.balancevalue.setStyle(game.uiSkin.get("greenlabel", LabelStyle.class));
|
||||
walletview.unlockedvalue.setStyle(game.uiSkin.get("greenlabel", LabelStyle.class));
|
||||
} else {
|
||||
// Gdx.app.log(LightWallet.LOG, "Balance is NOT checked.");
|
||||
walletview.balancevalue.setStyle(game.uiSkin.get("redlabel", LabelStyle.class));
|
||||
walletview.unlockedvalue.setStyle(game.uiSkin.get("redlabel", LabelStyle.class));
|
||||
}
|
||||
Gdx.app.log(LightWallet.LOG, "Height is at: " + height);
|
||||
// Gdx.app.log(LightWallet.LOG, "Height is at: " + height);
|
||||
walletview.syncvalue.setText(height + " / " + daemonvalues.getBlockheight());
|
||||
if (height.equals(Integer.toString(daemonvalues.getBlockheight()))) {
|
||||
walletview.syncvalue.setStyle(game.uiSkin.get("greenlabel", LabelStyle.class));
|
||||
@@ -263,7 +266,7 @@ public class MainScreen extends AbstractScreen {
|
||||
Gdx.app.log(LightWallet.LOG, "Command is: " + "monero-wallet-cli --wallet-file " + game.walletvalues.getName()
|
||||
+ " --password " + game.walletvalues.getPw() + " --daemon-address " + game.walletvalues.getNode()
|
||||
+ " --rpc-bind-port 19091 --user-agent " + game.walletvalues.getUserAgent() + " --log-level 2");
|
||||
wp = Runtime.getRuntime().exec("monero-wallet-cli --wallet-file " + game.walletvalues.getName()
|
||||
wp = Runtime.getRuntime().exec(game.simplewalletloc + " --wallet-file " + game.walletvalues.getName()
|
||||
+ " --password " + game.walletvalues.getPw() + " --daemon-address " + game.walletvalues.getNode()
|
||||
+ " --rpc-bind-port 19091 --user-agent " + game.walletvalues.getUserAgent() + " --log-level 2");
|
||||
wr = new BufferedReader(new InputStreamReader(wp.getInputStream()));
|
||||
@@ -292,6 +295,9 @@ public class MainScreen extends AbstractScreen {
|
||||
// Poll wallet thread and check block height and if transaction data is in output
|
||||
String queuepoll = wq.poll();
|
||||
try{
|
||||
if (queuepoll != null) {
|
||||
Gdx.app.log(LightWallet.LOG, queuepoll);
|
||||
}
|
||||
// If the string contains "height" then update the daemon and wallet screen blockheight
|
||||
if (queuepoll != null && queuepoll.contains("height:")) {
|
||||
height = queuepoll.split("height: ")[1].split(",")[0];
|
||||
@@ -326,6 +332,32 @@ public class MainScreen extends AbstractScreen {
|
||||
failuredialog.key(Keys.ENTER, true); //sends "true" when the ENTER key is pressed
|
||||
failuredialog.show(stage);
|
||||
}
|
||||
else if (queuepoll != null && queuepoll.contains("Transaction successfully sent.")) {
|
||||
// Setup popup for successful tx
|
||||
final String txid = queuepoll.split("<<")[1].split(">>")[0];
|
||||
final Dialog goodtxpopup = new Dialog("Succcessful transaction!", game.uiSkin, "dialog") {
|
||||
public void result(Object obj) {
|
||||
System.out.println("result "+obj);
|
||||
}
|
||||
};
|
||||
Label goodtxpopuplabel = new Label("Successfully completed tx with tx is:\n" + txid, game.uiSkin);
|
||||
goodtxpopuplabel.setWrap(true);
|
||||
goodtxpopup.add(goodtxpopuplabel).width(400).row();
|
||||
goodtxpopup.button("Copy tx id", true).addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked (InputEvent event, float x, float y) {
|
||||
Gdx.app.getClipboard().setContents(txid);
|
||||
}
|
||||
});
|
||||
goodtxpopup.button("Continue", true).addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked (InputEvent event, float x, float y) {
|
||||
goodtxpopup.remove();
|
||||
}
|
||||
});
|
||||
goodtxpopup.key(Keys.ENTER, true); //sends "true" when the ENTER key is pressed
|
||||
goodtxpopup.show(stage);
|
||||
}
|
||||
} catch (NullPointerException e){e.printStackTrace();}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class PasswordScreen extends AbstractScreen {
|
||||
super(game);
|
||||
System.out.print("CreateScreen creating.");
|
||||
|
||||
uiSkin = new Skin(Gdx.files.internal("skin/uiskin.json"));
|
||||
uiSkin = new Skin(Gdx.files.internal("assets/skin/uiskin.json"));
|
||||
padvalue = 20;
|
||||
|
||||
stage = new Stage();
|
||||
@@ -53,7 +53,7 @@ public class PasswordScreen extends AbstractScreen {
|
||||
|
||||
screenlayout = new Table();
|
||||
|
||||
logo = new Image(new Texture(Gdx.files.internal("logo.png")));
|
||||
logo = new Image(new Texture(Gdx.files.internal("assets/logo.png")));
|
||||
//logo.scaleBy(0.02f);
|
||||
|
||||
instruction = "Please enter your password in the password field below for the wallet" + game.walletvalues.getName() + ". "
|
||||
|
||||
@@ -212,6 +212,8 @@ public class TransactionView {
|
||||
httpGet.setUrl(swaddress);
|
||||
httpGet.setContent(getbalance);
|
||||
httpGet.setTimeOut(2500);
|
||||
httpGet.setHeader("User-Agent", game.walletvalues.getUserAgent());
|
||||
|
||||
|
||||
Gdx.net.sendHttpRequest (httpGet, new HttpResponseListener() {
|
||||
public void handleHttpResponse(HttpResponse httpResponse) {
|
||||
@@ -222,36 +224,7 @@ public class TransactionView {
|
||||
System.out.println(txresponse.getResult().getTx_hash());
|
||||
|
||||
String txid = txresponse.getResult().getTx_hash().substring(1, txresponse.getResult().getTx_hash().length()-1);;
|
||||
|
||||
System.out.println("Tx id is: " + txid);
|
||||
System.out.println("Tx id length is: " + txid.length());
|
||||
|
||||
if (txid.length() == 64) {
|
||||
// Setup popup for successful tx
|
||||
final String finaltxid = txid;
|
||||
final Dialog goodtxpopup = new Dialog("Succcessful transaction!", game.uiSkin, "dialog") {
|
||||
public void result(Object obj) {
|
||||
System.out.println("result "+obj);
|
||||
}
|
||||
};
|
||||
Label goodtxpopuplabel = new Label("Successfully completed tx with tx is:\n" + txid, game.uiSkin);
|
||||
goodtxpopuplabel.setWrap(true);
|
||||
goodtxpopup.add(goodtxpopuplabel).width(400).row();
|
||||
goodtxpopup.button("Copy tx id", true).addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked (InputEvent event, float x, float y) {
|
||||
Gdx.app.getClipboard().setContents(finaltxid);
|
||||
}
|
||||
});
|
||||
goodtxpopup.button("Continue", true).addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked (InputEvent event, float x, float y) {
|
||||
goodtxpopup.remove();
|
||||
}
|
||||
});
|
||||
goodtxpopup.key(Keys.ENTER, true); //sends "true" when the ENTER key is pressed
|
||||
goodtxpopup.show(stage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void failed(Throwable t) {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class WizardScreen extends AbstractScreen {
|
||||
public WizardScreen(final LightWallet game) {
|
||||
super(game);
|
||||
|
||||
uiSkin = new Skin(Gdx.files.internal("skin/uiskin.json"));
|
||||
uiSkin = new Skin(Gdx.files.internal("assets/skin/uiskin.json"));
|
||||
padvalue = 20;
|
||||
|
||||
stage = new Stage();
|
||||
@@ -44,10 +44,11 @@ public class WizardScreen extends AbstractScreen {
|
||||
|
||||
screenlayout = new Table();
|
||||
|
||||
logo = new Image(new Texture(Gdx.files.internal("logo.png")));
|
||||
logo = new Image(new Texture(Gdx.files.internal("assets/logo.png")));
|
||||
|
||||
|
||||
wizardtext = "Hello. It seems this is the either the first time you are launching LightWallet or you have deleted your lightwallet.conf file. "
|
||||
+ "You must have a copy of monero-wallet-cli executable in the same directory as the LightWallet executable. "
|
||||
+ "Please select from the options below whether you would like to create a new wallet, import a wallet from a .keys file, "
|
||||
+ "or import a wallet using your 25-word mnemonic seed.";
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ public class BalanceValues {
|
||||
long balance;
|
||||
boolean checked;
|
||||
|
||||
public boolean isChecked() {
|
||||
public boolean getChecked() {
|
||||
return checked;
|
||||
}
|
||||
public void setChecked(boolean checked) {
|
||||
|
||||
@@ -7,14 +7,18 @@ import com.badlogic.gdx.Net.HttpResponse;
|
||||
import com.badlogic.gdx.Net.HttpResponseListener;
|
||||
import com.google.gson.Gson;
|
||||
import com.jw.lightwallet.utils.BalanceValues;
|
||||
import com.jw.lightwallet.LightWallet;
|
||||
|
||||
|
||||
|
||||
public class BalanceRPC {
|
||||
LightWallet game;
|
||||
public String swaddress;
|
||||
String response;
|
||||
String getbalance;
|
||||
|
||||
public BalanceRPC () {
|
||||
public BalanceRPC (LightWallet game) {
|
||||
this.game = game;
|
||||
swaddress = "http://localhost:19091/json_rpc";
|
||||
getbalance = "{\"jsonrpc\":\"2.0\",\"id\":\"test\",\"method\":\"getbalance\",\"params\":[]}";
|
||||
}
|
||||
@@ -22,19 +26,29 @@ public class BalanceRPC {
|
||||
public void getinfo (final BalanceValues balancevalues) {
|
||||
HttpRequest httpGet = new HttpRequest(HttpMethods.POST);
|
||||
httpGet.setUrl(swaddress);
|
||||
httpGet.setContent(getbalance);
|
||||
httpGet.setContent(getbalance);
|
||||
httpGet.setHeader("User-Agent", game.walletvalues.getUserAgent());
|
||||
|
||||
Gdx.net.sendHttpRequest (httpGet, new HttpResponseListener() {
|
||||
public void handleHttpResponse(HttpResponse httpResponse) {
|
||||
response = httpResponse.getResultAsString();
|
||||
BalanceResponse balanceresponse = new Gson().fromJson(response, BalanceResponse.class);
|
||||
balancevalues.setBalance(balanceresponse.getResult().getBalance());
|
||||
balancevalues.setUnlockedbalance(balanceresponse.getResult().getUnlockedbalance());
|
||||
// Gdx.app.log(LightWallet.LOG, "Checked: " + balancevalues.getChecked());
|
||||
// Gdx.app.log(LightWallet.LOG, "Balance is: " + response);
|
||||
// BalanceResponse balanceresponse = new Gson().fromJson(response, BalanceResponse.class);
|
||||
// balancevalues.setBalance(balanceresponse.getResult().getBalance());
|
||||
// balancevalues.setUnlockedbalance(balanceresponse.getResult().getUnlockedbalance());
|
||||
// Gdx.app.log(LightWallet.LOG, response.split("\"balance\": ")[1].split(",")[0]);
|
||||
balancevalues.setBalance(Long.parseLong(response.split("\"balance\": ")[1].split(",")[0]));
|
||||
// Gdx.app.log(LightWallet.LOG, response.split("unlocked_balance\": ")[1].split("}")[0].replaceAll("\\s+",""));
|
||||
balancevalues.setUnlockedbalance(Long.parseLong(response.split("unlocked_balance\": ")[1].split("}")[0].replaceAll("\\s+","")));
|
||||
Gdx.app.log(LightWallet.LOG, "Setting checked true.");
|
||||
balancevalues.setChecked(true);
|
||||
}
|
||||
|
||||
public void failed(Throwable t) {
|
||||
response = "failed";
|
||||
Gdx.app.log(LightWallet.LOG, "Failed - setting checked false.");
|
||||
Gdx.app.log(LightWallet.LOG, t.getMessage());
|
||||
balancevalues.setChecked(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,17 +20,19 @@ public class WalletSaveRPC {
|
||||
this.game = game;
|
||||
swaddress = "http://localhost:19091/json_rpc";
|
||||
store = "{\"jsonrpc\":\"2.0\",\"id\":\"test\",\"method\":\"store\",\"params\":[]}";
|
||||
// store = "{\"jsonrpc\":\"2.0\",\"id\":\"test\",\"user-agent\":" + game.walletvalues.getUserAgent() + ",\"method\":\"store\",\"params\":[]}";
|
||||
}
|
||||
|
||||
public void trysave (final Label savestatuslabel) {
|
||||
HttpRequest httpGet = new HttpRequest(HttpMethods.POST);
|
||||
httpGet.setUrl(swaddress);
|
||||
httpGet.setContent(store);
|
||||
httpGet.setContent(store);
|
||||
httpGet.setHeader("User-Agent", game.walletvalues.getUserAgent());
|
||||
|
||||
Gdx.net.sendHttpRequest (httpGet, new HttpResponseListener() {
|
||||
public void handleHttpResponse(HttpResponse httpResponse) {
|
||||
response = httpResponse.getResultAsString();
|
||||
//System.out.print("Balance response: " + response);
|
||||
// System.out.print("Save response: " + response);
|
||||
savestatuslabel.setText("Successfully saved");
|
||||
savestatuslabel.setStyle(game.uiSkin.get("greenlabel", LabelStyle.class));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user