diff --git a/react/src/actions/actionCreators.js b/react/src/actions/actionCreators.js index 016d276..b9612e2 100644 --- a/react/src/actions/actionCreators.js +++ b/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')) + }) } } diff --git a/react/src/components/dashboard/settings.js b/react/src/components/dashboard/settings.js index ad56da3..e5aa5ae 100644 --- a/react/src/components/dashboard/settings.js +++ b/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 {
- +
@@ -210,7 +217,20 @@ class Settings extends React.Component {
- + + + + + + + + + +
+ {this.props.ActiveCoin.coin} + {this.props.Settings.address}
+ {this.props.ActiveCoin.coin}Wif + {this.props.Settings.wifkey}
@@ -240,7 +260,7 @@ class Settings extends React.Component {
- +