diff --git a/core/src/com/jw/lightwallet/LightWallet.java b/core/src/com/jw/lightwallet/LightWallet.java index fe4e3fd..e8cea1a 100644 --- a/core/src/com/jw/lightwallet/LightWallet.java +++ b/core/src/com/jw/lightwallet/LightWallet.java @@ -4,49 +4,44 @@ import java.io.File; import com.badlogic.gdx.Game; import com.badlogic.gdx.Gdx; -import com.jw.lightwallet.screens.CreateScreen; -import com.jw.lightwallet.screens.ImportKeysScreen; -import com.jw.lightwallet.screens.ImportSeedScreen; import com.jw.lightwallet.screens.MainScreen; import com.jw.lightwallet.screens.WizardScreen; +import com.jw.lightwallet.utils.WalletValues; public class LightWallet extends Game { public static final String LOG = LightWallet.class.getSimpleName(); // Logging constant public String dir; - - // Set screen methods - public MainScreen getMainScreen(){ - return new MainScreen(this); - } - public WizardScreen getWizardScreen(){ - return new WizardScreen(this); - } - public CreateScreen getCreateScreen(){ - return new CreateScreen(this); - } - public ImportKeysScreen getImportKeysScreen(){ - return new ImportKeysScreen(this); - } - public ImportSeedScreen getImportSeedScreen(){ - return new ImportSeedScreen(this); - } + public String os; + public String simplewalletloc; + public WalletValues walletvalues; + @Override public void create () { - // Initialize logger - Gdx.app.log(LightWallet.LOG, "Launching application"); + + // Object to store wallet values + walletvalues = new WalletValues(); // Get directory where program launched dir = System.getProperty("user.dir"); + os = System.getProperty("os.name"); + + if (os.contains("Windows")) { + simplewalletloc = dir + "\\" + "simplewallet.exe"; + System.out.println(simplewalletloc); + } + + // Initialize logger + Gdx.app.log(LightWallet.LOG, "Launching application in " + dir + " on " + os); // Check if config file exists, if not launch setup wizard File f = new File("lightwallet.conf"); if(f.exists() && !f.isDirectory()) { - setScreen(getMainScreen()); + setScreen(new MainScreen(this)); } - else {setScreen(getWizardScreen());} + 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 2de744a..571aae9 100644 --- a/core/src/com/jw/lightwallet/daemon/DaemonRPC.java +++ b/core/src/com/jw/lightwallet/daemon/DaemonRPC.java @@ -27,9 +27,9 @@ public class DaemonRPC { Gdx.net.sendHttpRequest (httpGet, new HttpResponseListener() { public void handleHttpResponse(HttpResponse httpResponse) { response = httpResponse.getResultAsString(); - System.out.print("1st time response" + response); + //System.out.print("1st time response" + response); DaemonResponse daemonresponse = new Gson().fromJson(response, DaemonResponse.class); - System.out.print("GSON response is" + daemonresponse.getId()); + //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()); @@ -39,7 +39,7 @@ public class DaemonRPC { 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 } diff --git a/core/src/com/jw/lightwallet/screens/CreateScreen.java b/core/src/com/jw/lightwallet/screens/CreateScreen.java index 5b9b2ed..4022211 100644 --- a/core/src/com/jw/lightwallet/screens/CreateScreen.java +++ b/core/src/com/jw/lightwallet/screens/CreateScreen.java @@ -1,9 +1,18 @@ package com.jw.lightwallet.screens; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.io.Writer; + import com.badlogic.gdx.Gdx; +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.Dialog; import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Skin; @@ -12,7 +21,7 @@ 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; +import com.jw.lightwallet.utils.Constants; public class CreateScreen extends AbstractScreen { @@ -38,14 +47,14 @@ public class CreateScreen extends AbstractScreen { Label pwrptlabel; TextField pwrpttext; String pwrpt; + Label nodelabel; + TextField nodetext; Table buttontable; TextButton createbutton; TextButton gobackbutton; - CreateWallet createwallet; - public CreateScreen(final LightWallet game) { super(game); System.out.print("CreateScreen creating."); @@ -64,7 +73,8 @@ public class CreateScreen extends AbstractScreen { 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)."; + + "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."; instructionlabel= new Label(instruction, uiSkin); instructionlabel.setWrap(true); @@ -82,12 +92,16 @@ public class CreateScreen extends AbstractScreen { pwrpttext = new TextField("", uiSkin); pwrpttext.setPasswordMode(true); pwrpttext.setPasswordCharacter((char) 42); + nodelabel = new Label("Node address: ", uiSkin); + nodetext = new TextField(Constants.moneroclub, uiSkin); 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(); + inputtable.add(nodelabel).width(200); + inputtable.add(nodetext).width(400).row(); buttontable = new Table(); createbutton = new TextButton("Create!", uiSkin); @@ -99,7 +113,7 @@ public class CreateScreen extends AbstractScreen { pwrpt = pwrpttext.getText(); if (name.length() > 0 && pw.equals(pwrpt)) { System.out.println(name + ", " + pw + ", " + pwrpt); - createwallet = new CreateWallet(name, pw); + CreateWallet(name, pw, game.simplewalletloc); } //game.setScreen(game.getCreateScreen()); } @@ -108,7 +122,7 @@ public class CreateScreen extends AbstractScreen { gobackbutton.addListener(new ClickListener() { @Override public void clicked (InputEvent event, float x, float y) { - game.setScreen(game.getWizardScreen()); + game.setScreen(new WizardScreen(game)); } }); buttontable.add(createbutton).width(150); @@ -121,6 +135,8 @@ public class CreateScreen extends AbstractScreen { screenlayout.setFillParent(true); stage.addActor(screenlayout); + + } public void show() { @@ -140,6 +156,105 @@ public class CreateScreen extends AbstractScreen { super.dispose(); } + + public void CreateWallet(String name, String pw, String simplewalletloc) { + + int i = 0; + boolean flag = false; + String str = null; + String seed = ""; + + Dialog success_dialog = new Dialog("Success!", uiSkin, "dialog") { + public void result(Object obj) { + System.out.println("result "+obj); + } + }; + Label success_label = new Label("Wallet successfully created. " + name + " file is your binary wallet file. " + + name + ".keys is your keys file; " + + "the keys file is password protected and you can restore your binary wallet file with it. " + + " A text file named " + name + "info.txt has also been created. This file contains your wallet recovery seed and view key. " + + "Please encrypt this file or print it and delete it. Your wallet seed allows wallet recovery and bypasses your password." + + "A file named lightwallet.conf has also been created; this file specifies the wallet and node currently in use.", uiSkin); + success_label.setWrap(true); + success_dialog.add(success_label).width(400).row(); + success_dialog.button("Continue", true).addListener(new ClickListener() { + @Override + public void clicked (InputEvent event, float x, float y) { + game.setScreen(new MainScreen(game)); + uiSkin.dispose(); + stage.dispose(); + } + }); + success_dialog.key(Keys.ENTER, true); //sends "true" when the ENTER key is pressed + + + + System.out.println("Starting creator"); + + try { + Process tr = Runtime.getRuntime().exec("simplewallet --generate-new-wallet " + name + " --password " + pw); + 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) { + str = rd.readLine(); + System.out.println(i + " " + str); + i += 1; + if (str.contains("Japanese")) { + break; + } + } + wr.write( "0\n" ); + wr.flush(); + + while (true) { + str = rd.readLine(); + System.out.println(i + " " + str); + i += 1; + if (str.contains("*****") && flag == true) {break;} + if (str.contains("*****")) {flag = true;} + if (str.contains("new wallet:")) { + game.walletvalues.setAddress(str.split("wallet: ")[1]); + } + if (str.contains("view key:")) { + game.walletvalues.setViewkey(str.split("key: ")[1]); + } + if (i >=23 && i <=26) {seed += str;} + } + + wr.write( "exit\n" ); + wr.flush(); + + game.walletvalues.setName(name); + game.walletvalues.setPw(pw); + game.walletvalues.setSeed(seed); + + PrintWriter infowriter = new PrintWriter(name + "info.txt", "UTF-8"); + infowriter.println("Wallet name: " + name); + infowriter.println("Wallet pw: " + pw); + infowriter.println("Wallet address: " + game.walletvalues.getAddress()); + infowriter.println("Wallet view key: " + game.walletvalues.getViewkey()); + infowriter.println("Wallet seed: " + game.walletvalues.getSeed()); + infowriter.close(); + + PrintWriter confwriter = new PrintWriter("lightwallet.conf", "UTF-8"); + confwriter.println("Wallet name: " + name); + confwriter.println("Wallet address: " + game.walletvalues.getAddress()); + confwriter.println("Wallet view key: " + game.walletvalues.getViewkey()); + confwriter.println("Node address: " + nodetext.getText()); + confwriter.close(); + + success_dialog.show(stage); + } + + catch (IOException e) { + System.out.println("exception happened - here's what I know: "); + e.printStackTrace(); + } + Gdx.app.log(LightWallet.LOG, "Address is: " + game.walletvalues.getAddress()); + Gdx.app.log(LightWallet.LOG, "Seed is: " + game.walletvalues.getSeed()); + } } diff --git a/core/src/com/jw/lightwallet/screens/MainScreen.java b/core/src/com/jw/lightwallet/screens/MainScreen.java index bde5e4b..3bed9c0 100644 --- a/core/src/com/jw/lightwallet/screens/MainScreen.java +++ b/core/src/com/jw/lightwallet/screens/MainScreen.java @@ -119,7 +119,7 @@ public class MainScreen extends AbstractScreen { daemonrpc.getinfo(daemonvalues); daemonview.Update(daemonvalues); } - }, 1f, 5f); + }, 1f, 10f); } diff --git a/core/src/com/jw/lightwallet/screens/WizardScreen.java b/core/src/com/jw/lightwallet/screens/WizardScreen.java index c65c073..a01752e 100644 --- a/core/src/com/jw/lightwallet/screens/WizardScreen.java +++ b/core/src/com/jw/lightwallet/screens/WizardScreen.java @@ -61,7 +61,7 @@ public class WizardScreen extends AbstractScreen { createbutton.addListener(new ClickListener() { @Override public void clicked (InputEvent event, float x, float y) { - game.setScreen(game.getCreateScreen()); + game.setScreen(new CreateScreen(game)); } }); createbutton.pad(padvalue); @@ -70,7 +70,7 @@ public class WizardScreen extends AbstractScreen { importkeysbutton.addListener(new ClickListener() { @Override public void clicked (InputEvent event, float x, float y) { - game.setScreen(game.getImportKeysScreen()); + game.setScreen(new ImportKeysScreen(game)); } }); importkeysbutton.pad(padvalue); @@ -79,7 +79,7 @@ public class WizardScreen extends AbstractScreen { importseedbutton.addListener(new ClickListener() { @Override public void clicked (InputEvent event, float x, float y) { - game.setScreen(game.getImportSeedScreen()); + game.setScreen(new ImportSeedScreen(game)); } }); importseedbutton.pad(padvalue); diff --git a/core/src/com/jw/lightwallet/utils/CreateWallet.java b/core/src/com/jw/lightwallet/utils/CreateWallet.java deleted file mode 100644 index 9e418cf..0000000 --- a/core/src/com/jw/lightwallet/utils/CreateWallet.java +++ /dev/null @@ -1,84 +0,0 @@ -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); - } - } - -} diff --git a/core/src/com/jw/lightwallet/utils/WalletValues.java b/core/src/com/jw/lightwallet/utils/WalletValues.java new file mode 100644 index 0000000..5cd4670 --- /dev/null +++ b/core/src/com/jw/lightwallet/utils/WalletValues.java @@ -0,0 +1,44 @@ +package com.jw.lightwallet.utils; + +public class WalletValues { + + String name; + String pw; + String address; + String viewkey; + String seed; + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getPw() { + return pw; + } + public void setPw(String pw) { + this.pw = pw; + } + public String getAddress() { + return address; + } + public void setAddress(String address) { + this.address = address; + } + public String getViewkey() { + return viewkey; + } + public void setViewkey(String viewkey) { + this.viewkey = viewkey; + } + public String getSeed() { + return seed; + } + public void setSeed(String seed) { + this.seed = seed; + } + + + +} diff --git a/core/bitmonerod.exe b/desktop/bitmonerod.exe similarity index 100% rename from core/bitmonerod.exe rename to desktop/bitmonerod.exe diff --git a/desktop/ffff b/desktop/ffff new file mode 100644 index 0000000..a093c6b --- /dev/null +++ b/desktop/ffff @@ -0,0 +1,4 @@ +hl›qf¬’ŠbnÛbÊkÑá”KÌ»ýœàšÝ.Êbõ/¸¿-kT/FVÚzK0ðæ›i‹â&=rÓà®z›o]o9 +=Ö^/›=Šl(–V©–¾oDéG`«ê· ðGyÒÁƒ +ŽßCaöcUÞ4ÉùûœYñ’–×rA{*@×û(”9ͽ×A¥.7«ò_n¯â ~ +ìÌúéÿ×H�)7Û�‹�0_³Šñƒz�“¢{aÀ$ÿ>†?;Š[ ö뎜ÐÑÿ·Ç – å;)1šiTÞêÆïUó‰WæÌOzWC‚ÓPLÐ'·™ùù@ÍϳÍxîõrXËEùvÖ˜�Òªz<ÀÐ�³[ƒ£ \ No newline at end of file diff --git a/desktop/ffff.address.txt b/desktop/ffff.address.txt new file mode 100644 index 0000000..9ff727c --- /dev/null +++ b/desktop/ffff.address.txt @@ -0,0 +1 @@ +46CPGcWMGHViB2f1jitYvtUf9qitPobAZRSJteqe7Nrx9PvAZBGrEExCyoG4LHGkEoZ9Yyez1xety7dkDN7N99Jx4dfX5C6 \ No newline at end of file diff --git a/desktop/ffff.keys b/desktop/ffff.keys new file mode 100644 index 0000000..2007faf Binary files /dev/null and b/desktop/ffff.keys differ diff --git a/desktop/ffffinfo.txt b/desktop/ffffinfo.txt new file mode 100644 index 0000000..ff92850 --- /dev/null +++ b/desktop/ffffinfo.txt @@ -0,0 +1,5 @@ +Wallet name: ffff +Wallet pw: f +Wallet address: 46CPGcWMGHViB2f1jitYvtUf9qitPobAZRSJteqe7Nrx9PvAZBGrEExCyoG4LHGkEoZ9Yyez1xety7dkDN7N99Jx4dfX5C6 +Wallet view key: eb45bd3b2d7949facc10a573f4bf302772a1bb192ca9f47ccfe41a6d78b45708 +Wallet seed: jackets soprano goes auctions inbound ailments fruit rustledaimless tilt hawk hobby stylishly people fever muffinvogue emails deodorant oilfield dabbing idled inundate joking muffin diff --git a/desktop/libeay32.dll b/desktop/libeay32.dll new file mode 100644 index 0000000..7c3f4a7 Binary files /dev/null and b/desktop/libeay32.dll differ diff --git a/desktop/libwinpthread-1.dll b/desktop/libwinpthread-1.dll new file mode 100644 index 0000000..e25834a Binary files /dev/null and b/desktop/libwinpthread-1.dll differ diff --git a/desktop/lightwallet.conf b/desktop/lightwallet.conf new file mode 100644 index 0000000..e0d3b62 --- /dev/null +++ b/desktop/lightwallet.conf @@ -0,0 +1,4 @@ +Wallet name: ffff +Wallet address: 46CPGcWMGHViB2f1jitYvtUf9qitPobAZRSJteqe7Nrx9PvAZBGrEExCyoG4LHGkEoZ9Yyez1xety7dkDN7N99Jx4dfX5C6 +Wallet view key: eb45bd3b2d7949facc10a573f4bf302772a1bb192ca9f47ccfe41a6d78b45708 +Node address: http://node.monoerclub.com/json_rpc:8880 diff --git a/core/simplewallet.exe b/desktop/simplewallet.exe similarity index 100% rename from core/simplewallet.exe rename to desktop/simplewallet.exe diff --git a/desktop/simplewallet.log b/desktop/simplewallet.log new file mode 100644 index 0000000..be5b0f4 --- /dev/null +++ b/desktop/simplewallet.log @@ -0,0 +1,21 @@ +2015-Dec-19 14:29:52.053920 bitmonero wallet v0.8.8.7-575af61 +2015-Dec-19 14:29:52.053920 Setting log level = 0 +2015-Dec-19 14:29:52.053920 default_log: E:\src\lightwallet2\desktop\simplewallet.log +2015-Dec-19 14:29:52.053920 Logging at log level 0 to E:\src\lightwallet2\desktop\simplewallet.log +2015-Dec-19 14:31:10.312694 bitmonero wallet v0.8.8.7-575af61 +2015-Dec-19 14:31:10.312694 Setting log level = 0 +2015-Dec-19 14:31:10.312694 default_log: E:\src\lightwallet2\desktop\simplewallet.log +2015-Dec-19 14:31:10.312694 Logging at log level 0 to E:\src\lightwallet2\desktop\simplewallet.log +2015-Dec-19 14:31:10.322698 ERROR C:/msys64/bitmonero-build/src/wallet/wallet2.cpp:706 boost::filesystem::exists(m_wallet_file, ignored_ec). THROW EXCEPTION: error::file_exists +2015-Dec-19 14:31:10.343698 C:/msys64/bitmonero-build/src/wallet/wallet2.cpp:706:N5tools5error15file_error_baseILi0EEE: file already exists "f" +2015-Dec-19 14:31:10.351737 Error: failed to generate new wallet: file already exists "f" +2015-Dec-19 14:31:10.352699 ERROR C:/msys64/bitmonero-build/src/simplewallet/simplewallet.cpp:751 account creation failed +2015-Dec-19 14:31:10.352699 ERROR C:/msys64/bitmonero-build/src/simplewallet/simplewallet.cpp:2252 Failed to initialize wallet +2015-Dec-19 14:48:33.513986 bitmonero wallet v0.8.8.7-575af61 +2015-Dec-19 14:48:33.528025 Setting log level = 0 +2015-Dec-19 14:48:33.528025 default_log: E:\src\lightwallet2\desktop\simplewallet.log +2015-Dec-19 14:48:33.528025 Logging at log level 0 to E:\src\lightwallet2\desktop\simplewallet.log +2015-Dec-19 22:10:17.047590 bitmonero wallet v0.8.8.7-575af61 +2015-Dec-19 22:10:17.048590 Setting log level = 0 +2015-Dec-19 22:10:17.048590 default_log: E:\src\lightwallet2\desktop\simplewallet.log +2015-Dec-19 22:10:17.048590 Logging at log level 0 to E:\src\lightwallet2\desktop\simplewallet.log diff --git a/desktop/ssleay32.dll b/desktop/ssleay32.dll new file mode 100644 index 0000000..97f1db0 Binary files /dev/null and b/desktop/ssleay32.dll differ