bitpay / bitcore-mnemonic

BIP39 Mnemonics implemented for Bitcore

Home Page:http://bitcore.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't instantiate Mnemonic in a web worker

Giszmo opened this issue · comments

Mnemonic.prototype.toHDPrivateKey() takes 20s on my Anroid and thus I'd like to create it "in the background".

Putting it in a new Worker() yields Uncaught Error: Uncaught ReferenceError: window is not defined. Apparently this stems from bitcore:

if ((inBrowser && window._bitcore) || (!inBrowser && global._bitcore)) {.

I browserified Mnemonic and try to include it like this:

importScripts(e.data.url + '/lib/bundle2.browser.js') // in this line above error is thrown

(I would prefer to have bitcore to offer a promise-based way to do expensive stuff like this ;) )

Please take a look at this: bitpay/bitcore#1168

Hope it solves the problem. Report if it doesn't

I wonder if there is a way that browserify or other can build for use in a web worker.

Thank you very much @maraoz ! Your link worked :)

I still wonder if it would not be possible to depend less on those environment things in this crypto library.

This should be fixed with: bitpay/bitcore#1322