Consensys / eth-lightwallet

Lightweight JS Wallet for Node and the browser
MIT License
1.47k stars 501 forks source link

Broken in electron #42

Closed tymat closed 8 years ago

tymat commented 8 years ago

Uncaught Exception: Error: Module version mismatch. Expected 46, got 14. at Error (native) at Object.module.(anonymous function) (ATOM_SHELL_ASAR.js:137:20) at Object.module.(anonymous function) as .node at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Module.require (module.js:365:17) at require (module.js:384:17) at Object. (/Users/aeufemio/projects/digixglobal/apps/wallet/app/node_modules/eth-lightwallet/node_modules/ethereumjs-tx/node_modules/ethereumjs-util/index.js:1:93) at Module._compile (module.js:434:26) at Object.Module._extensions..js (module.js:452:10)

coder5876 commented 8 years ago

Hi @tymat, I haven't used electron so I don't know what the specific issue could be. I was going to do some updates with updated dependencies though so that might issues that might be related. Also we had to do a force push today so you might want to make sure you are synced up with the current version.

tymat commented 8 years ago

@christianlundkvist
I noticed that eth-lightwallet has some native OS dependencies when installing. npm-install calls on node-gyp:

> secp256k1@1.1.6 install /Users/aeufemio/node_modules/eth-lightwallet/node_modules/ethereumjs-tx/node_modules/secp256k1
> node-gyp rebuild

  CXX(target) Release/obj.target/secp256k1/functions.o
../functions.cc:231:57: warning: variable 'pub_key' is uninitialized when used here [-Wuninitialized]
  int results = secp256k1_ec_pubkey_parse(secp256k1ctx, pub_key, pk_data, pub_len);
                                                        ^~~~~~~
../functions.cc:230:28: note: initialize the variable 'pub_key' to silence this warning
  secp256k1_pubkey *pub_key;
                           ^
                            = NULL
../functions.cc:255:56: warning: variable 'pub_key' is uninitialized when used here [-Wuninitialized]
  int results= secp256k1_ec_pubkey_parse(secp256k1ctx, pub_key, pk_data, pub_len);
                                                       ^~~~~~~
../functions.cc:254:28: note: initialize the variable 'pub_key' to silence this warning
  secp256k1_pubkey *pub_key;
                           ^
                            = NULL
2 warnings generated.
  CXX(target) Release/obj.target/secp256k1/util.o
  CXX(target) Release/obj.target/secp256k1/secp256k1.o
  CC(target) Release/obj.target/secp256k1/secp256k1-src/src/secp256k1.o
In file included from ../secp256k1-src/src/secp256k1.c:13:
In file included from ../secp256k1-src/src/field_impl.h:19:
../secp256k1-src/src/field_5x52_impl.h:54:13: warning: unused function 'secp256k1_fe_verify' [-Wunused-function]
static void secp256k1_fe_verify(const secp256k1_fe *a) {
            ^
In file included from ../secp256k1-src/src/secp256k1.c:15:
../secp256k1-src/src/group_impl.h:214:12: warning: unused function 'secp256k1_gej_is_valid_var' [-Wunused-function]
static int secp256k1_gej_is_valid_var(const secp256k1_gej *a) {
           ^
In file included from ../secp256k1-src/src/secp256k1.c:17:
../secp256k1-src/src/ecmult_const_impl.h:125:13: warning: unused function 'secp256k1_ecmult_const' [-Wunused-function]
static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, const secp256k1_scalar *scalar) {
            ^
3 warnings generated.
  SOLINK_MODULE(target) Release/secp256k1.node

> sha3@1.2.0 install /Users/aeufemio/node_modules/eth-lightwallet/node_modules/ethereumjs-tx/node_modules/ethereumjs-util/node_modules/sha3
> node-gyp rebuild

That seems to be the issue with electron.

d11e9 commented 8 years ago

@tymat you could just use the prebuilt dist for lightwallet. https://github.com/ConsenSys/eth-lightwallet/blob/master/dist/lightwallet.min.js

coder5876 commented 8 years ago

@tymat Ah, interesting. Yes other people had issues with the secp256k1 package when building on Windows, so that's come up before. I might look into getting a version of that functionality that doesn't require precompilation.

aakilfernandes commented 8 years ago

Whenever I have libraries that work outside electron, but then break inside electron, it tends to be a result of the fact that electron includes a global module object by default. Lots of packages use the existence of module to indicate they are in a node environment (rather than a browser environment).

Try turning off node-integration which removes the global module object

var mainWindow = new BrowserWindow({width: 800, height: 600, "node-integration": false});
tymat commented 8 years ago

Rebuilding electron seems to fix this:

https://github.com/atom/electron/blob/master/docs/tutorial/using-native-node-modules.md