From 94e1db3a4e0659f9e5076e5db1556c5eea04a6de Mon Sep 17 00:00:00 2001 From: Sander Ferdinand Date: Tue, 13 Nov 2018 02:19:26 +0100 Subject: [PATCH] 0.1.1 --- INSTALL.md | 40 +++++++ LICENSE | 10 ++ README.md | 68 ++--------- package.json | 2 +- src/index.ejs | 6 +- src/main/config.js | 75 ++++++++++++ src/main/index.js | 48 +++++--- src/main/wowrpc.js | 27 ++++- src/renderer/App.vue | 107 ++++-------------- src/renderer/assets/bootstrap.min.css | 7 -- src/renderer/assets/fa.css | 5 - src/renderer/assets/messages.js | 88 ++++++++++++++ src/renderer/assets/wow.css | 29 +++++ src/renderer/components/Landing/Credits.vue | 7 +- .../components/Landing/LandingPage.vue | 75 +++++++++--- src/renderer/components/Landing/Settings.vue | 76 +++++++++++++ .../components/Landing/WarioLanding.vue | 14 ++- .../components/Landing/WarioSettings.vue | 59 ++++++++++ .../Landing/components/WfsExplorer.vue | 2 +- .../Pages/components/TxHistoryList.vue | 1 - .../Wizards/CreateWalletOptions.vue | 2 +- .../components/Wizards/CreateWalletSeed.vue | 3 +- src/renderer/main.js | 6 + src/renderer/router/index.js | 7 +- src/renderer/store/index.js | 35 +++++- 25 files changed, 588 insertions(+), 211 deletions(-) create mode 100644 INSTALL.md create mode 100644 LICENSE create mode 100644 src/main/config.js delete mode 100644 src/renderer/assets/bootstrap.min.css delete mode 100644 src/renderer/assets/fa.css create mode 100644 src/renderer/assets/messages.js create mode 100644 src/renderer/components/Landing/Settings.vue create mode 100644 src/renderer/components/Landing/WarioSettings.vue diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000..b92d809 --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,40 @@ +## Compile + +Requirements: + +- Node v8 +- Latest Wownero (CLI) + `git apply light_diff.patch` + +#### Electron + +``` bash +# install dependencies +npm install + +# serve with hot reload at localhost:9080 +npm run dev +``` + +If `npm run dev` works, you can install a custom version of `wownero-wallet-cli` + +#### wownero-wallet-cli :star2: + +``` +git clone https://github.com/wownero/wownero.git +cd wownero +git checkout +git apply light_patch.diff +make -j4 +``` + +Use `light_patch.diff` that's included in this repository. Move resulting binary into the resources folder: + +``` +cp build/release/bin/wownero-wallet-cli wowlight/resources/linux/bin/wowlight +``` + +Build the light wallet: + +``` +npm run build +``` \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f43a89f --- /dev/null +++ b/LICENSE @@ -0,0 +1,10 @@ + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2018 Wownero Inc., a Monero Enterprise Alliance partner company + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. \ No newline at end of file diff --git a/README.md b/README.md index ab61872..68bdf3b 100644 --- a/README.md +++ b/README.md @@ -1,69 +1,17 @@ -# Wownero Light Wallet :computer: :two_hearts: :ok_hand: +# wowlight -An experimental crypto wallet for Wownero. Possibly the worst ever made. 100% WOW. -- Electron/Vue.js -- Remote node only -- Linux/Windows/OSX -- Integration with [WFS](https://funding.wownero.com) -- USD/WOW conversion - -## Compile :two_men_holding_hands: - -Requirements: - -- Node v8 :-1: -- Wownero on tag `v0.3.1.1` :fire: -- A patch to the above git tag :sunglasses: - -#### Electron :sob: - -Clone this repo and install npm packages: - -``` bash -# install dependencies -npm install - -# serve with hot reload at localhost:9080 -npm run dev - -# build electron application for production -npm run build -``` +![](https://light.wownero.com/wowlight.png) -If `npm run dev` works, you can install a custom version of `wownero-wallet-cli` :alien: +Wownero wallet full of questionable development practices. -#### wownero-wallet-cli :star2: - -``` -git clone https://github.com/wownero/wownero.git -cd wownero -git checkout tags/v0.3.1.1 -git apply light_patch.diff -make -j4 -``` - -Use `light_patch.diff` that's included in this repository. :two_women_holding_hands: - -If it compiled successfully; you can move the binary into the resources folder: - -``` -cp build/release/bin/wownero-wallet-cli wowlight/resources/linux/bin/wowlight -``` - -Build the light wallet: - -``` -npm run build -``` - -Resulting build will go into `build/` - -### Technical +- Electron/Vue.js +- Remote node only +- 100% WOW -This GUI is a wrapper for a custom `wownero-wallet-cli`. `stdout` is parsed with Regex. What can go wrong :scream: ? +Download: [https://light.wownero.com](https://light.wownero.com) -The code base is one big spaghetti. 100% WOW. +See `Install.md` for compilation instructions. ### License diff --git a/package.json b/package.json index c5b419f..efbdbe8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wowlight", - "version": "0.1.0", + "version": "0.1.1", "author": "dsc ", "description": "Wownero Light Wallet", "license": "WTFPL", diff --git a/src/index.ejs b/src/index.ejs index 05887ca..c3a7948 100644 --- a/src/index.ejs +++ b/src/index.ejs @@ -14,8 +14,12 @@ - <% } %> + + + + +
diff --git a/src/main/config.js b/src/main/config.js new file mode 100644 index 0000000..d691ecc --- /dev/null +++ b/src/main/config.js @@ -0,0 +1,75 @@ +const fs = require('fs'); + + +export class Config { + constructor(wowdir) { + this._path_cfg = `${wowdir}/wowlight.json`; + this.create(); + this.data = this.load(); + } + + load(){ + if (!fs.existsSync(this._path_cfg)) { + console.log('no file yo'); + return {}; + } + + let contents = fs.readFileSync(this._path_cfg, 'utf8'); + return JSON.parse(contents); + } + + create(){ + if (fs.existsSync(this._path_cfg)) { + return; + } + + let data = JSON.stringify({ + "node": "node.wowne.ro:34568", + "nodes": [ + {"address": "node.wowne.ro:34568", "location": "New Jersey, United States", "region": "US"}, + {"address": "node.pwned.systems:34568", "location": "Amsterdam, The Netherlands", "region": "EU"}, + {"address": "node.wownero.com:34568", "location": "Montreal, Canada", "region": "US"}, + {"address": "localhost:34568", 'location': "", "region": "*"} + ], + "wallet_path": "" + }); + + fs.writeFileSync(this._path_cfg, JSON.stringify(data)); + console.log(`${this._path_cfg} written`); + } + + save(){ + fs.writeFileSync(this._path_cfg, JSON.stringify(this.data, null, 4)); + console.log(`${this._path_cfg} written`); + } + + selectNode(node){ + if (typeof this.data === 'string' || this.data instanceof String){ + this.data = JSON.parse(this.data); + } + + node = node.trim(); + if(node === ''){ + return; + } + + console.log('NEW NODE: ' + node); + this.data.node = node; + this.save(); + + return true; + } + + saveLastWalletPath(path){ + if (typeof this.data === 'string' || this.data instanceof String){ + this.data = JSON.parse(this.data); + } + + if(path === ''){ + return; + } + + this.data.wallet_path = path; + this.save(); + } +} diff --git a/src/main/index.js b/src/main/index.js index bb0b1bb..26098df 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -12,27 +12,27 @@ let mainWindow const electron = require('electron'); const {ipcMain} = require('electron'); -// import jQuery from 'jquery'; +const path = require('path'); const wowrpc = require('./wowrpc'); - +const config = require('./config'); const Store = require('electron-store'); const store = new Store(); const fs = require('fs'); - const utils = require('electron-util'); let homedir = (process.platform === 'win32') ? process.env.HOMEPATH : process.env.HOME; -let wowdir = `${homedir}/Wownero`; +let wowdir = path.join(homedir, 'Wownero'); if (!fs.existsSync(wowdir)){ console.log(`${wowdir} created`); fs.mkdirSync(wowdir); } +// WowRPC & cfg bootstrap let wallet = new wowrpc.WowRpc(wowdir); - -console.log(`getWalletDir(): ${wowdir}`); +let cfg = new config.Config(wowdir); +wallet._cli_daemon_address = cfg.data.node; const winURL = process.env.NODE_ENV === 'development' ? `http://localhost:9080` : `file://${__dirname}/index.html` import { platform, cliPath } from './binaries'; @@ -55,10 +55,14 @@ function createWindow() { } mainWindow.loadURL(winURL); - // mainWindow.webContents.openDevTools(); - mainWindow.webContents.on("devtools-opened", () => { - mainWindow.webContents.closeDevTools(); - }); + + if(process.env.NODE_ENV === 'development'){ + mainWindow.webContents.openDevTools(); + } else { + mainWindow.webContents.on("devtools-opened", () => { + mainWindow.webContents.closeDevTools(); + }); + } mainWindow.on('closed', () => { mainWindow = null; @@ -99,6 +103,8 @@ function createWindow() { const menu = Menu.buildFromTemplate(template); Menu.setApplicationMenu(menu); } + + wallet.getEmbeddedVersion(); } app.on('ready', createWindow) @@ -125,16 +131,28 @@ app.on('activate', () => { } }); -ipcMain.on('ping', (event, data) => { - console.log("received ping!"); - event.sender.send('pong', Math.random()); +ipcMain.on('rpc_get_embedded_version', (event) => { + wallet.onEmbeddedVersion = (version) => { + event.sender.send( 'embedded_version', version); + }; + wallet.getEmbeddedVersion(); + }); ipcMain.on('rpc_get_wowdir', (event, data) => { - console.log('RPC_GET_WOWDIR'); event.sender.send('rpc_get_wowdir', wowdir); }); +ipcMain.on('rpc_cfg_set_node', (event, node) => { + if(cfg.selectNode(node)){ + wallet._cli_daemon_address = node; + } +}); + +ipcMain.on('rpc_get_cfg', (event) => { + event.sender.send('rpc_get_cfg', cfg.data); +}); + ipcMain.on('rpc_create_wallet', (event, data) => { console.log('creating wallet!'); wallet.onCreateWalletFinished = function(data){ @@ -178,6 +196,7 @@ function resetWallet(){ } wallet = new wowrpc.WowRpc(wowdir); + wallet._cli_daemon_address = cfg.data.node; } ipcMain.on('rpc_close_wallet', (event) => { @@ -192,6 +211,7 @@ ipcMain.on('rpc_kill_wallet', (event) => { ipcMain.on('rpc_open_wallet', (event, data) => { wallet.onWalletOpened = function(data){ + cfg.saveLastWalletPath(data.wallet_path); event.sender.send('rpc_wallet_opened', data); } diff --git a/src/main/wowrpc.js b/src/main/wowrpc.js index a36f20a..40d0a1d 100644 --- a/src/main/wowrpc.js +++ b/src/main/wowrpc.js @@ -23,10 +23,12 @@ export class WowRpc { this._wallet_path = ''; this._cli_wallet_password = ''; this._cli_wallet_address = null; + this._cli_daemon_address = ''; this._cli_wallet_selected_account = null; this._cli_balance_unlocked = null; this._cli_balance = null; this._cli_txs = []; + this._version = ""; this._buffer = ""; this._sending = false; @@ -43,10 +45,6 @@ export class WowRpc { '--generate-new-wallet', this._create_wallet_tmp_path ] - this._cli_args_connect = [ - '--daemon-address', - 'node.wowne.ro:34568' - ]; // '--restore-deterministic-wallet' recover from seed // lil' state machine @@ -364,8 +362,7 @@ export class WowRpc { this._wallet_path = wallet_path; this._cli_wallet_password = wallet_password; - let cli_args = []; - cli_args = cli_args.concat(this._cli_args_connect); + let cli_args = ['--daemon-address', this._cli_daemon_address]; cli_args = cli_args.concat(this._cli_args_default); cli_args.push('--wallet-file'); cli_args.push(wallet_path); @@ -470,6 +467,24 @@ export class WowRpc { } } + getEmbeddedVersion(){ + console.log('Retrieving embedded version.'); + let args = ['--version']; + this._cli_process = childProcess.spawn(this._cli_path, args); + this._cli_process.stdout.on('data', (data) => { + data = new TextDecoder("utf-8").decode(data); + console.log("[cli] " + data); + let version = data.trim().split(" ").slice(1).join(" ").trim(); + this._cli_process.kill(); + + this.onEmbeddedVersion(version); + }); + } + + onEmbeddedVersion(version){ + // overloaded + } + onWalletOpened(data){ // overloaded } diff --git a/src/renderer/App.vue b/src/renderer/App.vue index fb076d1..9f95215 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -31,7 +31,7 @@
-
    -
  • vicer0y
  • +
  • vicer0y (wownero.info)
  • @bl4sty
  • kico (TooL)
  • notmike (popping off)
  • @@ -64,8 +64,7 @@
  • scoobybejesus
  • kloinka
  • ilovetron
  • -
  • OhGodAGirl
  • -
  • Gwen Stefani
  • +
  • \x
diff --git a/src/renderer/components/Landing/LandingPage.vue b/src/renderer/components/Landing/LandingPage.vue index 0fe46b6..21e3868 100644 --- a/src/renderer/components/Landing/LandingPage.vue +++ b/src/renderer/components/Landing/LandingPage.vue @@ -7,18 +7,29 @@

Welcome to wownero light!

  • Electron/Vue.js (OSX/Windows/Linux)
  • -
  • Remote node only
  • +
  • Works most of the time
- - + + + + @@ -26,10 +37,13 @@
Node
-
- + +
+ +
@@ -71,6 +85,9 @@ open(link) { this.$electron.shell.openExternal(link) }, + settings(){ + this.$router.push({name: 'settings'}); + }, createWallet(){ // make sure any stale process is killed anyway ;/ ipcRenderer.send('rpc_kill_wallet'); @@ -100,9 +117,21 @@ }, 50); } }); + }, + openLastWallet(){ + if(!this.cfg_wallet_path || this.cfg_wallet_path === ''){ + alert('Invalid wallet path?!'); + return; + } + + this.$store.commit('addWalletPath', this.cfg_wallet_path); + this.$store.commit('showPassword', { + 'message': 'Enter wallet password' + }); } }, mounted() { + let select_node = jQuery('#selectnode'); const axios = require('axios'); axios.get('https://funding.wownero.com/api/1/convert/wow-usd?amount=1000').then(response => { this.$store.commit('addRate', response.data.usd); @@ -118,13 +147,10 @@ buttons: ['OK'], message: `You are running an old instance of wowlight and need to upgrade!\n\nVisit https://light.wownero.com for a shiny new version.` } - dialog.showMessageBox(dialogOptions, i => { - }); + dialog.showMessageBox(dialogOptions, i => {}); } }); - ipcRenderer.send('rpc_get_wowdir'); - this.$electron.ipcRenderer.on('rpc_wallet_opening', (event) => { console.log('opening'); this.$store.commit('showMessage', { @@ -133,7 +159,15 @@ }); }); - //this.$router.push({name: 'dashboard'}); + select_node.on('change', (fuckme) => { + let address = fuckme.currentTarget.value; + let nodes = this.$store.getters.cfg.nodes; + let node = nodes.find(_node => _node.address === address) + + ipcRenderer.send('rpc_cfg_set_node', node.address); + + jQuery('.node_status .location').html(`Location: ${node.location}`); + }); }, computed: { walletDir(){ @@ -147,6 +181,19 @@ }, wallet(){ return this.$store.state.wallet; + }, + nodes(){ + return this.$store.getters.cfg.nodes; + }, + selected_node(){ + return this.$store.getters.cfg.node; + }, + cfg_wallet_path(){ + return this.$store.getters.cfg.wallet_path; + }, + cfg_wallet_path_name(){ + let path = require("path"); + return path.basename(this.cfg_wallet_path); } } } diff --git a/src/renderer/components/Landing/Settings.vue b/src/renderer/components/Landing/Settings.vue new file mode 100644 index 0000000..43e1a1f --- /dev/null +++ b/src/renderer/components/Landing/Settings.vue @@ -0,0 +1,76 @@ + + + diff --git a/src/renderer/components/Landing/WarioLanding.vue b/src/renderer/components/Landing/WarioLanding.vue index 5366234..efa62de 100644 --- a/src/renderer/components/Landing/WarioLanding.vue +++ b/src/renderer/components/Landing/WarioLanding.vue @@ -17,7 +17,7 @@
- v{{version}} + {{version}} - {{version_embedded}} Credits @@ -36,12 +36,10 @@ name: "WarioLanding", data(){ return { - 'version': null + 'electron_version': null } }, mounted() { - this.version = require('electron').remote.app.getVersion(); - let wario = jQuery('.wario_walking_animated'); let window_width = jQuery(window).width(); @@ -60,6 +58,14 @@ openCredits(){ this.$router.push({name: 'credits'}); } + }, + computed: { + version_embedded(){ + return this.$store.state.version_embedded; + }, + version(){ + return this.$store.state.version; + } } } diff --git a/src/renderer/components/Landing/WarioSettings.vue b/src/renderer/components/Landing/WarioSettings.vue new file mode 100644 index 0000000..12ebbc4 --- /dev/null +++ b/src/renderer/components/Landing/WarioSettings.vue @@ -0,0 +1,59 @@ + + + + + \ No newline at end of file diff --git a/src/renderer/components/Landing/components/WfsExplorer.vue b/src/renderer/components/Landing/components/WfsExplorer.vue index e7798ac..8f94c8f 100644 --- a/src/renderer/components/Landing/components/WfsExplorer.vue +++ b/src/renderer/components/Landing/components/WfsExplorer.vue @@ -9,7 +9,7 @@ - {{Number((proposal.funds_target/100)*proposal.funded_pct).toFixed(2)}} WOW remaining + {{Number((proposal.funds_target - (proposal.funds_target/100)*proposal.funded_pct)).toFixed(2)}} WOW remaining ({{Number(proposal.funded_pct).toFixed(1)}}% funded) diff --git a/src/renderer/components/Pages/components/TxHistoryList.vue b/src/renderer/components/Pages/components/TxHistoryList.vue index ce72621..29631bc 100644 --- a/src/renderer/components/Pages/components/TxHistoryList.vue +++ b/src/renderer/components/Pages/components/TxHistoryList.vue @@ -81,7 +81,6 @@ _txs_pooled.map((tx, i) => { _txs.insert(0, tx); }); - // let _txs = []; return _txs; } }, diff --git a/src/renderer/components/Wizards/CreateWalletOptions.vue b/src/renderer/components/Wizards/CreateWalletOptions.vue index c03f37b..7a34d78 100644 --- a/src/renderer/components/Wizards/CreateWalletOptions.vue +++ b/src/renderer/components/Wizards/CreateWalletOptions.vue @@ -10,7 +10,7 @@
- + A wallet password is recommended but not required.
diff --git a/src/renderer/components/Wizards/CreateWalletSeed.vue b/src/renderer/components/Wizards/CreateWalletSeed.vue index c25c5e6..1227aaf 100644 --- a/src/renderer/components/Wizards/CreateWalletSeed.vue +++ b/src/renderer/components/Wizards/CreateWalletSeed.vue @@ -89,7 +89,8 @@ let path_wallet = path.join(this.walletDir, this.wallet.name); ipcRenderer.send('rpc_open_wallet', { - path: path_wallet, password: this.wallet.password + path: path_wallet, + password: this.wallet.password }); this.$router.push({name: 'landing-page'}); diff --git a/src/renderer/main.js b/src/renderer/main.js index 16a5de4..b1f4ff0 100644 --- a/src/renderer/main.js +++ b/src/renderer/main.js @@ -36,6 +36,12 @@ let app = new Vue({ this.$store.commit('addWalletDir', data); }); + this.$electron.ipcRenderer.on('rpc_get_cfg', (event, data) => { + console.log('renderer get_cfg'); + console.log(data); + this.$store.commit('addCfg', data); + }); + this.$electron.ipcRenderer.on('rpc_wallet_created', (event, data) => { self.$store.commit('appState', null); diff --git a/src/renderer/router/index.js b/src/renderer/router/index.js index 04ec63d..fb618cc 100644 --- a/src/renderer/router/index.js +++ b/src/renderer/router/index.js @@ -39,9 +39,14 @@ export default new Router({ path: '/enter-password', name: 'enter-password', component: require('@/components/Landing/EnterPassword').default + }, + { + path: '/settings', + name: 'settings', + component: require('@/components/Landing/Settings').default } ], beforeEach: () => { console.log("changed"); } -}) +}); diff --git a/src/renderer/store/index.js b/src/renderer/store/index.js index c990805..41b17ac 100644 --- a/src/renderer/store/index.js +++ b/src/renderer/store/index.js @@ -1,6 +1,5 @@ import Vue from 'vue' import Vuex from 'vuex' - Vue.use(Vuex) @@ -9,6 +8,11 @@ export default new Vuex.Store({ height_from: 0, // height refreshes height_to: 0, wallet_dir: "", + cfg: { + "node": "", + "nodes": [], + "wallet_path": "" + }, created_wallet: {}, // only used when creating wallets appState: "", // not really used error: "", @@ -30,9 +34,14 @@ export default new Vuex.Store({ 'state': -1 }, // wallet opened wallet_path: '', - wallet_password: '' + wallet_password: '', + version_embedded: '', + version: require('electron').remote.app.getVersion() }, mutations: { + addEmbeddedVersion(state, data){ + state.version_embedded = data.version; + }, addCreatedWallet({ created_wallet }, data) { created_wallet.seed = data.seed; created_wallet.address = data.address; @@ -43,6 +52,24 @@ export default new Vuex.Store({ addWalletDir(state, data){ state.wallet_dir = data; }, + addCfg({cfg}, data){ + console.log('store addCfg'); + if (typeof data === 'string' || data instanceof String){ // fucku javascript + data = JSON.parse(data); + } + + if(data.hasOwnProperty('node')){ + cfg.node = data.node; + } + + if(data.hasOwnProperty('nodes')){ + cfg.nodes = data.nodes; + } + + if(data.hasOwnProperty('wallet_path')){ + cfg.wallet_path = data.wallet_path; + } + }, appState(state, data){ state.appState = data; }, @@ -109,6 +136,8 @@ export default new Vuex.Store({ message_box: state => state.message_box, password_box: state => state.password_box, height_from: state => state.height_from, - height_to: state => state.height_to + height_to: state => state.height_to, + version_embedded: state => state.version_embedded, + cfg: state => state.cfg } });