Skip to content
This repository has been archived by the owner on Jun 29, 2020. It is now read-only.

Commit

Permalink
Merge pull request #8 from skftn/0.1.1
Browse files Browse the repository at this point in the history
0.1.1
  • Loading branch information
sanderfoobar authored Nov 14, 2018
2 parents 129e335 + 94e1db3 commit 93f537a
Show file tree
Hide file tree
Showing 25 changed files with 588 additions and 211 deletions.
40 changes: 40 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -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 <latest version here>
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
```
10 changes: 10 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
68 changes: 8 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wowlight",
"version": "0.1.0",
"version": "0.1.1",
"author": "dsc <xmrdsc@protonmail.com>",
"description": "Wownero Light Wallet",
"license": "WTFPL",
Expand Down
6 changes: 5 additions & 1 deletion src/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
<script>
require('module').globalPaths.push('<%= htmlWebpackPlugin.options.nodeModules.replace(/\\/g, '\\\\') %>')
</script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" crossorigin="anonymous">
<% } %>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.5/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>

</head>
<body>
<div ref="app" id="app"></div>
Expand Down
75 changes: 75 additions & 0 deletions src/main/config.js
Original file line number Diff line number Diff line change
@@ -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();
}
}
48 changes: 34 additions & 14 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down Expand Up @@ -99,6 +103,8 @@ function createWindow() {
const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
}

wallet.getEmbeddedVersion();
}

app.on('ready', createWindow)
Expand All @@ -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){
Expand Down Expand Up @@ -178,6 +196,7 @@ function resetWallet(){
}

wallet = new wowrpc.WowRpc(wowdir);
wallet._cli_daemon_address = cfg.data.node;
}

ipcMain.on('rpc_close_wallet', (event) => {
Expand All @@ -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);
}

Expand Down
27 changes: 21 additions & 6 deletions src/main/wowrpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
}
Expand Down
Loading

0 comments on commit 93f537a

Please sign in to comment.