mirror of
https://github.com/jwinterm/LightWallet2.git
synced 2026-10-17 05:21:26 +02:00
Got wallet generation started...kinda.
This commit is contained in:
@@ -11,7 +11,10 @@ import com.jw.lightwallet.screens.MainScreen;
|
||||
import com.jw.lightwallet.screens.WizardScreen;
|
||||
|
||||
public class LightWallet extends Game {
|
||||
public static final String LOG = LightWallet.class.getSimpleName(); // Logging constant
|
||||
|
||||
public static final String LOG = LightWallet.class.getSimpleName(); // Logging constant
|
||||
|
||||
public String dir;
|
||||
|
||||
// Set screen methods
|
||||
public MainScreen getMainScreen(){
|
||||
@@ -35,6 +38,9 @@ public class LightWallet extends Game {
|
||||
// Initialize logger
|
||||
Gdx.app.log(LightWallet.LOG, "Launching application");
|
||||
|
||||
// Get directory where program launched
|
||||
dir = System.getProperty("user.dir");
|
||||
|
||||
// Check if config file exists, if not launch setup wizard
|
||||
File f = new File("lightwallet.conf");
|
||||
if(f.exists() && !f.isDirectory()) {
|
||||
|
||||
@@ -2,6 +2,7 @@ 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;
|
||||
@@ -9,7 +10,9 @@ 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;
|
||||
import com.jw.lightwallet.utils.CreateWallet;
|
||||
|
||||
public class CreateScreen extends AbstractScreen {
|
||||
|
||||
@@ -21,23 +24,31 @@ public class CreateScreen extends AbstractScreen {
|
||||
Image logo;
|
||||
Texture logotex;
|
||||
|
||||
Table textcontainer;
|
||||
String instruction;
|
||||
Label instructionlabel;
|
||||
Table textcontainer;
|
||||
|
||||
|
||||
Table inputtable;
|
||||
Label namelabel;
|
||||
TextField nametext;
|
||||
String name;
|
||||
Label pwlabel;
|
||||
TextField pwtext;
|
||||
String pw;
|
||||
Label pwrptlabel;
|
||||
TextField pwrpttext;
|
||||
String pwrpt;
|
||||
|
||||
Table buttontable;
|
||||
TextButton createbutton;
|
||||
TextButton gobackbutton;
|
||||
|
||||
|
||||
CreateWallet createwallet;
|
||||
|
||||
public CreateScreen(final LightWallet game) {
|
||||
super(game);
|
||||
System.out.print("CreateScreen creating.");
|
||||
|
||||
uiSkin = new Skin(Gdx.files.internal("skin/uiskin.json"));
|
||||
padvalue = 20;
|
||||
@@ -48,7 +59,7 @@ public class CreateScreen extends AbstractScreen {
|
||||
screenlayout = new Table();
|
||||
|
||||
logo = new Image(new Texture(Gdx.files.internal("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). "
|
||||
@@ -60,9 +71,53 @@ public class CreateScreen extends AbstractScreen {
|
||||
textcontainer = new Table();
|
||||
textcontainer.add(instructionlabel).width(600);
|
||||
|
||||
screenlayout.add(logo).pad(10).center().row();
|
||||
inputtable = new Table();
|
||||
namelabel = new Label("Wallet name: ", uiSkin);
|
||||
nametext = new TextField("", uiSkin);
|
||||
pwlabel = new Label("Password: ", uiSkin);
|
||||
pwtext = new TextField("", uiSkin);
|
||||
pwtext.setPasswordMode(true);
|
||||
pwtext.setPasswordCharacter((char) 42);
|
||||
pwrptlabel = new Label("Repeat password: ", uiSkin);
|
||||
pwrpttext = new TextField("", uiSkin);
|
||||
pwrpttext.setPasswordMode(true);
|
||||
pwrpttext.setPasswordCharacter((char) 42);
|
||||
inputtable.add(namelabel).width(200);
|
||||
inputtable.add(nametext).width(400).row();
|
||||
inputtable.add(pwlabel).width(200);
|
||||
inputtable.add(pwtext).width(400).row();
|
||||
inputtable.add(pwrptlabel).width(200);
|
||||
inputtable.add(pwrpttext).width(400).row();
|
||||
|
||||
buttontable = new Table();
|
||||
createbutton = new TextButton("Create!", uiSkin);
|
||||
createbutton.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked (InputEvent event, float x, float y) {
|
||||
name = nametext.getText();
|
||||
pw = pwtext.getText();
|
||||
pwrpt = pwrpttext.getText();
|
||||
if (name.length() > 0 && pw.equals(pwrpt)) {
|
||||
System.out.println(name + ", " + pw + ", " + pwrpt);
|
||||
createwallet = new CreateWallet(name, pw);
|
||||
}
|
||||
//game.setScreen(game.getCreateScreen());
|
||||
}
|
||||
});
|
||||
gobackbutton = new TextButton("Cancel", uiSkin);
|
||||
gobackbutton.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked (InputEvent event, float x, float y) {
|
||||
game.setScreen(game.getWizardScreen());
|
||||
}
|
||||
});
|
||||
buttontable.add(createbutton).width(150);
|
||||
buttontable.add(gobackbutton).width(150);
|
||||
|
||||
screenlayout.add(logo).pad(10).width(200).height(50).center().row();
|
||||
screenlayout.add(textcontainer).pad(padvalue).row();
|
||||
//screenlayout.add(buttontable).pad(padvalue).row();
|
||||
screenlayout.add(inputtable).pad(padvalue).row();
|
||||
screenlayout.add(buttontable).pad(padvalue).row();
|
||||
|
||||
screenlayout.setFillParent(true);
|
||||
stage.addActor(screenlayout);
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.jw.lightwallet.utils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
public class CreateWallet {
|
||||
|
||||
String name;
|
||||
String pw;
|
||||
|
||||
|
||||
public CreateWallet(String name, String pw) {
|
||||
|
||||
this.name = name;
|
||||
this.pw = pw;
|
||||
|
||||
System.out.println("Starting creator");
|
||||
String s = null;
|
||||
System.out.println("Working Directory = " +
|
||||
System.getProperty("user.dir"));
|
||||
|
||||
try {
|
||||
|
||||
Process tr = Runtime.getRuntime().exec("E:\\src\\lightWallet\\simplewallet.exe --generate-new-wallet jj --password jj");
|
||||
Writer wr = new OutputStreamWriter( tr.getOutputStream() );
|
||||
BufferedReader rd = new BufferedReader( new InputStreamReader( tr.getInputStream() ) );
|
||||
System.out.println("Here is the standard output of the command:\n");
|
||||
while (true) {
|
||||
String str = rd.readLine();
|
||||
System.out.println( str );
|
||||
if (str.contains("Japanese")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
wr.write( "0\n" );
|
||||
wr.flush();
|
||||
String str = rd.readLine();
|
||||
System.out.println( str );
|
||||
System.out.println("Here is the standard output of the command:\n");
|
||||
while ((s = rd.readLine()) != null) {
|
||||
System.out.println(s);
|
||||
}
|
||||
|
||||
wr.write( "exit\n" );
|
||||
wr.flush();
|
||||
/*
|
||||
// run the Unix "ps -ef" command
|
||||
// using the Runtime exec method:
|
||||
Process p = Runtime.getRuntime().exec("E:\\src\\lightWallet\\simplewallet.exe --generate-new-wallet jj --password jj");
|
||||
|
||||
BufferedReader stdInput = new BufferedReader(new
|
||||
InputStreamReader(p.getInputStream()));
|
||||
|
||||
BufferedReader stdError = new BufferedReader(new
|
||||
InputStreamReader(p.getErrorStream()));
|
||||
|
||||
|
||||
// read the output from the command
|
||||
System.out.println("Here is the standard output of the command:\n");
|
||||
while ((s = stdInput.readLine()) != null) {
|
||||
System.out.println(s);
|
||||
}
|
||||
|
||||
// read any errors from the attempted command
|
||||
System.out.println("Here is the standard error of the command (if any):\n");
|
||||
while ((s = stdError.readLine()) != null) {
|
||||
System.out.println(s);
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
System.exit(0);
|
||||
}
|
||||
catch (IOException e) {
|
||||
System.out.println("exception happened - here's what I know: ");
|
||||
e.printStackTrace();
|
||||
System.exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user