Handle EthereumWallet's private key as a Buffer.
commita529165ac8550667eb895f7efed6fa5806200190
authorJared Tobin <jared@jtobin.io>
dateMon 21 Jan 2019, 14:08 (8 years ago)
parenta54b5ac
src/lib/wallet.js+2−3
@@ -20,9 +20,8 @@ const WALLET_NAMES = {
2020}
2121
2222function EthereumWallet(privateKey) {
23− const sec = Buffer.from(privateKey, 'hex')
24− this.privateKey = sec
25− this.publicKey = secp256k1.publicKeyCreate(sec)
23+ this.privateKey = privateKey
24+ this.publicKey = secp256k1.publicKeyCreate(this.privateKey)
2625 const pub = this.publicKey.toString('hex')
2726 this.address = addressFromSecp256k1Public(pub)
2827}
src/views/PrivateKey.js+2−1
@@ -29,7 +29,8 @@ class PrivateKey extends React.Component {
2929 constructWallet(privateKey) {
3030 const { setWallet } = this.props
3131 if (secre.test(privateKey) === true) {
32− const wallet = new EthereumWallet(privateKey)
32+ const sec = Buffer.from(privateKey, 'hex')
33+ const wallet = new EthereumWallet(sec)
3334 setWallet(Maybe.Just(wallet))
3435 } else {
3536 setWallet(Maybe.Nothing())