diff --git a/react/src/actions/actionCreators.js b/react/src/actions/actionCreators.js index 1b3529c..7f99a85 100644 --- a/react/src/actions/actionCreators.js +++ b/react/src/actions/actionCreators.js @@ -978,7 +978,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { 'account': '*' }; } - console.log('pl', payload); + //console.log('pl', payload); if (sessionStorage.getItem('useCache') && mode === 'basilisk') { const pubkey = JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey; @@ -1063,7 +1063,7 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { } function calcBalance(result, json, dispatch, mode) { - console.log('result', result); + //console.log('result', result); if (mode === 'full' || mode === 'basilisk') { result[0] = result[0].result; } else { @@ -1071,8 +1071,8 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { result[1] = result[1].result; } - console.log('calc result', result); - console.log('calc json', json); + //console.log('calc result', result); + //console.log('calc json', json); if (mode !== 'basilisk') { const allAddrArray = json.map(res => res.address).filter((x, i, a) => a.indexOf(x) == i); @@ -1112,8 +1112,8 @@ export function getKMDAddressesNative(coin, mode, currentAddress) { } else { filteredArray = json.filter(res => res.address === result[a][b]).map(res => res.amount); } - console.log('filteredArray', filteredArray); - console.log('addr', result[a][b]); + //console.log('filteredArray', filteredArray); + //console.log('addr', result[a][b]); let sum = 0; @@ -1752,6 +1752,34 @@ export function sendToAddress(coin, _payload) { } } +export function sendFromAddress(coin, _payload) { + const payload = { + 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'coin': coin, + 'method': 'sendfrom', + 'params': [ + _payload.sendFrom, + _payload.sendTo, + _payload.amount, + 'EasyDEX', + 'EasyDEXTransaction' + ] + }; + + return dispatch => { + return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + method: 'POST', + body: JSON.stringify(payload), + }) + .catch(function(error) { + console.log(error); + dispatch(triggerToaster(true, 'sendFromAddress', 'Error', 'error')); + }) + .then(response => response.json()) + .then(json => dispatch(sendToAddressState(json, dispatch))) + } +} + function checkAddressBasiliskHandle(json) { if (json && json.error) { return dispatch => { @@ -2116,6 +2144,38 @@ export function connectNotaries() { } } +export function iguanaUTXORawTX(data) { + const payload = { + 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), + 'symbol': data.coin, + 'agent': 'basilisk', + 'method': 'utxorawtx', + 'vals': { + 'timelock': 0, + 'changeaddr': data.sendfrom, + 'destaddr': data.sendtoaddr, + 'txfee': data.txfee, + 'amount': data.amount, + 'sendflag': data.sendsig + }, + 'utxos': data.utxos + }; + console.log('iguanaUTXORawTXExport', payload); + + return new Promise((resolve, reject) => { + fetch('http://127.0.0.1:' + Config.iguanaCorePort, { + method: 'POST', + body: JSON.stringify(payload), + }) + .catch(function(error) { + console.log(error); + dispatch(triggerToaster(true, 'iguanaUTXORawTX', 'Error', 'error')); + }) + .then(response => response.json()) + .then(json => resolve(json)) + }); +} + /*function Shepherd_SendPendValue() { Shepherd_SysInfo().then(function(result){ var ram_data = formatBytes(result.totalmem_bytes) diff --git a/react/src/components/dashboard/sendCoin.js b/react/src/components/dashboard/sendCoin.js index b698e60..555c90d 100644 --- a/react/src/components/dashboard/sendCoin.js +++ b/react/src/components/dashboard/sendCoin.js @@ -3,6 +3,7 @@ import Config from '../../config'; import { translate } from '../../translate/translate'; import { sendToAddress, + sendFromAddress, sendNativeTx, getKMDOPID, resolveOpenAliasAddress, @@ -26,22 +27,47 @@ class SendCoin extends React.Component { amount: 0, fee: 0.0001, sendSig: false, + sendApiType: false, addressSelectorOpen: false, }; this.updateInput = this.updateInput.bind(this); - this.handleSubmit = this.handleSubmit.bind(this); + this.handleBasiliskSend = this.handleBasiliskSend.bind(this); this.openDropMenu = this.openDropMenu.bind(this); this.toggleSendSig = this.toggleSendSig.bind(this); this.getOAdress = this.getOAdress.bind(this); + this.toggleSendAPIType = this.toggleSendAPIType.bind(this); + } + + renderAddressAmount(address) { + if (this.props.ActiveCoin.addresses && this.props.ActiveCoin.addresses['public'] && this.props.ActiveCoin.addresses['public'].length) { + for (let i = 0; i < this.props.ActiveCoin.addresses['public'].length; i++) { + if (this.props.ActiveCoin.addresses['public'][i].address === address) { + return this.props.ActiveCoin.addresses['public'][i].amount; + } + } + } else { + return 0; + } } renderAddressByType(type) { if (this.props.ActiveCoin.addresses && this.props.ActiveCoin.addresses[type] && this.props.ActiveCoin.addresses[type].length) { - return this.props.ActiveCoin.addresses[type].map((address) => -