Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for metamask wallet import #4

Merged
merged 1 commit into from Oct 3, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

add support for metamask wallet import

  • Loading branch information
diracdeltas committed Sep 2, 2019
commit 2343bba0d599f0e83e0c3b84e542c6d981bb4a0e
@@ -4,6 +4,7 @@ const hdkey = require('ethereumjs-wallet/hdkey')
const ethUtil = require('ethereumjs-util')
const sigUtil = require('eth-sig-util')
const braveCrypto = require('brave-crypto')
const bip39 = require('bip39')

// Options:
const hdPathString = `m/44'/60'/0'/0`
@@ -170,7 +171,14 @@ class HdKeyring extends EventEmitter {

_initFromMnemonic (mnemonic) {
this.mnemonic = mnemonic
const seed = braveCrypto.passphrase.toBytes32(mnemonic)
let seed
try {
seed = braveCrypto.passphrase.toBytes32(mnemonic)
} catch (e) {
// Support metamask word restoration
console.warn('Could not get seed using brave-crypto.')
seed = bip39.mnemonicToSeed(mnemonic)
}
this.hdWallet = hdkey.fromMasterSeed(seed)
this.root = this.hdWallet.derivePath(this.hdPath)
}

Some generated files are not rendered by default. Learn more.

@@ -21,6 +21,7 @@
},
"homepage": "https://github.com/MetaMask/eth-hd-keyring#readme",
"dependencies": {
"bip39": "^3.0.2",
"brave-crypto": "^0.2.1",
"eth-sig-util": "^2.2.0",
"ethereumjs-util": "^6.1.0",
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.