Skip to content

Commit

Permalink
Merge c5979a3 into 731ed38
Browse files Browse the repository at this point in the history
  • Loading branch information
pbca26 authored May 11, 2022
2 parents 731ed38 + c5979a3 commit fe3287e
Show file tree
Hide file tree
Showing 134 changed files with 26,561 additions and 4,098 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '12'
node-version: '14'
check-latest: true

- name: Build GUI HW Wallet
Expand Down Expand Up @@ -119,6 +119,7 @@ jobs:
- name: Build Electron App
run: |
sudo apt update
sudo apt-get install libusb-1.0-0-dev
sudo apt install libudev-dev
cd electron
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '12'
node-version: '14'
check-latest: true

- name: Install deps
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
.env.test.local
.env.production.local

package-lock.json
npm-debug.log*
yarn-debug.log*
yarn-error.log*
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
MIT License

Copyright (c) 2018 - 2019 Atomic Labs, Luke Childs
Copyright (c) 2019 - 2020 Komodo Platform
Copyright (c) 2019 - 2022 Komodo Platform

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -19,4 +19,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ If you're experiencing issues connecting your Ledger device open the following u
## Build/compile issues
If you are experiencing build issues that lead to minify errors add required modules to [config-overrides.js](https://github.com/pbca26/hw-kmd-wallet/blob/master/config-overrides.js#L19) file.

## Running tests on MacOS
If you're running into the following error `Error: EMFILE: too many open files, watch` install watchman
```
brew install watchman
```

## License

MIT © Atomic Labs<br />
Expand Down
52 changes: 18 additions & 34 deletions config-overrides.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,23 @@
const hotLoader = require('react-app-rewire-hot-loader');
const rewireSass = require('react-app-rewire-scss');
const webpack = require('webpack');
const {paths} = require('react-app-rewired');
const path = require('path');

module.exports = {
webpack: function (config, env) {
// workaround for es6 node_modules minify errors
config.module.rules[1].oneOf[1].include = [
paths.appSrc,
path.resolve(paths.appNodeModules, 'bitcoinjs-lib'),
path.resolve(paths.appNodeModules, 'ow'),
path.resolve(paths.appNodeModules, 'create-xpub'),
path.resolve(paths.appNodeModules, 'build-output-script'),
path.resolve(paths.appNodeModules, 'get-komodo-rewards'),
path.resolve(paths.appNodeModules, 'tiny-secp256k1'),
path.resolve(paths.appNodeModules, 'bip32'),
path.resolve(paths.appNodeModules, 'typeforce'),
path.resolve(paths.appNodeModules, 'semver'),
path.resolve(paths.appNodeModules, 'lru-cache'),
path.resolve(paths.appNodeModules, 'yallist'),
path.resolve(paths.appNodeModules, 'u2f-api'),
path.resolve(paths.appNodeModules, 'asn1.js'),
path.resolve(paths.appNodeModules, 'bech32'),
path.resolve(paths.appNodeModules, 'webrtc-adapter'),
path.resolve(paths.appNodeModules, '@trezor/utxo-lib'),
path.resolve(paths.appNodeModules, '@ledgerhq/hw-app-btc'),
path.resolve(paths.appNodeModules, '@ledgerhq/hw-transport/lib-es'),
path.resolve(paths.appNodeModules, '@ledgerhq/hw-transport-webusb/lib-es'),
path.resolve(paths.appNodeModules, '@ledgerhq/hw-transport-u2f/lib-es'),
path.resolve(paths.appNodeModules, '@ledgerhq/hw-transport-webhid/lib-es'),
];
module.exports = function override(config) {
config.ignoreWarnings = [/Failed to parse source map/];

const fallback = config.resolve.fallback || {};
Object.assign(fallback, {
'crypto': require.resolve('crypto-browserify'),
'buffer': require.resolve('buffer'),
'stream': require.resolve('stream-browserify'),
})
config.resolve.fallback = fallback;
config.plugins = (config.plugins || []).concat([
new webpack.ProvidePlugin({
process: 'process/browser',
Buffer: ['buffer', 'Buffer']
})
]);

config = hotLoader(config, env);
config = rewireSass(config, env);

return config;
}
return config;
}
50 changes: 50 additions & 0 deletions electron/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

const {createAdapter} = require('iocane');
let pw;

const decodeStoredData = (str/*, pw*/) => {
return new Promise((resolve, reject) => {
if (str.length) {
createAdapter()
.decrypt(str, pw)
.catch((err) => {
console.log('decodeStoredData error', err);
resolve(false);
})
.then(decryptedString => {
//console.log('decryptedString', decryptedString);
resolve(decryptedString);
});
} else {
resolve(false);
}
});
};

const encodeStoredData = (str/*, pw*/) => {
return new Promise((resolve, reject) => {
createAdapter()
.encrypt(str, pw)
.catch((err) => {
console.log('encodeStoredData error', err);
resolve(false);
})
.then(encryptedString => {
resolve(encryptedString);
});
});
};

const getPW = () => {
return pw;
};
const setPW = (_pw) => {
pw = _pw;
};

module.exports = {
decodeStoredData,
encodeStoredData,
getPW,
setPW,
};
37 changes: 0 additions & 37 deletions electron/index.html

This file was deleted.

17 changes: 4 additions & 13 deletions electron/ipc-ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const setMainWindow = (_mainWindow) => {
function getAddress(derivationPath, verify) {
return TransportNodeHid.open('')
.then(transport => {
transport.setDebugMode(true);
const appBtc = new AppBtc(transport);
return appBtc.getWalletPublicKey(derivationPath, verify).then(r =>
transport
Expand All @@ -33,31 +32,24 @@ function createPaymentTransactionNew(txData) {
inputs,
associatedKeysets,
changePath,
outputScript,
outputScriptHex,
lockTime,
sigHashType,
segwit,
initialTimestamp,
additionals,
expiryHeight,
} = txData;

return TransportNodeHid.open('')
.then(transport => {
transport.setDebugMode(true);
const appBtc = new AppBtc(transport);
return appBtc.createPaymentTransactionNew(
return appBtc.createPaymentTransactionNew({
inputs,
associatedKeysets,
changePath,
outputScript,
outputScriptHex,
lockTime,
sigHashType,
segwit,
initialTimestamp,
additionals,
expiryHeight,
).then(r =>
}).then(r =>
transport
.close()
.catch(e => {})
Expand All @@ -81,7 +73,6 @@ function splitTransaction(txData) {

return TransportNodeHid.open('')
.then(transport => {
transport.setDebugMode(true);
const appBtc = new AppBtc(transport);
const txSplit = appBtc.splitTransaction(
transactionHex,
Expand Down
67 changes: 9 additions & 58 deletions electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ const url = require('url');
const ipcLedger = require('./ipc-ledger');
const ipcSPV = require('./spv');
const ipcNSPV = require('./nspv');
const {
decodeStoredData,
encodeStoredData,
getPW,
setPW,
} = require('./auth');
const menuTemplates = require('./menuTemplates');
const isDev = process.argv.indexOf('devmode') > -1;
const {createAdapter} = require('iocane');

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
let pw;

function createWindow() {
// Create the browser window.
Expand All @@ -42,62 +47,8 @@ function createWindow() {

require(path.join(__dirname, 'menu'));

const staticMenu = Menu.buildFromTemplate([ // if static
{ role: 'copy' },
{ type: 'separator' },
{ role: 'selectall' },
]);

const editMenu = Menu.buildFromTemplate([ // if editable
{ role: 'undo' },
{ role: 'redo' },
{ type: 'separator' },
{ role: 'cut' },
{ role: 'copy' },
{ role: 'paste' },
{ type: 'separator' },
{ role: 'selectall' },
]);

const decodeStoredData = (str/*, pw*/) => {
return new Promise((resolve, reject) => {
if (str.length) {
createAdapter()
.decrypt(str, pw)
.catch((err) => {
console.log('decodeStoredData error', err);
resolve(false);
})
.then(decryptedString => {
//console.log('decryptedString', decryptedString);
resolve(decryptedString);
});
} else {
resolve(false);
}
});
};

const encodeStoredData = (str/*, pw*/) => {
return new Promise((resolve, reject) => {
createAdapter()
.encrypt(str, pw)
.catch((err) => {
console.log('encodeStoredData error', err);
resolve(false);
})
.then(encryptedString => {
resolve(encryptedString);
});
});
};

const getPW = () => {
return pw;
};
const setPW = (_pw) => {
pw = _pw;
};
const staticMenu = Menu.buildFromTemplate(menuTemplates.static);
const editMenu = Menu.buildFromTemplate(menuTemplates.edit);

global.app = {
isDev,
Expand Down
21 changes: 21 additions & 0 deletions electron/menuTemplates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const static = [ // if static
{ role: 'copy' },
{ type: 'separator' },
{ role: 'selectall' },
];

const edit = [ // if editable
{ role: 'undo' },
{ role: 'redo' },
{ type: 'separator' },
{ role: 'cut' },
{ role: 'copy' },
{ role: 'paste' },
{ type: 'separator' },
{ role: 'selectall' },
];

module.exports = {
static,
edit,
};
Loading

0 comments on commit fe3287e

Please sign in to comment.