Browse Source

settings wifkeys export

all-modes
pbca26 8 years ago
parent
commit
9422befb51
  1. 33
      react/src/actions/actionCreators.js
  2. 30
      react/src/components/dashboard/settings.js

33
react/src/actions/actionCreators.js

@ -429,11 +429,16 @@ export function atomic(payload) {
}
}
export function test(json) {
export function settingsWifkeyState(json, coin) {
return {
type: GET_WIF_KEY,
wifkey: json[coin + 'wif'],
address: json[coin],
}
console.log('test', json);
}
export function encryptWallet(_passphrase, cb) {
export function encryptWallet(_passphrase, cb, coin) {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'bitcoinrpc',
@ -450,8 +455,30 @@ export function encryptWallet(_passphrase, cb) {
console.log(error);
dispatch(triggerToaster(true, 'encryptWallet', 'Error', 'error'))
})
.then(dispatch(walletPassphrase(_passphrase)))
.then(response => response.json())
.then(json => dispatch(cb.call(this, json)));
.then(json => dispatch(cb.call(this, json, coin)));
}
}
export function walletPassphrase(_passphrase) {
const payload = {
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
'agent': 'bitcoinrpc',
'method': 'walletpassphrase',
'password': _passphrase,
'timeout': '2592000'
};
return dispatch => {
return fetch('http://127.0.0.1:7778', {
method: 'POST',
body: JSON.stringify(payload),
})
.catch(function(error) {
console.log(error);
dispatch(triggerToaster(true, 'walletPassphrase', 'Error', 'error'))
})
}
}

30
react/src/components/dashboard/settings.js

@ -1,6 +1,6 @@
import React from 'react';
import { translate } from '../../translate/translate';
import { iguanaActiveHandle, encryptWallet, test } from '../../actions/actionCreators';
import { iguanaActiveHandle, encryptWallet, settingsWifkeyState } from '../../actions/actionCreators';
import Store from '../../store';
import AddCoinOptionsCrypto from '../addcoin/addcoinOptionsCrypto';
import AddCoinOptionsAC from '../addcoin/addcoinOptionsAC';
@ -13,6 +13,7 @@ class Settings extends React.Component {
activeTab: 0,
};
this.exportWifKeys = this.exportWifKeys.bind(this);
this.updatePassphraseInput = this.updatePassphraseInput.bind(this);
}
componentDidMount() {
@ -26,7 +27,13 @@ class Settings extends React.Component {
}
exportWifKeys() {
Store.dispatch(encryptWallet('lime lime', test));
Store.dispatch(encryptWallet(this.state.wifkeysPassphrase, settingsWifkeyState, this.props.ActiveCoin.coin));
}
updatePassphraseInput(e) {
this.setState({
[e.target.name]: e.target.value,
});
}
render() {
@ -200,7 +207,7 @@ class Settings extends React.Component {
<div className="col-sm-12"></div>
<form className="wifkeys-form" method="post" action="javascript:" autoComplete="off">
<div className="form-group form-material floating">
<input type="password" className="form-control" name="wifkeys_passphrase" id="wifkeys_passphrase" />
<input type="password" className="form-control" name="wifkeysPassphrase" id="wifkeys_passphrase" onChange={this.updatePassphraseInput} />
<label className="floating-label" htmlFor="wifkeys_passphrase">{translate('INDEX.PASSPHRASE')}</label>
</div>
<div className="col-sm-12 col-xs-12" style={{textAlign: 'center'}}>
@ -210,7 +217,20 @@ class Settings extends React.Component {
<div className="col-sm-12" style={{paddingTop: '15px'}}>
<div className="row" id="wif-priv-keys" data-plugin="masonry">
<table class="table">
<tr>
<td style={{width: '5%'}}>
<b>{this.props.ActiveCoin.coin}</b>
</td>
<td>{this.props.Settings.address}</td>
</tr>
<tr>
<td>
<b>{this.props.ActiveCoin.coin}Wif</b>
</td>
<td>{this.props.Settings.wifkey}</td>
</tr>
</table>
</div>
</div>
</div>
@ -240,7 +260,7 @@ class Settings extends React.Component {
<label className="floating-label" htmlFor="import_wifkey">{translate('INDEX.INPUT_PRIV_KEY')}</label>
</div>
<div className="col-sm-12 col-xs-12" style={{textAlign: 'center'}}>
<button type="submit" className="btn btn-primary waves-effect waves-light" data-toggle="modal" data-dismiss="modal" id="import_wifkey_btn">{translate('INDEX.IMPORT_PRIV_KEY')}</button>
<button type="button" className="btn btn-primary waves-effect waves-light" data-toggle="modal" data-dismiss="modal" id="import_wifkey_btn">{translate('INDEX.IMPORT_PRIV_KEY')}</button>
</div>
</form>
<div className="col-sm-12" style={{paddingTop: '15px'}}>

Loading…
Cancel
Save