Consensys / eth-lightwallet

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

ERROR TypeError: crypto.createHash is not a function when calling keystore.generateRandomSeed #195

Open Muhammad-Altabba opened 6 years ago

Muhammad-Altabba commented 6 years ago

The flowing error is presented when calling keystore.generateRandomSeed

ERROR TypeError: crypto.createHash is not a function at Object.Hash.sha256 (hash.js:18) at Function.KeyStore._concatAndSha256 (keystore.js:265) at Function.KeyStore.generateRandomSeed (keystore.js:291) at RegistrationComponent.newWallet (registration.component.ts:118) at Object.eval [as handleEvent] (RegistrationComponent.html:13) at handleEvent (core.js:13547) at callWithDebugContext (core.js:15056) at Object.debugHandleEvent [as handleEvent] (core.js:14643) at dispatchEvent (core.js:9962) at eval (core.js:10587)

I am using Angular and before doing some JS libraries updates (Web3, EthLightWallet and many others), it was working.

I am not sure if this is related: Importing eth-lightwallet using (import { default as lightwallet } from 'eth-lightwallet';) no longer works. But the 'require' (declare let require: any; const lightwallet = require('eth-lightwallet');) works but introduced the mentioned error.

Current versions:

node -v

v8.11.1

truffle version

Truffle v4.1.5 (core: 4.1.5) Solidity v0.4.21 (solc-js)

npm version

{ 'angular-truffle-box': '0.0.0', npm: '5.8.0', ares: '1.10.1-DEV', cldr: '32.0', http_parser: '2.8.0', icu: '60.1', modules: '57', nghttp2: '1.25.0', node: '8.11.1', openssl: '1.0.2o', tz: '2017c', unicode: '10.0', uv: '1.19.1', v8: '6.2.414.50', zlib: '1.2.11' }

ng version

Angular CLI: 1.7.3 Node: 8.11.1 OS: linux x64 Angular: 5.2.9 ... animations, common, compiler, compiler-cli, core, forms ... http, platform-browser, platform-browser-dynamic ... platform-server, router

@'angular/cli: 1.7.3 @'angular/language-service: 4.4.6 @'angular-devkit/build-optimizer: 0.3.2 @'angular-devkit/core: 0.4.8 @'angular-devkit/schematics: 0.3.2 @'ngtools/json-schema: 1.2.0 @'ngtools/webpack: 1.10.2 @'schematics/angular: 0.3.2 @'schematics/package-update: 0.3.2 typescript: 2.4.2 webpack: 3.11.0

At package.json:

"@angular/animations": "^5.2.9",
"@angular/cdk": "^5.2.4",
"@angular/common": "^5.2.9",
"@angular/compiler": "^5.2.9",
"@angular/core": "^5.2.9",
"@angular/forms": "^5.2.9",
"@angular/http": "^5.2.9",
"@angular/material": "^5.2.4",
"@angular/platform-browser": "^5.2.9",
"@angular/platform-browser-dynamic": "^5.2.9",
"@angular/platform-server": "^5.2.9",
"@angular/router": "^5.2.9",
"core-js": "^2.5.5",
"eth-lightwallet": "^3.0.1",
"hammerjs": "^2.0.8",
"hooked-web3-provider": "^1.0.0",
"rxjs": "^5.5.10",
"web3": "^1.0.0-beta.34",
"zeppelin-solidity": "^1.8.0",
"zone.js": "^0.8.26"
cylof22 commented 6 years ago

I also see the same problem.

juliovera78 commented 5 years ago

same