encrypt wallet with Mnemonic Spanish language
See original GitHub issueHi, I’m trying to encrypt a wallet created with Mnemonic in Spanish and I get some errors. The strange thing is that if I do it in English works perfect. First I have tried the following code:
import { ethers } from 'ethers';
import { es } from 'ethers/wordlists';
private async all(){
const randomBytes = ethers.utils.randomBytes(24);
const mnemonic = ethers.utils.HDNode.entropyToMnemonic(randomBytes, es);
const wallet = ethers.Wallet.fromMnemonic(mnemonic, null, es);
const json = await wallet.encrypt("123");
return json;
}
And I get the following error:
ERROR Error: Uncaught (in promise): Error: entropy and mnemonic mismatch
Error: entropy and mnemonic mismatch
at Object.r.encrypt (ethers.min.js:1)
at _.encrypt (ethers.min.js:1)
at WalletService.<anonymous> (wallet.service.ts:81)
at Generator.next (<anonymous>)
at tslib.es6.js:73
at new ZoneAwarePromise (zone-evergreen.js:876)
at Module.__awaiter (tslib.es6.js:69)
at WalletService.all (wallet.service.ts:76)
at WalletService.<anonymous> (wallet.service.ts:46)
at Generator.next (<anonymous>)
at resolvePromise (zone-evergreen.js:797)
at zone-evergreen.js:707
at rejected (tslib.es6.js:71)
at ZoneDelegate.invoke (zone-evergreen.js:359)
at Object.onInvoke (core.js:39699)
at ZoneDelegate.invoke (zone-evergreen.js:358)
at Zone.run (zone-evergreen.js:124)
at zone-evergreen.js:855
at ZoneDelegate.invokeTask (zone-evergreen.js:391)
at Object.onInvokeTask (core.js:39680)
The second code I have tried is:
private async all(){
const randomBytes = ethers.utils.randomBytes(24);
const mnemonic = ethers.utils.HDNode.entropyToMnemonic(randomBytes, es);
const entropy = ethers.utils.HDNode.mnemonicToEntropy(mnemonic, es);
const wallet = ethers.Wallet.fromMnemonic(mnemonic, null, es);
const json = await wallet.encrypt("123", {entropy: entropy});
return json;
}
and I get the following error:
ERROR Error: Uncaught (in promise): Error: entropy and mnemonic mismatch
Error: entropy and mnemonic mismatch
at Object.r.encrypt (ethers.min.js:1)
at _.encrypt (ethers.min.js:1)
at WalletService.<anonymous> (wallet.service.ts:81)
at Generator.next (<anonymous>)
at tslib.es6.js:73
at new ZoneAwarePromise (zone-evergreen.js:876)
at Module.__awaiter (tslib.es6.js:69)
at WalletService.all (wallet.service.ts:76)
at WalletService.<anonymous> (wallet.service.ts:46)
at Generator.next (<anonymous>)
at resolvePromise (zone-evergreen.js:797)
at zone-evergreen.js:707
at rejected (tslib.es6.js:71)
at ZoneDelegate.invoke (zone-evergreen.js:359)
at Object.onInvoke (core.js:39699)
at ZoneDelegate.invoke (zone-evergreen.js:358)
at Zone.run (zone-evergreen.js:124)
at zone-evergreen.js:855
at ZoneDelegate.invokeTask (zone-evergreen.js:391)
at Object.onInvokeTask (core.js:39680)
What I’m doing wrong??? Thanks in advance 😃
Issue Analytics
- State:
- Created 4 years ago
- Comments:17 (9 by maintainers)
Top Results From Across the Web
How to store private keys and mnemonic seed - Atomic Wallet
Do you know how to protect you private keys? Check this article and learn how to safely store the seed phrase and private...
Read more >The Journey from Secret Recovery Phrase (Mnemonic Phrase ...
Secret recovery phrases (or mnemonic phrases) may seem very simple at ... wordlists in different languages (e.g. English, Chinese, Spanish).
Read more >How the Pitfalls of Mnemonic Phrases Are Solved ... - LinkedIn
The advice here is to really avoid wallets with low quality key generation processes. The ECB encryption mode is used for the key...
Read more >BIP39 - Mnemonic Code - iancoleman.io
More info · BIP39 Mnemonic code for generating deterministic keys · BIP32 Hierarchical Deterministic Wallets · BIP44 Multi-Account Hierarchy for Deterministic ...
Read more >Can't import seed: seed phrase in Spanish (12 Spanish words)
Today, I cannot import that seed into the wallet, same app: it returns error "invalid mnemonic". I have tried: Importing in Electron Cash: ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve confirmed this is an issue in v4 and v5. I am trying to figure out a backwards-compatible fix that is safe.
Since v5 is not officially released yet, backwards compatibility isn’t as important, so I may fix it there first to try out a few ideas.
I’ll keep this ticket updated and sorry for the inconvenience.
I have no idea what that error means. Maybe there is more info in the react documentation?
Also, where are you getting the
es
from? If you are using the dist files, make sure you are using the-all
variant which includes all languages. The normal dist file only includes English. Similar things may happen if you use the browser mainField in rollup. Do a console.log on the 'es` object to make sure it is a Wordlist object…Let me know. 😃