Make build lighter

This commit is contained in:
Boris Kubiak 2018-03-25 19:18:46 +02:00
parent a2e73942cc
commit e1eb740672
2 changed files with 5 additions and 11 deletions

View file

@ -41,7 +41,7 @@
</div>
<!--Save modal-->
<save :private-key="result.privateKey"></save>
<save :address="result.address.toLowerCase()" :private-key="result.privateKey"></save>
<!--Footer-->
<foot></foot>

View file

@ -23,12 +23,11 @@
import {v4} from 'uuid';
import CryptoJS from 'crypto-js';
import secp256k1 from 'secp256k1';
import keccak from 'keccak';
export default {
props: {
privateKey: String
privateKey: String,
address: String
},
data: function () {
return {
@ -48,7 +47,7 @@
setTimeout(() => {
const wallet = this.generateWallet(this.privateKey, this.password);
const fileName = 'UTC--' + new Date().toISOString().replace(/:/g, '-') + '--' + wallet.address;
const fileName = 'UTC--' + new Date().toISOString().replace(/:/g, '-') + '--' + this.address;
download(JSON.stringify(wallet), fileName, "application/json");
this.loading = false;
}, 20);
@ -59,18 +58,13 @@
generateWallet(privateKey, password) {
privateKey = Buffer.from(privateKey, 'hex');
return {
address: this.privateToAddress(privateKey),
address: this.address,
crypto: this.encryptPrivateKey(privateKey, password),
id: v4(),
version: 3
};
},
privateToAddress(privateKey) {
const pub = secp256k1.publicKeyCreate(privateKey, false).slice(1);
return keccak('keccak256').update(pub).digest().slice(-20).toString('hex');
},
sliceWordArray(wordArray, start, end) {
const newArray = wordArray.clone();
newArray.words = newArray.words.slice(start, end);