2017-05-31 23:54:47 +00:00
|
|
|
import React, {Component} from 'react';
|
|
|
|
import translate from 'translations';
|
2017-06-08 02:30:25 +00:00
|
|
|
import wallet from 'ethereumjs-wallet';
|
|
|
|
import ethUtil from 'ethereumjs-util';
|
2017-05-31 23:54:47 +00:00
|
|
|
|
|
|
|
export default class KeystoreDecrypt extends Component {
|
2017-06-08 02:30:25 +00:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.handleFileSelection = this.handleFileSelection.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
handleFileSelection(event) {
|
|
|
|
const fileReader = new FileReader();
|
|
|
|
const inputFile = event.target.files[0];
|
|
|
|
|
|
|
|
fileReader.onload = () => {
|
|
|
|
try {
|
|
|
|
const keyStoreString = fileReader.result;
|
|
|
|
const decryptedWallet = wallet.fromV3(keyStoreString, 'asdfasdfasdf', true);
|
|
|
|
const privateHex = ethUtil.bufferToHex(decryptedWallet._privKey);
|
|
|
|
const publicHex = ethUtil.bufferToHex(ethUtil.privateToAddress(decryptedWallet._privKey));
|
|
|
|
} catch (e) {
|
|
|
|
console.error('Could not parse Keystore file.', e);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
fileReader.readAsText(inputFile, 'utf-8');
|
|
|
|
}
|
|
|
|
|
2017-05-31 23:54:47 +00:00
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<section className="col-md-4 col-sm-6">
|
|
|
|
<div id="selectedUploadKey">
|
|
|
|
<h4>{translate('ADD_Radio_2_alt')}</h4>
|
|
|
|
|
|
|
|
<div className="form-group">
|
2017-06-08 02:30:25 +00:00
|
|
|
<input type="file" id="fselector" onChange={this.handleFileSelection} />
|
|
|
|
<label htmlFor="fselector">
|
|
|
|
<a className="btn-file marg-v-sm" id="aria1" tabIndex="0" role="button">{translate('ADD_Radio_2_short')}</a>
|
|
|
|
</label>
|
2017-05-31 23:54:47 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|