Open DalderupMaurice opened 6 years ago
I believe there is some kind of problem in:
#FILE: lightwallet.js / Line: 250
KeyStore.prototype.init = function (mnemonic, pwDerivedKey, hdPathString, salt) {
...
if (!Mnemonic.isValid(mnemonic, Mnemonic.Words.ENGLISH) || words.length !== 12) {
throw new Error('KeyStore: Invalid mnemonic');
}
So, I checked and problem probably is on library
var Mnemonic = require('bitcore-mnemonic');
I have my own 12-word seed and it fails anytime. And I used this below, and Validation was OK.
select scout crash enforce riot rival spring whale hollow radar rule sentence
I still try to find where problem is ;/
OK, I can confirm that problem is with "12 word seed" , or I'm doing something wrong with the words.
This seed work:
select scout crash enforce riot rival spring whale hollow radar rule sentence
this not:
select scout crash road riot rival spring whale hollow radar rule sentence
I changed enforce => road, and I got error about wrong mnemonic.
@pdanysz Not every 12 words is a valid mnemonic, the mnemonic contains a checksum, so if you just change one word it will not be a valid mnemonic.
@christianlundkvist yes, correct, thank you!
Well, my problem persists. Whenever an invalid password is matched with the given mnemonic, I am unable to catch the error. That was the essence of this topic, not the generation of a mnemonic :)
Hi @DalderupMaurice , this is due to the fact that init function throws error if invalid mnemonic appears. But that error is not caught by it's calling function viz. createVault
function. I have created a pull request for this (https://github.com/ConsenSys/eth-lightwallet/pull/193).
For now, you can import "bitcore-mnemonic" library and prior to calling createVault
, you can check if your mnemonic is correct using isValid
function of this library.
Thanks man, really appreciate the effort :D
@christianlundkvist can you explain this:
Not every 12 words is a valid mnemonic, the mnemonic contains a checksum, so if you just change one word it will not be a valid mnemonic.
So I cannot use any 12 words, is there a schema to follow? Are only certain words allowed, is there a good resource for this?
E.g. can I use any combination of those: https://gist.github.com/fogleman/c4a1f69f34c7e8a00da8 https://github.com/sindresorhus/mnemonic-words
I'm not getting this explanation: https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki
EDIT: this library makes it easier:
https://github.com/ggozad/mnemonic.js/tree/master
But I still get invalid mnemonic with the generated seed phrase:
cousin,gun,muscle,radio,total,rhythm,written,built,compare,rip,child,knowledge
@360disrupt Not any 12 random words make a correct mnemonic (not at least for Ethereum and Bitcoin chains). You can view the wordlist here. Again, you cannot arrange these words randomly yourself to make a valid mnemonic. This has steps to create one. You can visit https://iancoleman.io/bip39/ to generate mnemonic for yourself. Or include this in your codebase to create wallets. Here you can see that eth-lightwallet uses it as well ;)
Upgrading from eth-lightwallet 2.5.4 to 3.0.x I am having the issue that I am unable to catch the error whenever a wrong mnemonic is passed to lightwallet.keystore.createVault.
Example:
In this example, whenever the password is wrong, the callback does not retrieve an error keystore. It just displays an uncaught error in the console of the browser. I also tried placing a try - catch around it, but it still does not work.
This is the error shown in the browser: