diff --git a/react/build.zip b/react/build.zip
deleted file mode 100644
index 25965a1..0000000
Binary files a/react/build.zip and /dev/null differ
diff --git a/react/src/actions/actionCreators.js b/react/src/actions/actionCreators.js
index fe8d8b6..307b763 100644
--- a/react/src/actions/actionCreators.js
+++ b/react/src/actions/actionCreators.js
@@ -2,17 +2,48 @@ import 'whatwg-fetch';
import 'bluebird';
import _config from '../config';
-import {
- startCurrencyAssetChain,
- startAssetChain,
- startCrypto,
- checkCoinType,
- checkAC
-} from '../components/addcoin/payload';
-import { copyToClipboard } from '../util/copyToClipboard';
import { translate } from '../translate/translate';
-
-let Config;
+import * as storeType from './storeType';
+import {
+ logGuiHttp,
+ getAgamaLog,
+ guiLogState
+} from './log';
+
+export * from './nativeSyncInfo';
+export * from './basiliskCache';
+export * from './nativeSend';
+export * from './coinList';
+export * from './syncOnly';
+export * from './createWallet';
+export * from './nativeTxHistory';
+export * from './nativeBalance';
+export * from './nativeNewAddress';
+export * from './logout';
+export * from './syncOnly';
+export * from './basiliskProcessAddress';
+export * from './edexGetTx';
+export * from './sendFullBasilisk';
+export * from './settings';
+export * from './syncOnly';
+export * from './iguanaInstance';
+export * from './notary';
+export * from './edexBalance';
+export * from './addCoin';
+export * from './addressBalance';
+export * from './syncInfo';
+export * from './getAddrByAccount';
+export * from './atomic';
+export * from './walletAuth';
+export * from './openAlias';
+export * from './copyAddress';
+export * from './sysInfo';
+export * from './dexCoins';
+export * from './fullTxHistory';
+export * from './basiliskTxHistory';
+export * from './iguanaHelpers';
+
+export let Config;
try {
Config = window.require('electron').remote.getCurrentWindow().appConfig;
@@ -20,117 +51,76 @@ try {
Config = _config;
}
-export const TOASTER_MESSAGE = 'TOASTER_MESSAGE';
-export const DISPLAY_ADDCOIN_MODAL = 'DISPLAY_ADDCOIN_MODAL';
-export const GET_ACTIVE_COINS = 'GET_ACTIVE_COINS';
-export const LOGIN = 'LOGIN';
-export const ACTIVE_HANDLE = 'ACTIVE_HANDLE';
-export const DASHBOARD_SECTION_CHANGE = 'DASHBOARD_SECTION_CHANGE';
-export const DASHBOARD_ACTIVE_COIN_CHANGE = 'DASHBOARD_ACTIVE_COIN_CHANGE';
-export const GET_MAIN_ADDRESS = 'GET_MAIN_ADDRESS';
-export const DASHBOARD_ACTIVE_COIN_BALANCE = 'DASHBOARD_ACTIVE_COIN_BALANCE';
-export const DASHBOARD_ACTIVE_COIN_SEND_FORM = 'DASHBOARD_ACTIVE_COIN_SEND_FORM';
-export const DASHBOARD_ACTIVE_COIN_RECEIVE_FORM = 'DASHBOARD_ACTIVE_COIN_RECEIVE_FORM';
-export const DASHBOARD_ACTIVE_COIN_RESET_FORMS = 'DASHBOARD_ACTIVE_COIN_RESET_FORMS';
-export const ATOMIC = 'ATOMIC';
-export const GET_WIF_KEY = 'GET_WIF_KEY';
-export const GET_PEERS_LIST = 'GET_PEERS_LIST';
-export const GET_DEBUG_LOG = 'GET_DEBUG_LOG';
-export const BASILISK_REFRESH = 'BASILISK_REFRESH';
-export const BASILISK_CONNECTION = 'BASILISK_CONNECTION';
-export const SYNCING_FULL_MODE = 'SYNCING_FULL_MODE';
-export const SYNCING_NATIVE_MODE = 'SYNCING_NATIVE_MODE';
-export const ACTIVE_COIN_GET_ADDRESSES = 'ACTIVE_COIN_GET_ADDRESSES';
-export const START_INTERVAL= 'START_INTERVAL';
-export const STOP_INTERVAL= 'STOP_INTERVAL';
-export const DASHBOARD_ACTIVE_SECTION = 'DASHBOARD_ACTIVE_SECTION';
-export const DASHBOARD_ACTIVE_TXINFO_MODAL = 'DASHBOARD_ACTIVE_TXINFO_MODAL';
-export const DASHBOARD_ACTIVE_COIN_NATIVE_BALANCE = 'DASHBOARD_ACTIVE_COIN_NATIVE_BALANCE';
-export const DASHBOARD_ACTIVE_COIN_NATIVE_TXHISTORY = 'DASHBOARD_ACTIVE_COIN_NATIVE_TXHISTORY';
-export const DASHBOARD_ACTIVE_COIN_NATIVE_OPIDS = 'DASHBOARD_ACTIVE_COIN_NATIVE_OPIDS';
-export const DASHBOARD_ACTIVE_COIN_SENDTO = 'DASHBOARD_ACTIVE_COIN_SENDTO';
-export const DASHBOARD_ACTIVE_COIN_GET_CACHE = 'DASHBOARD_ACTIVE_COIN_GET_CACHE';
-export const DASHBOARD_ACTIVE_COIN_MAIN_BASILISK_ADDR = 'DASHBOARD_ACTIVE_COIN_MAIN_BASILISK_ADDR';
-export const DASHBOARD_GET_NOTARIES_LIST = 'DASHBOARD_GET_NOTARIES_LIST';
-export const DASHBOARD_DISPLAY_NOTARIES_MODAL = 'DASHBOARD_DISPLAY_NOTARIES_MODAL';
-export const DASHBOARD_CONNECT_NOTARIES = 'DASHBOARD_CONNECT_NOTARIES';
-export const VIEW_CACHE_DATA = 'VIEW_CACHE_DATA';
-export const SYNC_ONLY_MODAL_TOGGLE = 'SYNC_ONLY_MODAL_TOGGLE';
-export const SYNC_ONLY_DATA = 'SYNC_ONLY_DATA';
-export const LOAD_APP_CONFIG = 'LOAD_APP_CONFIG';
-export const SAVE_APP_CONFIG = 'SAVE_APP_CONFIG';
-export const SERVICE_ERROR = 'SERVICE_ERROR';
-export const DASHBOARD_ACTIVE_ADDRESS = 'DASHBOARD_ACTIVE_ADDRESS';
-export const LOAD_APP_INFO = 'LOAD_APP_INFO';
-export const LOG_GUI_HTTP = 'LOG_GUI_HTTP';
-
-export function changeActiveAddress(address) {
+export function triggerToaster(display, message, title, _type) {
return {
- type: DASHBOARD_ACTIVE_ADDRESS,
- address,
+ type: storeType.TOASTER_MESSAGE,
+ display,
+ message,
+ title,
+ _type,
}
}
-function updateErrosStack(method) {
+export function changeActiveAddress(address) {
return {
- apiMethod: method,
+ type: storeType.DASHBOARD_ACTIVE_ADDRESS,
+ address,
}
}
-export function toggleSyncOnlyModal(display) {
+export function updateErrosStack(method) {
return {
- type: SYNC_ONLY_MODAL_TOGGLE,
- display,
+ apiMethod: method,
}
}
export function toggleViewCacheModal(display) {
return {
- type: VIEW_CACHE_DATA,
+ type: storeType.VIEW_CACHE_DATA,
display,
}
}
export function displayNotariesModal(display) {
return {
- type: DASHBOARD_DISPLAY_NOTARIES_MODAL,
+ type: storeType.DASHBOARD_DISPLAY_NOTARIES_MODAL,
display,
}
}
export function changeMainBasiliskAddress(address) {
return {
- type: DASHBOARD_ACTIVE_COIN_MAIN_BASILISK_ADDR,
+ type: storeType.DASHBOARD_ACTIVE_COIN_MAIN_BASILISK_ADDR,
address,
}
}
export function toggleDashboardActiveSection(name) {
return {
- type: DASHBOARD_ACTIVE_SECTION,
+ type: storeType.DASHBOARD_ACTIVE_SECTION,
section: name,
}
}
export function toggleDashboardTxInfoModal(display, txIndex) {
return {
- type: DASHBOARD_ACTIVE_TXINFO_MODAL,
+ type: storeType.DASHBOARD_ACTIVE_TXINFO_MODAL,
showTransactionInfo: display,
showTransactionInfoTxIndex: txIndex,
}
}
-function basiliskConnectionState(display, json) {
+export function basiliskConnectionState(display, json) {
return {
- type: BASILISK_CONNECTION,
+ type: storeType.BASILISK_CONNECTION,
basiliskConnection: display,
progress: json,
}
}
-function basiliskRefreshState(display, json) {
+export function basiliskRefreshState(display, json) {
return {
- type: BASILISK_REFRESH,
+ type: storeType.BASILISK_REFRESH,
basiliskRefresh: display,
progress: json,
}
@@ -150,7 +140,7 @@ export function basiliskConnection(display) {
export function syncingNativeModeState(display, json) {
return {
- type: SYNCING_FULL_MODE,
+ type: storeType.SYNCING_FULL_MODE,
syncingNativeMode: display,
progress: json,
}
@@ -158,91 +148,53 @@ export function syncingNativeModeState(display, json) {
export function syncingFullModeState(display, json) {
return {
- type: SYNCING_NATIVE_MODE,
+ type: storeType.SYNCING_NATIVE_MODE,
syncingFullMode: display,
progress: json,
}
}
-function atomicState(json) {
+export function toggleSendCoinFormState(display) {
return {
- type: ATOMIC,
- response: json,
- }
-}
-
-function toggleSendCoinFormState(display) {
- return {
- type: DASHBOARD_ACTIVE_COIN_SEND_FORM,
+ type: storeType.DASHBOARD_ACTIVE_COIN_SEND_FORM,
send: display,
}
}
-function toggleReceiveCoinFormState(display) {
+export function toggleReceiveCoinFormState(display) {
return {
- type: DASHBOARD_ACTIVE_COIN_RECEIVE_FORM,
+ type: storeType.DASHBOARD_ACTIVE_COIN_RECEIVE_FORM,
receive: display,
}
}
-function toggleSendReceiveCoinFormsState() {
+export function toggleSendReceiveCoinFormsState() {
return {
- type: DASHBOARD_ACTIVE_COIN_RESET_FORMS,
+ type: storeType.DASHBOARD_ACTIVE_COIN_RESET_FORMS,
send: false,
receive: false,
}
}
-export function triggerToaster(display, message, title, _type) {
- return {
- type: TOASTER_MESSAGE,
- display,
- message,
- title,
- _type,
- }
-}
-
-function toggleAddcoinModalState(display, isLogin) {
+export function toggleAddcoinModalState(display, isLogin) {
return {
- type: DISPLAY_ADDCOIN_MODAL,
+ type: storeType.DISPLAY_ADDCOIN_MODAL,
display: display,
isLogin: isLogin,
}
}
-function dashboardCoinsState(json) {
+export function dashboardCoinsState(json) {
return {
- type: GET_ACTIVE_COINS,
+ type: storeType.GET_ACTIVE_COINS,
coins: json,
activeCoins: Object.keys(json.native).length || Object.keys(json.basilisk).length || Object.keys(json.full).length ? true : false
}
}
-function iguanaWalletPassphraseState(json, dispatch) {
- console.log('iguanaWalletPassphraseState', json);
- sessionStorage.setItem('IguanaActiveAccount', JSON.stringify(json));
- dispatch(triggerToaster(true, translate('TOASTR.LOGIN_SUCCESSFULL'), translate('TOASTR.ACCOUNT_NOTIFICATION'), 'success'));
- dispatch(getMainAddressState(json));
- dispatch(iguanaActiveHandleState(json));
-
- return {
- type: LOGIN,
- isLoggedIn: json && json.pubkey ? true : false,
- }
-}
-
-function iguanaActiveHandleState(json) {
- return {
- type: ACTIVE_HANDLE,
- isLoggedIn: sessionStorage.getItem('IguanaActiveAccount') && JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey === json.pubkey && json.status === 'unlocked' ? true : false,
- handle: json,
- }
-}
-
-function getMainAddressState(json) {
+export function getMainAddressState(json) {
return {
- type: GET_MAIN_ADDRESS,
+ type: storeType.GET_MAIN_ADDRESS,
activeHandle: json,
}
}
@@ -265,68 +217,9 @@ export function toggleSendReceiveCoinForms() {
}
}
-function logoutState(json, dispatch) {
- console.log('passp', json);
- sessionStorage.removeItem('IguanaActiveAccount');
-
- return {
- type: LOGIN,
- isLoggedIn: false,
- }
-}
-
-export function logout() {
- return dispatch => {
- dispatch(walletLock());
- }
-}
-
-function walletLock() {
- const payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': 'bitcoinrpc',
- 'method': 'walletlock',
- };
-
- return dispatch => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'walletLock',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'walletLock', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- dispatch(logoutState(json));
- })
- }
-}
-
-function dashboardChangeSectionState(sectionName) {
+export function dashboardChangeSectionState(sectionName) {
return {
- type: DASHBOARD_SECTION_CHANGE,
+ type: storeType.DASHBOARD_SECTION_CHANGE,
activeSection: sectionName,
}
}
@@ -337,21 +230,14 @@ export function dashboardChangeSection(sectionName) {
}
}
-function dashboardChangeActiveCoinState(coin, mode) {
+export function dashboardChangeActiveCoinState(coin, mode) {
return {
- type: DASHBOARD_ACTIVE_COIN_CHANGE,
+ type: storeType.DASHBOARD_ACTIVE_COIN_CHANGE,
coin: coin,
mode: mode,
}
}
-function iguanaEdexBalanceState(json) {
- return {
- type: DASHBOARD_ACTIVE_COIN_BALANCE,
- balance: json && json.result ? json.result : 0,
- }
-}
-
export function dashboardChangeActiveCoin(coin, mode) {
return dispatch => {
dispatch(dashboardChangeActiveCoinState(coin, mode));
@@ -364,306 +250,14 @@ export function toggleAddcoinModal(display, isLogin) {
}
}
-export function copyCoinAddress(address) {
- const _result = copyToClipboard(address);
-
- if (_result) {
- return dispatch => {
- dispatch(triggerToaster(true, translate('DASHBOARD.ADDR_COPIED'), translate('TOASTR.COIN_NOTIFICATION'), 'success'));
- }
- } else {
- return dispatch => {
- dispatch(triggerToaster(true, 'Couldn\'t copy address to clipboard', translate('TOASTR.COIN_NOTIFICATION'), 'error'));
- }
- }
-}
-
export function dismissToasterMessage() {
return dispatch => {
dispatch(triggerToaster(false))
}
}
-export function addCoin(coin, mode, syncOnly, port) {
- console.log('coin, mode, syncOnly', coin + ' ' + mode + ' ' + syncOnly);
- if (mode === '-1') {
- return dispatch => {
- dispatch(shepherdGetConfig(coin, mode));
- }
- } else {
- if (checkCoinType(coin) === 'currency_ac') {
- const _acData = startCurrencyAssetChain('', coin, mode);
-
- return dispatch => {
- dispatch(iguanaAddCoin(coin, mode, _acData));
- }
- }
- if (checkCoinType(coin) === 'ac') {
- const _acData = startAssetChain('', coin, mode);
-
- return dispatch => {
- dispatch(iguanaAddCoin(coin, mode, _acData));
- }
- }
- if (checkCoinType(coin) === 'crypto') {
- const _acData = startCrypto('', coin, mode);
-
- if (syncOnly) {
- const modeToValue = {
- '1': 'full',
- '0': 'basilisk',
- '-1': 'native'
- };
-
- return dispatch => {
- startIguanaInstance(modeToValue[mode] + '/sync', coin)
- .then(function(json) {
- setTimeout(function() {
- console.log('started ' + coin + ' / ' + modeToValue[mode] + ' fork', json);
- dispatch(iguanaAddCoin(coin, mode, _acData, json.result));
- }, 2000);
- });
- }
- } else {
- if (port) {
- return dispatch => {
- dispatch(iguanaAddCoin(coin, mode, _acData, port));
- }
- } else {
- return dispatch => {
- dispatch(iguanaAddCoin(coin, mode, _acData));
- }
- }
- }
- }
- }
-}
-
-export function iguanaAddCoin(coin, mode, acData, port) {
- function _iguanaAddCoin(dispatch) {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'iguanaAddCoin',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + (port ? port : Config.iguanaCorePort),
- 'payload': acData,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + (port ? port : Config.iguanaCorePort), {
- method: 'POST',
- body: JSON.stringify(acData),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, translate('TOASTR.FAILED_TO_ADDCOIN'), translate('TOASTR.ACCOUNT_NOTIFICATION'), 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- dispatch(addCoinResult(coin, mode, acData))
- });
- }
-
- if (mode === 0) {
- return dispatch => {
- return _iguanaAddCoin(dispatch);
- }
- } else {
- return dispatch => {
- return _iguanaAddCoin(dispatch);
- }
- }
-}
-
-export function shepherdHerd(coin, mode, path) {
- let acData;
- let herdData = {
- 'ac_name': coin,
- 'ac_options': [
- '-daemon=0',
- '-server',
- '-ac_name=' + coin,
- '-addnode=78.47.196.146'
- ]
- };
-
- if (coin === 'ZEC') {
- herdData = {
- 'ac_name': 'zcashd',
- 'ac_options': [
- '-daemon=0',
- '-server=1'
- ]
- };
- }
-
- if (coin === 'KMD') {
- herdData = {
- 'ac_name': 'komodod',
- 'ac_options': [
- '-daemon=0',
- '-addnode=78.47.196.146'
- ]
- };
- }
-
- if (checkCoinType(coin) === 'crypto') {
- acData = startCrypto(path.result, coin, mode);
- }
- if (checkCoinType(coin) === 'currency_ac') {
- acData = startCurrencyAssetChain(path.result, coin, mode);
- }
- if (checkCoinType(coin) === 'ac') {
- acData = startAssetChain(path.result, coin, mode);
- var supply = startAssetChain(path.result, coin, mode, true);
- herdData.ac_options.push('-ac_supply=' + supply);
- }
-
- console.log('herdData', herdData);
- return dispatch => {
- return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/herd', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({
- 'herd': coin !== 'ZEC' ? 'komodod' : 'zcashd',
- 'options': herdData
- }),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, translate('FAILED_SHEPHERD_HERD'), translate('TOASTR.SERVICE_NOTIFICATION'), 'error'));
- })
- .then(response => response.json())
- .then(json => dispatch(iguanaAddCoin(coin, mode, acData)));
- }
-}
-
-export function addCoinResult(coin, mode) {
- const modeToValue = {
- '1': 'full',
- '0': 'basilisk',
- '-1': 'native'
- };
-
- return dispatch => {
- dispatch(triggerToaster(true, coin + ' ' + translate('TOASTR.STARTED_IN') + ' ' + modeToValue[mode] + ' ' + translate('TOASTR.MODE'), translate('TOASTR.COIN_NOTIFICATION'), 'success'));
- dispatch(toggleAddcoinModal(false, false));
- dispatch(getDexCoins());
- }
-}
-
-export function _shepherdGetConfig(coin, mode) {
- return dispatch => {
- return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/getconf', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({ 'chain': 'komodod' })
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'Failed to get mode config', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => dispatch(shepherdHerd(coin, mode, json)));
- }
-}
-
-export function shepherdGetConfig(coin, mode) {
- if (coin === 'KMD' &&
- mode === '-1') {
- return dispatch => {
- return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/getconf', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({ 'chain': 'komodod' })
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'Failed to get KMD config', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => dispatch(shepherdHerd(coin, mode, json)))
- }
- } else {
- return dispatch => {
- return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/getconf', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({ 'chain': coin })
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'Failed to get mode config', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => dispatch(shepherdHerd(coin, mode, json)));
- }
- }
-}
-
-export function getDexCoins() {
- const _payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': 'InstantDEX',
- 'method': 'allcoins',
- };
-
- return dispatch => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'getDexCoins',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': _payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(_payload)
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'Error getDexCoins', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- dispatch(dashboardCoinsState(json));
- });
- }
-}
-
-function rpcErrorHandler(json, dispatch) {
+// TODO
+export function rpcErrorHandler(json, dispatch) {
console.log('json', json);
if (json &&
json.error) {
@@ -673,485 +267,6 @@ function rpcErrorHandler(json, dispatch) {
}
}
-export function iguanaWalletPassphrase(_passphrase) {
- const _payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'handle': '',
- 'password': _passphrase,
- 'timeout': '2592000',
- 'agent': 'bitcoinrpc',
- 'method': 'walletpassphrase',
- };
-
- return dispatch => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'walletLock',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': _payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(_payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'Error iguanaWalletPassphrase', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- dispatch(iguanaWalletPassphraseState(json, dispatch));
- });
- }
-}
-
-export function iguanaActiveHandle(getMainAddress) {
- const _payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': 'SuperNET',
- 'method': 'activehandle',
- };
-
- return dispatch => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'iguanaActiveHandle',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': _payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(_payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(updateErrosStack('activeHandle'));
- dispatch(triggerToaster(true, translate('TOASTR.IGUANA_ARE_YOU_SURE'), translate('TOASTR.SERVICE_NOTIFICATION'), 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- dispatch(getMainAddress ? getMainAddressState(json) : iguanaActiveHandleState(json));
- });
- }
-}
-
-export function iguanaEdexBalance(coin) {
- const _payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': 'bitcoinrpc',
- 'method': 'getbalance',
- 'coin': coin,
- };
-
- return dispatch => {
- if (coin) {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'iguanaEdexBalance',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': _payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(_payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'Error iguanaEdexBalance', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => dispatch(iguanaEdexBalanceState(json)));
- }
- }
-}
-
-export function atomic(payload) {
- return dispatch => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'atomic',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, payload.method, 'Atomic explore error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- dispatch(atomicState(json));
- });
- }
-}
-
-export function settingsWifkeyState(json, coin) {
- return {
- type: GET_WIF_KEY,
- wifkey: json[coin + 'wif'],
- address: json[coin],
- }
-}
-
-export function encryptWallet(_passphrase, cb, coin) {
- const payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': 'bitcoinrpc',
- 'method': 'encryptwallet',
- 'passphrase': _passphrase,
- };
-
- return dispatch => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'encryptWallet',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'encryptWallet', 'Error', 'error'));
- })
- .then(dispatch(walletPassphrase(_passphrase)))
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': 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': '300000',
- };
-
- return dispatch => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'walletpassphrase',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'walletPassphrase', 'Error', 'error'));
- })
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- })
- }
-}
-
-export function getPeersListState(json) {
- let peersList = {};
-
- if (json &&
- json.rawpeers &&
- json.rawpeers.length) {
- for (let i = 0; i < json.rawpeers.length; i++) {
- peersList[json.rawpeers[i].coin] = json.rawpeers[i].peers;
- }
- }
- return {
- type: GET_PEERS_LIST,
- supernetPeers: json && json.supernet[0] ? json.supernet : null,
- rawPeers: peersList,
- }
-}
-
-export function getFullTransactionsList(coin) {
- const payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'coin': coin,
- 'method': 'listtransactions',
- 'params': [
- 0,
- 9999999,
- []
- ],
- };
-
- return dispatch => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'getFullTransactionsList',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'getFullTransactionsList', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- dispatch(getNativeTxHistoryState(json));
- })
- }
-}
-
-export function getBasiliskTransactionsList(coin, address) {
- const payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': 'dex',
- 'method': 'listtransactions',
- 'address': address,
- 'count': 100,
- 'skip': 0,
- 'symbol': coin,
- };
-
- const pubkey = JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey;
-
- return dispatch => {
- return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/cache?pubkey=' + pubkey, {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json',
- },
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'getBasiliskTransactionsList+cache', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(function(json) {
- if (json.result &&
- !json.result.basilisk &&
- json.result.indexOf('no file with handle') > -1) {
- console.log('new cache');
- }
-
- json = json.result.basilisk;
- if (json[coin][address].listtransactions) {
- dispatch(getNativeTxHistoryState({ 'result': json[coin][address].listtransactions.data }));
- }
- })
- }
-}
-
-export function getPeersList(coin) {
- const payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': 'SuperNET',
- 'method': 'getpeers',
- 'activecoin': coin,
- };
-
- return dispatch => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'getPeersList',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'getPeersList', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- dispatch(getPeersListState(json, dispatch));
- })
- }
-}
-
-function addPeerNodeState(json, dispatch) {
- if (json.error === 'addnode needs active coin, do an addcoin first') {
- return dispatch => {
- dispatch(triggerToaster(true, 'Addnode needs active coin', translate('TOASTR.SETTINGS_NOTIFICATION'), 'error'));
- }
- }
- if (json.result === 'peer was already connected') {
- return dispatch => {
- dispatch(triggerToaster(true, 'Peer was already connected', translate('TOASTR.SETTINGS_NOTIFICATION'), 'warning'));
- }
- }
- if (json.result === 'addnode connection was already pending') {
- return dispatch => {
- dispatch(triggerToaster(true, 'Addnode connection was already pending', translate('TOASTR.SETTINGS_NOTIFICATION'), 'warning'));
- }
- }
- if (json.result === 'addnode submitted') {
- return dispatch => {
- dispatch(triggerToaster(true, 'Peer is added', translate('TOASTR.SETTINGS_NOTIFICATION'), 'success'));
- }
- }
-}
-
-export function addPeerNode(coin, ip) {
- const payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': 'iguana',
- 'method': 'addnode',
- 'activecoin': coin,
- 'ipaddr': ip,
- };
-
- return dispatch => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'addPeerNode',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'addPeerNode', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- dispatch(addPeerNodeState(json, dispatch));
- })
- }
-}
-
export function setBasiliskMainAddress(json, coin, mode) {
if (mode === 'full') {
let publicAddressArray = [];
@@ -1171,81 +286,30 @@ export function setBasiliskMainAddress(json, coin, mode) {
}
return {
- type: ACTIVE_COIN_GET_ADDRESSES,
+ type: storeType.ACTIVE_COIN_GET_ADDRESSES,
addresses: { 'public': [] },
}
}
-export function getAddressesByAccountState(json, coin, mode) {
- if (mode === 'full' ||
- mode === 'basilisk') {
- let publicAddressArray = [];
-
- for (let i = 0; i < json.result.length; i++) {
- publicAddressArray.push({
- 'address': json.result[i],
- 'amount': 'N/A'
- });
- }
-
- json.result = publicAddressArray;
+export function getNativeTxHistoryState(json) {
+ if (json &&
+ json.error) {
+ json = null;
+ } else if (json && json.result) {
+ json = json.result;
+ } else if (!json.length) {
+ json = 'no data';
}
return {
- type: ACTIVE_COIN_GET_ADDRESSES,
- addresses: { 'public': json.result },
- }
-}
-
-export function getAddressesByAccount(coin, mode) {
- const payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'coin': coin,
- 'agent': 'bitcoinrpc',
- 'method': 'getaddressesbyaccount',
- 'account': '*',
- };
-
- return dispatch => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'getAddressesByAccount',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(updateErrosStack('activeHandle'));
- dispatch(triggerToaster(true, 'getAddressesByAccount', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- dispatch(getAddressesByAccountState(json, coin, mode));
- })
+ type: storeType.DASHBOARD_ACTIVE_COIN_NATIVE_TXHISTORY,
+ txhistory: json,
}
}
export function startInterval(name, handle) {
return {
- type: START_INTERVAL,
+ type: storeType.START_INTERVAL,
name,
handle,
}
@@ -1255,2191 +319,7 @@ export function stopInterval(name, intervals) {
clearInterval(intervals[name]);
return {
- type: STOP_INTERVAL,
+ type: storeType.STOP_INTERVAL,
name,
}
-}
-
-// TODO: add custom json parser
-function getSyncInfoState(json) {
- try {
- JSON.parse(json);
- json = JSON.parse(json);
- } catch(e) {
- //
- }
-
- return {
- type: SYNCING_FULL_MODE,
- progress: json,
- }
-}
-
-export function getSyncInfo(coin) {
- const payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'coin': coin,
- 'agent': 'bitcoinrpc',
- 'method': 'getinfo',
- };
-
- return dispatch => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'getSyncInfo',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'getSyncInfo', 'Error', 'error'));
- })
- .then(function(response) {
- const _response = response.text().then(function(text) { return text; });
-
- return _response;
- })
- .then(function(json) {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- if (json.indexOf('coin is busy processing') === -1) {
- dispatch(getSyncInfoState(json, dispatch));
- }
- })
- }
-}
-
-function getKMDAddressesNativeState(json) {
- return {
- type: ACTIVE_COIN_GET_ADDRESSES,
- addresses: json,
- }
-}
-
-export function getKMDAddressesNative(coin, mode, currentAddress) {
- const type = ['public', 'private'];
-
- if (mode !== 'native') {
- type.pop();
- }
-
- return dispatch => {
- Promise.all(type.map((_type, index) => {
- return new Promise((resolve, reject) => {
- let payload,
- ajax_data_to_hex = '',
- ajax_function_input = '',
- tmplistaddr_hex_input = '',
- passthru_agent = getPassthruAgent(coin),
- tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth');
-
- if (_type === 'public') {
- ajax_function_input = 'getaddressesbyaccount';
- tmplistaddr_hex_input = '222200';
- }
- if (_type === 'private') {
- ajax_function_input = 'z_listaddresses';
- tmplistaddr_hex_input = '';
- }
-
- if (passthru_agent === 'iguana') {
- payload = {
- 'userpass': tmpIguanaRPCAuth,
- 'agent': passthru_agent,
- 'method': 'passthru',
- 'asset': coin,
- 'function': ajax_function_input,
- 'hex': tmplistaddr_hex_input,
- };
- } else {
- payload = {
- 'userpass': tmpIguanaRPCAuth,
- 'agent': passthru_agent,
- 'method': 'passthru',
- 'function': ajax_function_input,
- 'hex': tmplistaddr_hex_input,
- };
- }
-
- if (mode === 'full' || mode === 'basilisk') {
- payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'coin': coin,
- 'agent': 'bitcoinrpc',
- 'method': 'getaddressesbyaccount',
- 'account': '*',
- };
- }
-
- if (mode === 'basilisk') {
- const pubkey = JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey;
-
- fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/cache?pubkey=' + pubkey, {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json',
- },
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'getKMDAddressesNative+addresslist+cache', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(function(json) {
- json = json.result.basilisk;
-
- if (json[coin].addresses) {
- resolve({ 'result': json[coin].addresses });
- }
- })
- } else {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'getKMDAddressesNative',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'getKMDAddressesNative', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- resolve(json);
- })
- }
- });
- }))
- .then(result => {
- // TODO: split into 2 functions
- const passthru_agent = getPassthruAgent(coin),
- tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth');
- let payload;
-
- if (passthru_agent === 'iguana') {
- payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': passthru_agent,
- 'method': 'passthru',
- 'asset': coin,
- 'function': 'listunspent',
- 'hex': '',
- };
- } else {
- payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': passthru_agent,
- 'method': 'passthru',
- 'function': 'listunspent',
- 'hex': '',
- };
- }
-
- if (mode === 'full') {
- payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'coin': coin,
- 'method': 'listunspent',
- 'params': [
- 1,
- 9999999,
- ],
- };
- }
-
- // if api cache option is off
- if (mode === 'basilisk') {
- payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': 'dex',
- 'method': 'listunspent',
- 'address': currentAddress,
- 'symbol': coin,
- };
- }
-
- function calcBalance(result, json, dispatch, mode) {
- if (mode === 'full' ||
- mode === 'basilisk') {
- result[0] = result[0].result;
- }
-
- if (mode !== 'basilisk' &&
- json &&
- json.length) {
- const allAddrArray = json.map(res => res.address).filter((x, i, a) => a.indexOf(x) == i);
-
- for (let a = 0; a < allAddrArray.length; a++) {
- const filteredArray = json.filter(res => res.address === allAddrArray[a]).map(res => res.amount);
-
- let isNewAddr = true;
- for (let x = 0; x < result.length && isNewAddr; x++) {
- for (let y=0; y < result[x].length && isNewAddr; y++) {
- if (allAddrArray[a] === result[x][y]) {
- isNewAddr = false;
- }
- }
- }
-
- if (isNewAddr) {
- if (allAddrArray[a].substring(0, 2) === 'zc' ||
- allAddrArray[a].substring(0, 2) === 'zt') {
- result[1][result[1].length] = allAddrArray[a];
- } else {
- result[0][result[0].length] = allAddrArray[a];
- }
- }
- }
- }
-
- let newAddressArray = [];
-
- for (let a = 0; a < result.length; a++) {
- newAddressArray[a] = [];
-
- for (let b = 0; b < result[a].length; b++) {
- var filteredArray;
-
- if (mode === 'basilisk') {
- filteredArray = json.map(res => res.amount);
- } else {
- filteredArray = json.filter(res => res.address === result[a][b]).map(res => res.amount);
- }
-
- let sum = 0;
-
- for (let i=0; i < filteredArray.length; i++) {
- sum += filteredArray[i];
- }
-
- newAddressArray[a][b] = {
- address: result[a][b],
- amount: currentAddress === result[a][b] || mode === 'native' ? sum : 'N/A',
- };
- }
- }
-
- dispatch(getKMDAddressesNativeState({
- 'public': newAddressArray[0],
- 'private': newAddressArray[1]
- }));
- }
-
- if (mode === 'basilisk') {
- const pubkey = JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey;
-
- fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/cache?pubkey=' + pubkey, {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json',
- },
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'getKMDAddressesNative+addresslist+cache', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(function(json) {
- let updatedCache = Object.assign({}, json.result);
- json = json.result.basilisk;
- // if listunspent is not in cache file retrieve new copy
- // otherwise read from cache data
- if (json[coin][currentAddress].refresh) {
- calcBalance(result, json[coin][currentAddress].refresh.data, dispatch, mode);
- } else {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'getKMDAddressesNative+Balance',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + (Config.useBasiliskInstance && mode === 'basilisk' ? Config.iguanaCorePort + 1 : Config.iguanaCorePort),
- 'payload': payload,
- 'status': 'pending',
- }));
-
- fetch('http://127.0.0.1:' + (Config.useBasiliskInstance && mode === 'basilisk' ? Config.iguanaCorePort + 1 : Config.iguanaCorePort), {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'getKMDAddressesNative+Balance', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(function(json) {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- updatedCache.basilisk[coin][currentAddress].refresh = {
- 'data': json,
- 'status': 'done',
- 'timestamp': Date.now(),
- };
- dispatch(shepherdGroomPost(pubkey, updatedCache));
- calcBalance(result, json, dispatch, mode);
- })
- }
- })
- } else {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'getKMDAddressesNative+Balance',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + (Config.useBasiliskInstance && mode === 'basilisk' ? Config.iguanaCorePort + 1 : Config.iguanaCorePort),
- 'payload': payload,
- 'status': 'pending',
- }));
-
- fetch('http://127.0.0.1:' + (Config.useBasiliskInstance && mode === 'basilisk' ? Config.iguanaCorePort + 1 : Config.iguanaCorePort), {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'getKMDAddressesNative+Balance', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(function(json) {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- calcBalance(result, json, dispatch, mode);
- })
- }
- })
- }
-}
-
-export function shepherdGroomPost(_filename, _payload) {
- return dispatch => {
- return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/groom/', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({
- 'filename': _filename,
- 'payload': JSON.stringify(_payload),
- }),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'shepherdGroomPost', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => console.log(json))
- }
-}
-
-export function shepherdGroomPostPromise(_filename, _payload) {
- return new Promise((resolve, reject) => {
- fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/groom/', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({
- 'filename': _filename,
- 'payload': JSON.stringify(_payload),
- }),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'shepherdGroomPostPromise', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => resolve(json))
- })
-}
-
-export function fetchUtxoCache(_payload) {
- const _userpass = '?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- _pubkey = '&pubkey=' + _payload.pubkey,
- _route = _payload.allcoins ? 'cache-all' : 'cache-one',
- _coin = '&coin=' + _payload.coin,
- _calls = '&calls=' + _payload.calls,
- _address = _payload.address ? ('&address=' + _payload.address) : '',
- _iguanaInstancePort = Config.useBasiliskInstance ? '&port=' + (Config.iguanaCorePort + 1) : '';
-
- return dispatch => {
- return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/' + _route + _userpass + _pubkey + _coin + _calls + _address + _iguanaInstancePort, {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json',
- },
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'fetchNewCacheData', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => dispatch(getShepherdCache(_pubkey)))
- }
-}
-
-function getShepherdCacheState(json, pubkey, coin) {
- if (json.result &&
- json.error &&
- json.result.indexOf('no file with handle') > -1) {
- return dispatch => {
- dispatch(fetchNewCacheData({
- 'pubkey': pubkey,
- 'allcoins': false,
- 'coin': coin,
- 'calls': 'listtransactions:getbalance',
- }));
- }
- } else {
- return {
- type: DASHBOARD_ACTIVE_COIN_GET_CACHE,
- cache: json && json.result && json.result.basilisk ? json.result.basilisk : null,
- }
- }
-}
-
-export function getShepherdCache(pubkey, coin) {
- return dispatch => {
- return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/cache?pubkey=' + pubkey, {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json',
- },
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'getShepherdCache', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => dispatch(getShepherdCacheState(json, pubkey, coin)))
- }
-}
-
-function getDebugLogState(json) {
- const _data = json.result.replace('\n', '\r\n');
-
- return {
- type: GET_DEBUG_LOG,
- data: _data,
- }
-}
-
-export function getDebugLog(target, linesCount) {
- const payload = {
- 'herdname': target,
- 'lastLines': linesCount
- };
-
- return dispatch => {
- return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/debuglog', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'getDebugLog', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => dispatch(getDebugLogState(json)))
- }
-}
-
-function parseImportPrivKeyResponse(json, dispatch) {
- if (json.error === 'illegal privkey') {
- return dispatch => {
- dispatch(triggerToaster(true, 'Illegal privkey', translate('TOASTR.SETTINGS_NOTIFICATION'), 'error'));
- }
- }
- if (json.error === 'privkey already in wallet') {
- return dispatch => {
- dispatch(triggerToaster(true, 'Privkey already in wallet', translate('TOASTR.SETTINGS_NOTIFICATION'), 'warning'));
- }
- }
- if (json &&
- json.result !== undefined &&
- json.result == 'success') {
- return dispatch => {
- dispatch(triggerToaster(true, translate('TOASTR.PRIV_KEY_IMPORTED'), translate('TOASTR.SETTINGS_NOTIFICATION'), 'success'));
- }
- }
-}
-
-export function importPrivKey(wifKey) {
- const payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'method': 'importprivkey',
- 'params': [
- wifKey,
- 'imported'
- ],
- };
-
- return dispatch => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'importPrivKey',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'importPrivKey', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- dispatch(parseImportPrivKeyResponse(json, dispatch));
- })
- .catch(function(ex) {
- dispatch(parseImportPrivKeyResponse({ 'error': 'privkey already in wallet' }, dispatch));
- console.log('parsing failed', ex);
- })
- }
-}
-
-export function shepherdGetSysInfo() {
- return dispatch => {
- return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/sysinfo', {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json',
- }
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'Failed to get sys info', 'Error', 'error'))
- })
- .then(response => response.json())
- .then(json => dispatch(shepherdHerd(coin, mode, json)));
- }
-}
-
-export function getSyncInfoNativeKMD(skipDebug) {
- const coin = 'KMD';
-
- return dispatch => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'getSyncInfoNativeKMD',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort + '/api/dex/getinfo?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth') + '&symbol=' + coin,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + Config.iguanaCorePort + '/api/dex/getinfo?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth') + '&symbol=' + coin, {
- method: 'GET',
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'getSyncInfoNativeKMD', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- dispatch(getSyncInfoNativeState({ 'remoteKMDNode': json }));
- })
- .then(function() {
- if (!skipDebug) {
- dispatch(getDebugLog('komodo', 1));
- }
- })
- }
-}
-
-function getSyncInfoNativeState(json, coin, skipDebug) {
- if (coin === 'KMD' &&
- json &&
- json.error) {
- return getSyncInfoNativeKMD(skipDebug);
- } else {
- return {
- type: SYNCING_NATIVE_MODE,
- progress: json,
- }
- }
-}
-
-function getPassthruAgent(coin) {
- let passthru_agent;
-
- if ( coin === 'KMD') { passthru_agent = 'komodo'; };
- if ( coin === 'ZEC') { passthru_agent = 'zcash'; };
-
- if (checkAC(coin)) { passthru_agent = 'iguana'; };
-
- return passthru_agent;
-}
-
-export function getSyncInfoNative(coin, skipDebug) {
- const payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': getPassthruAgent(coin),
- 'method': 'passthru',
- 'asset': coin,
- 'function': 'getinfo',
- 'hex': '',
- };
-
- return dispatch => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'getSyncInfo',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'getSyncInfo', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- dispatch(getSyncInfoNativeState(json, coin, skipDebug));
- })
- }
-}
-
-export function getDexBalance(coin, mode, addr) {
- Promise.all(addr.map((_addr, index) => {
- const payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': 'dex',
- 'method': 'listunspent',
- 'address': _addr,
- 'symbol': coin,
- };
-
- return new Promise((resolve, reject) => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'getDexBalance',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort),
- 'payload': payload,
- 'status': 'pending',
- }));
-
- fetch('http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort), {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'getDexBalance', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- console.log(json);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- })
-
- resolve(index);
- });
- }))
- .then(result => {
- console.log(result);
- });
-}
-
-export function getKMDBalanceTotal(coin) {
- let payload;
-
- if (coin !== 'KMD' &&
- coin !== 'ZEC') {
- payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': 'iguana',
- 'method': 'passthru',
- 'asset': coin,
- 'function': 'z_gettotalbalance',
- 'hex': '3000',
- };
- } else {
- payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': getPassthruAgent(coin),
- 'method': 'passthru',
- 'function': 'z_gettotalbalance',
- 'hex': '3000',
- };
- }
-
- return dispatch => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'getKMDBalanceTotal',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'getKMDBalanceTotal', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(function(json) { // TODO: figure out why komodod spits out "parse error"
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- if (json &&
- !json.error) {
- dispatch(getNativeBalancesState(json));
- }
- })
- }
-}
-
-export function getNativeBalancesState(json) {
- return {
- type: DASHBOARD_ACTIVE_COIN_NATIVE_BALANCE,
- balance: json && !json.error ? json : 0,
- }
-}
-
-export function getNativeTxHistory(coin) {
- let payload;
-
- if (getPassthruAgent(coin) === 'iguana') {
- payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': 'iguana',
- 'method': 'passthru',
- 'asset': coin,
- 'function': 'listtransactions',
- 'hex': '',
- };
- } else {
- payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': getPassthruAgent(coin),
- 'method': 'passthru',
- 'function': 'listtransactions',
- 'hex': '',
- };
- }
-
- return dispatch => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'getNativeTxHistory',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'getNativeTxHistory', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- dispatch(getNativeTxHistoryState(json));
- })
- }
-}
-
-export function getNativeTxHistoryState(json) {
- if (json &&
- json.error) {
- json = null;
- } else if (json && json.result) {
- json = json.result;
- } else if (!json.length) {
- json = 'no data';
- }
-
- return {
- type: DASHBOARD_ACTIVE_COIN_NATIVE_TXHISTORY,
- txhistory: json,
- }
-}
-
-function handleGetNewKMDAddresses(pubpriv, coin, dispatch) {
- dispatch(triggerToaster(true, translate('KMD_NATIVE.NEW_ADDR_GENERATED'), translate('TOASTR.WALLET_NOTIFICATION'), 'success'));
- dispatch(getKMDAddressesNative(coin));
-
- return {};
-}
-
-export function getNewKMDAddresses(coin, pubpriv) {
- let payload,
- ajax_function_input = '';
-
- if (pubpriv === 'public') {
- ajax_function_input = 'getnewaddress';
- }
- if (pubpriv === 'private') {
- ajax_function_input = 'z_getnewaddress';
- }
-
- if (getPassthruAgent(coin) === 'iguana') {
- payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': getPassthruAgent(coin),
- 'method': 'passthru',
- 'asset': coin,
- 'function': ajax_function_input,
- 'hex': '',
- };
- } else {
- payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': coin,
- 'method': 'passthru',
- 'function': ajax_function_input,
- 'hex': '',
- };
- }
-
- return dispatch => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'getNewKMDAddresses',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'getNewKMDAddresses', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- dispatch(handleGetNewKMDAddresses(pubpriv, coin, dispatch));
- })
- .catch(function(ex) {
- dispatch(handleGetNewKMDAddresses(pubpriv, coin, dispatch))
- })
- }
-}
-
-export function iguanaHashHex(data) {
- const payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': 'hash',
- 'method': 'hex',
- 'message': data,
- };
-
- return new Promise((resolve, reject) => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'iguanaHashHex',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'iguanaHashHex', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- resolve(json.hex);
- })
- })
-}
-
-export function sendNativeTx(coin, _payload) {
- let ajax_data_to_hex;
- let payload;
- let _apiMethod;
-
- if (_payload.addressType === 'public') {
- _apiMethod = 'sendtoaddress';
- ajax_data_to_hex = '["' + _payload.sendTo + '", ' + (Number(_payload.amount) - Number(_payload.fee)) + ']';
- } else {
- _apiMethod = 'z_sendmany';
- ajax_data_to_hex = '["' + _payload.sendFrom + '",[{"address":"' + _payload.sendTo + '","amount":' + (Number(_payload.amount) - Number(_payload.fee)) + '}]]';
- }
-
- return dispatch => {
- return iguanaHashHex(ajax_data_to_hex).then((hashHexJson) => {
- if (getPassthruAgent(coin) === 'iguana') {
- payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': getPassthruAgent(coin),
- 'method': 'passthru',
- 'asset': coin,
- 'function': _apiMethod,
- 'hex': hashHexJson,
- };
- } else {
- payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': getPassthruAgent(coin),
- 'method': 'passthru',
- 'function': _apiMethod,
- 'hex': hashHexJson,
- };
- }
-
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'sendNativeTx',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'sendNativeTx', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(function(json) {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
-
- if (json.error &&
- json.error.toString().indexOf('code:') > -1) {
- dispatch(triggerToaster(true, 'Send failed', translate('TOASTR.WALLET_NOTIFICATION'), 'error'));
- } else {
- dispatch(triggerToaster(true, translate('TOASTR.TX_SENT_ALT'), translate('TOASTR.WALLET_NOTIFICATION'), 'success'));
- }
- })
- .catch(function(ex) {
- dispatch(triggerToaster(true, translate('TOASTR.TX_SENT_ALT'), translate('TOASTR.WALLET_NOTIFICATION'), 'success'));
- console.log('parsing failed', ex);
- })
- });
- }
-}
-
-export function getKMDOPIDState(json) {
- return {
- type: DASHBOARD_ACTIVE_COIN_NATIVE_OPIDS,
- opids: json,
- }
-}
-
-export function getKMDOPID(opid, coin) {
- let tmpopid_output = '',
- ajax_data_to_hex;
-
- if (opid === undefined) {
- ajax_data_to_hex = null;
- } else {
- ajax_data_to_hex = '["' + opid + '"]';
- }
-
- return dispatch => {
- return iguanaHashHex(ajax_data_to_hex).then((hashHexJson) => {
- if (hashHexJson === '5b226e756c6c225d00') {
- hashHexJson = '';
- }
-
- let payload,
- passthru_agent = getPassthruAgent(coin),
- tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth');
-
- if (passthru_agent == 'iguana') {
- payload = {
- 'userpass': tmpIguanaRPCAuth,
- 'agent': passthru_agent,
- 'method': 'passthru',
- 'asset': coin,
- 'function': 'z_getoperationstatus',
- 'hex': hashHexJson,
- };
- } else {
- payload = {
- 'userpass': tmpIguanaRPCAuth,
- 'agent': passthru_agent,
- 'method': 'passthru',
- 'function': 'z_getoperationstatus',
- 'hex': hashHexJson,
- };
- }
-
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'getKMDOPID',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'getKMDOPID', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- dispatch(getKMDOPIDState(json));
- })
- })
- }
-}
-
-function sendToAddressState(json, dispatch) {
- if (json &&
- json.error) {
- dispatch(triggerToaster(true, json.error, 'Error', 'error'));
-
- return {
- type: DASHBOARD_ACTIVE_COIN_SENDTO,
- lastSendToResponse: json,
- }
- } else if (json && json.result && json.complete) {
- dispatch(triggerToaster(true, translate('TOASTR.TX_SENT_ALT'), translate('TOASTR.WALLET_NOTIFICATION'), 'success'));
-
- return {
- type: DASHBOARD_ACTIVE_COIN_SENDTO,
- lastSendToResponse: json,
- }
- }
-}
-
-export function sendToAddressStateAlt(json) {
- return {
- type: DASHBOARD_ACTIVE_COIN_SENDTO,
- lastSendToResponse: json,
- }
-}
-
-export function clearLastSendToResponseState() {
- return {
- type: DASHBOARD_ACTIVE_COIN_SENDTO,
- lastSendToResponse: null,
- }
-}
-
-export function sendToAddress(coin, _payload) {
- const payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'coin': coin,
- 'method': 'sendtoaddress',
- 'params': [
- _payload.sendTo,
- _payload.amount,
- 'EasyDEX',
- 'EasyDEXTransaction'
- ],
- };
-
- return dispatch => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'sendToAddress',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'sendToAddress', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- dispatch(sendToAddressState(json, dispatch));
- })
- }
-}
-
-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 => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'walletLock',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'sendFromAddress', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- dispatch(sendToAddressState(json, dispatch));
- })
- }
-}
-
-function checkAddressBasiliskHandle(json) {
- if (json &&
- json.error) {
- return dispatch => {
- dispatch(triggerToaster(true, json.error, translate('TOASTR.WALLET_NOTIFICATION'), 'error'));
- }
- }
-
- if (json &&
- json.coin &&
- json.randipbits) {
- return dispatch => {
- dispatch(triggerToaster(true, 'Address already registered', translate('TOASTR.WALLET_NOTIFICATION'), 'warning'));
- }
- }
-}
-
-export function checkAddressBasilisk(coin, address) {
- const payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': 'dex',
- 'method': 'checkaddress',
- 'address': address,
- 'symbol': coin,
- };
-
- return dispatch => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'checkAddressBasilisk',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort),
- 'payload': payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort), {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'checkAddressBasilisk', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- dispatch(checkAddressBasiliskHandle(json));
- })
- }
-}
-
-function validateAddressBasiliskHandle(json) {
- return dispatch => {
- if (json.iswatchonly === true) {
- dispatch(triggerToaster(true, translate('TOASTR.VALIDATION_SUCCESS'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error'));
- }
- if (json.iswatchonly === false) {
- dispatch(triggerToaster(true, translate('TOASTR.ADDR_ISNT_REG'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error'));
- }
- if (json.iswatchonly === undefined) {
- dispatch(triggerToaster(true, translate('TOASTR.INVALID_QUERY_ALT'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error'));
- }
- if (json.error === 'less than required responses') {
- dispatch(triggerToaster(true, translate('TOASTR.LESS_RESPONSES_REQ'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error'));
- }
- }
-}
-
-export function validateAddressBasilisk(coin, address) {
- const payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': 'dex',
- 'method': 'validateaddress',
- 'address': address,
- 'symbol': coin,
- };
-
- return dispatch => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'validateAddressBasilisk',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort), {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'validateAddressBasilisk', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- dispatch(validateAddressBasiliskHandle(json));
- })
- }
-}
-
-function getDexNotariesState(json) {
- if (json.error === 'less than required responses') {
- return dispatch => {
- dispatch(triggerToaster(true, translate('TOASTR.LESS_RESPONSES_REQ'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error'));
- }
- } else {
- return {
- type: DASHBOARD_GET_NOTARIES_LIST,
- notaries: json,
- }
- }
-}
-
-export function getDexNotaries(coin) {
- const payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': 'dex',
- 'method': 'getnotaries',
- 'symbol': coin,
- };
-
- return dispatch => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'getDexNotaries',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort),
- 'payload': payload,
- 'status': 'pending',
- }));
- return fetch('http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort), {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'getDexNotaries', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- dispatch(getDexNotariesState(json));
- })
- }
-}
-
-function createNewWalletState(json) {
- if (json &&
- json.result &&
- json.result === 'success') {
- return dispatch => {
- dispatch(triggerToaster(true, translate('TOASTR.WALLET_CREATED_SUCCESFULLY'), translate('TOASTR.ACCOUNT_NOTIFICATION'), 'success'));
- }
- } else {
- return dispatch => {
- dispatch(triggerToaster(true, 'Couldn\'t create new wallet seed', translate('TOASTR.ACCOUNT_NOTIFICATION'), 'error'));
- }
- }
-}
-
-export function createNewWallet(_passphrase) {
- const payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': 'bitcoinrpc',
- 'method': 'encryptwallet',
- 'passphrase': _passphrase,
- };
-
- return dispatch => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'createNewWallet',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'createNewWallet', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- dispatch(createNewWalletState(json));
- })
- }
-}
-
-export function deleteCacheFile(_payload) {
- return dispatch => {
- return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/groom?', {
- method: 'DELETE',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({ 'filename': _payload.pubkey }),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'deleteCacheFile', 'Error', 'error'))
- })
- .then(response => response.json())
- .then(json => dispatch(fetchNewCacheData(_payload)));
- }
-}
-
-export function getCacheFile(pubkey) {
- const _pubkey = pubkey || JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey;
-
- return new Promise((resolve, reject) => {
- fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/groom?filename=' + _pubkey, {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json',
- },
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'getCacheFile', 'Error', 'error'))
- })
- .then(response => response.json())
- .then(json => resolve(json))
- })
-}
-
-export function fetchNewCacheData(_payload) {
- console.log('fetchNewCacheData', true);
- const _userpass = '?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- _pubkey = '&pubkey=' + _payload.pubkey,
- _route = _payload.allcoins ? 'cache-all' : 'cache-one',
- _coin = '&coin=' + _payload.coin,
- _calls = '&calls=' + _payload.calls,
- _address = _payload.address ? ('&address=' + _payload.address) : '',
- _iguanaInstancePort = Config.useBasiliskInstance ? '&port=' + (Config.iguanaCorePort + 1) : '';
-
- return dispatch => {
- return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/' + _route + _userpass + _pubkey + _coin + _calls + _address + _iguanaInstancePort, {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json',
- },
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'fetchNewCacheData', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => console.log(json))
- }
-}
-
-function initNotaryNodesConSequence(nodes) {
- return dispatch => {
- Promise.all(nodes.map((node, index) => {
- const payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': 'dex',
- 'method': 'getinfo',
- 'symbol': node,
- 'timeout': 10000
- };
-
- return new Promise((resolve, reject) => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'initNotaryNodesConSequence+' + node,
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- fetch('http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort) + '/api/dex/getinfo?userpass=' + ('tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth')) + '&symbol=' + node, {
- method: 'GET',
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'getInfoDexNode+' + node, 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- dispatch(updateNotaryNodeConState(json, nodes.length, index, node));
- })
- });
- }));
- }
-}
-
-function updateNotaryNodeConState(json, totalNodes, currentNodeIndex, currentNodeName) {
- if (currentNodeIndex === totalNodes - 1) {
- return dispatch => {
- dispatch(basiliskConnectionState(false));
- };
- } else {
- if (json &&
- json.error === 'less than required responses') {
- return {
- type: DASHBOARD_CONNECT_NOTARIES,
- total: totalNodes - 1,
- current: currentNodeIndex,
- name: currentNodeName,
- failedNode: currentNodeName,
- }
- } else {
- return {
- type: DASHBOARD_CONNECT_NOTARIES,
- total: totalNodes - 1,
- current: currentNodeIndex,
- name: currentNodeName,
- }
- }
- }
-}
-
-function connectAllNotaryNodes(json, dispatch) {
- if (json &&
- json.length) {
- dispatch(initNotaryNodesConSequence(json));
-
- return {
- type: DASHBOARD_CONNECT_NOTARIES,
- total: json.length - 1,
- current: 0,
- name: json[0],
- }
- }
-}
-
-export function startIguanaInstance(mode, coin) {
- return new Promise((resolve, reject) => {
- fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({
- mode,
- coin
- }),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'startIguanaInstance', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => resolve(json))
- });
-}
-
-export function getIguanaInstancesList() {
- return new Promise((resolve, reject) => {
- fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks', {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json',
- },
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'getIguanaInstanceList', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => resolve(json))
- });
-}
-
-export function restartIguanaInstance(pmid) {
- return new Promise((resolve, reject) => {
- fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks/restart?pmid=' + pmid, {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json',
- },
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'restartIguanaInstance', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => resolve(json))
- });
-}
-
-export function restartBasiliskInstance() {
- return dispatch => {
- getIguanaInstancesList()
- .then(function(json) {
- for (let port in json.result) {
- if (json.result[port].mode === 'basilisk') {
- restartIguanaInstance(json.result[port].pmid)
- .then(function(json) {
- console.log('restartBasiliskInstance', json);
- });
- }
- }
- });
- }
-}
-
-export function resolveOpenAliasAddress(email) {
- const url = email.replace('@', '.');
-
- return new Promise((resolve, reject) => {
- fetch('https://dns.google.com/resolve?name=' + url + '&type=txt', {
- method: 'GET',
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'resolveOpenAliasAddress', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => resolve(json))
- });
-}
-
-export function connectNotaries() {
- const payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': 'dpow',
- 'method': 'notarychains',
- };
-
- 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, 'connectNotaries', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => dispatch(connectAllNotaryNodes(json, dispatch)))
- }
-}
-
-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) => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'iguanaUTXORawTX',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'iguanaUTXORawTX', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- resolve(json);
- })
- });
-}
-
-export function dexSendRawTX(data) {
- const payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'agent': 'dex',
- 'method': 'sendrawtransaction',
- 'signedtx': data.signedtx,
- 'symbol': data.coin
- };
-
- return new Promise((resolve, reject) => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'dexSendRawTX',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'dexSendRawTX', 'Error', 'error'));
- })
- .then(function(response) {
- const _response = response.text().then(function(text) { return text; });
-
- return _response;
- })
- .then(function(json) {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- resolve(json);
- })
- });
-}
-
-export function edexGetTransaction(data) {
- const payload = {
- 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
- 'symbol': data.coin,
- 'agent': 'dex',
- 'method': 'gettransaction',
- 'vout': 1,
- 'txid': data.txid
- };
-
- return new Promise((resolve, reject) => {
- const _timestamp = Date.now();
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'function': 'edexGetTransaction',
- 'type': 'post',
- 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
- 'payload': payload,
- 'status': 'pending',
- }));
-
- fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
- method: 'POST',
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'error',
- 'response': error,
- }));
- dispatch(triggerToaster(true, 'edexGetTransaction', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => {
- dispatch(logGuiHttp({
- 'timestamp': _timestamp,
- 'status': 'success',
- 'response': json,
- }));
- resolve(json);
- })
- });
-}
-
-export function saveAppConfig(_payload) {
- return dispatch => {
- return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/appconf', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({ 'payload': _payload }),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'saveAppConfig', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => dispatch(getAppConfig()))
- }
-}
-
-function getAppConfigState(json) {
- return {
- type: LOAD_APP_CONFIG,
- config: json,
- }
-}
-
-export function getAppConfig() {
- return dispatch => {
- return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/appconf', {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json',
- },
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'getAppConfig', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => dispatch(getAppConfigState(json)))
- }
-}
-
-function getSyncOnlyForksState(json) {
- return {
- type: SYNC_ONLY_DATA,
- forks: JSON.parse(json.result),
- }
-}
-
-export function getSyncOnlyForks() {
- return dispatch => {
- return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks/info/show', {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json',
- },
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'getSyncOnlyForks', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => dispatch(getSyncOnlyForksState(json)))
- }
-}
-
-export function stopIguanaFork(pmid) {
- return dispatch => {
- return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks/stop?pmid=' + pmid, {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json',
- },
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'stopIguanaFork', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => dispatch(triggerToaster(true, 'Iguana instance is stopped', translate('TOASTR.SERVICE_NOTIFICATION'), 'success')))
- }
-}
-
-export function shepherdGetCoinList() {
- return new Promise((resolve, reject) => {
- fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/coinslist', {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json',
- },
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'shepherdGetCoinList', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => resolve(json))
- });
-}
-
-export function shepherdPostCoinList(data) {
- return new Promise((resolve, reject) => {
- fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/coinslist', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({ 'payload': data }),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'shepherdPostCoinList', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => resolve(json))
- });
-}
-
-function getAppInfoState(json) {
- return {
- type: LOAD_APP_INFO,
- info: json,
- }
-}
-
-export function getAppInfo() {
- return dispatch => {
- return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/appinfo', {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json',
- },
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'getAppInfo', 'Error', 'error'));
- })
- .then(response => response.json())
- .then(json => dispatch(getAppInfoState(json)))
- }
-}
-
-export function logGuiHttp(payload) {
- return dispatch => {
- dispatch(guiLogState(payload));
-
- // disabled for now
- /*return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/guilog', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify(payload),
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'logGuiHttp', 'Error', 'error'));
- })
- .then(response => response.json())*/
- }
-}
-
-export function getAgamaLog(type) {
- return dispatch => {
- return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/getlog?type=' + type, {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json',
- },
- })
- .catch(function(error) {
- console.log(error);
- dispatch(triggerToaster(true, 'getAgamaLog', 'Error', 'error'));
- })
- .then(response => response.json())
- .then()
- }
-}
-
-export function guiLogState(logData) {
- return {
- type: LOG_GUI_HTTP,
- timestamp: logData.timestamp,
- log: {
- function: logData.function,
- httpMethod: logData.type,
- url: logData.url,
- payload: logData.payload,
- status: logData.status,
- response: logData.response,
- }
- }
}
\ No newline at end of file
diff --git a/react/src/actions/addCoin.js b/react/src/actions/addCoin.js
new file mode 100644
index 0000000..dfa13a0
--- /dev/null
+++ b/react/src/actions/addCoin.js
@@ -0,0 +1,254 @@
+import * as storeType from './storeType';
+import { translate } from '../translate/translate';
+import {
+ triggerToaster,
+ Config,
+ toggleAddcoinModal,
+ getDexCoins
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+import {
+ startCurrencyAssetChain,
+ startAssetChain,
+ startCrypto,
+ checkCoinType,
+ checkAC
+} from '../components/addcoin/payload';
+
+export function addCoin(coin, mode, syncOnly, port) {
+ if (mode === '-1') {
+ return dispatch => {
+ dispatch(shepherdGetConfig(coin, mode));
+ }
+ } else {
+ if (checkCoinType(coin) === 'currency_ac') {
+ const _acData = startCurrencyAssetChain('', coin, mode);
+
+ return dispatch => {
+ dispatch(iguanaAddCoin(coin, mode, _acData));
+ }
+ }
+ if (checkCoinType(coin) === 'ac') {
+ const _acData = startAssetChain('', coin, mode);
+
+ return dispatch => {
+ dispatch(iguanaAddCoin(coin, mode, _acData));
+ }
+ }
+ if (checkCoinType(coin) === 'crypto') {
+ const _acData = startCrypto('', coin, mode);
+
+ if (syncOnly) {
+ const modeToValue = {
+ '1': 'full',
+ '0': 'basilisk',
+ '-1': 'native'
+ };
+
+ return dispatch => {
+ startIguanaInstance(modeToValue[mode] + '/sync', coin)
+ .then(function(json) {
+ setTimeout(function() {
+ console.log('started ' + coin + ' / ' + modeToValue[mode] + ' fork', json);
+ dispatch(iguanaAddCoin(coin, mode, _acData, json.result));
+ }, 2000);
+ });
+ }
+ } else {
+ if (port) {
+ return dispatch => {
+ dispatch(iguanaAddCoin(coin, mode, _acData, port));
+ }
+ } else {
+ return dispatch => {
+ dispatch(iguanaAddCoin(coin, mode, _acData));
+ }
+ }
+ }
+ }
+ }
+}
+
+export function iguanaAddCoin(coin, mode, acData, port) {
+ function _iguanaAddCoin(dispatch) {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'iguanaAddCoin',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + (port ? port : Config.iguanaCorePort),
+ 'payload': acData,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + (port ? port : Config.iguanaCorePort), {
+ method: 'POST',
+ body: JSON.stringify(acData),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, translate('TOASTR.FAILED_TO_ADDCOIN'), translate('TOASTR.ACCOUNT_NOTIFICATION'), 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ dispatch(addCoinResult(coin, mode, acData));
+ });
+ }
+
+ if (mode === 0) {
+ return dispatch => {
+ return _iguanaAddCoin(dispatch);
+ }
+ } else {
+ return dispatch => {
+ return _iguanaAddCoin(dispatch);
+ }
+ }
+}
+
+export function shepherdHerd(coin, mode, path) {
+ let acData;
+ let herdData = {
+ 'ac_name': coin,
+ 'ac_options': [
+ '-daemon=0',
+ '-server',
+ '-ac_name=' + coin,
+ '-addnode=78.47.196.146'
+ ]
+ };
+
+ if (coin === 'ZEC') {
+ herdData = {
+ 'ac_name': 'zcashd',
+ 'ac_options': [
+ '-daemon=0',
+ '-server=1'
+ ]
+ };
+ }
+
+ if (coin === 'KMD') {
+ herdData = {
+ 'ac_name': 'komodod',
+ 'ac_options': [
+ '-daemon=0',
+ '-addnode=78.47.196.146'
+ ]
+ };
+ }
+
+ if (checkCoinType(coin) === 'crypto') {
+ acData = startCrypto(path.result, coin, mode);
+ }
+ if (checkCoinType(coin) === 'currency_ac') {
+ acData = startCurrencyAssetChain(path.result, coin, mode);
+ }
+ if (checkCoinType(coin) === 'ac') {
+ acData = startAssetChain(path.result, coin, mode);
+ const supply = startAssetChain(path.result, coin, mode, true);
+ herdData.ac_options.push('-ac_supply=' + supply);
+ }
+
+ console.log('herdData', herdData);
+ return dispatch => {
+ return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/herd', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({
+ 'herd': coin !== 'ZEC' ? 'komodod' : 'zcashd',
+ 'options': herdData
+ }),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, translate('FAILED_SHEPHERD_HERD'), translate('TOASTR.SERVICE_NOTIFICATION'), 'error'));
+ })
+ .then(response => response.json())
+ .then(json => dispatch(iguanaAddCoin(coin, mode, acData)));
+ }
+}
+
+export function addCoinResult(coin, mode) {
+ const modeToValue = {
+ '1': 'full',
+ '0': 'basilisk',
+ '-1': 'native'
+ };
+
+ return dispatch => {
+ dispatch(triggerToaster(true, coin + ' ' + translate('TOASTR.STARTED_IN') + ' ' + modeToValue[mode] + ' ' + translate('TOASTR.MODE'), translate('TOASTR.COIN_NOTIFICATION'), 'success'));
+ dispatch(toggleAddcoinModal(false, false));
+ dispatch(getDexCoins());
+ }
+}
+
+export function _shepherdGetConfig(coin, mode) {
+ return dispatch => {
+ return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/getconf', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({ 'chain': 'komodod' })
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'Failed to get mode config', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => dispatch(shepherdHerd(coin, mode, json)));
+ }
+}
+
+export function shepherdGetConfig(coin, mode) {
+ if (coin === 'KMD' &&
+ mode === '-1') {
+ return dispatch => {
+ return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/getconf', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({ 'chain': 'komodod' })
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'Failed to get KMD config', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => dispatch(shepherdHerd(coin, mode, json)))
+ }
+ } else {
+ return dispatch => {
+ return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/getconf', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({ 'chain': coin })
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'Failed to get mode config', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => dispatch(shepherdHerd(coin, mode, json)));
+ }
+ }
+}
\ No newline at end of file
diff --git a/react/src/actions/addressBalance.js b/react/src/actions/addressBalance.js
new file mode 100644
index 0000000..8bf3e5f
--- /dev/null
+++ b/react/src/actions/addressBalance.js
@@ -0,0 +1,345 @@
+import * as storeType from './storeType';
+import {
+ triggerToaster,
+ Config,
+ shepherdGroomPost,
+ getPassthruAgent
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+function getKMDAddressesNativeState(json) {
+ return {
+ type: storeType.ACTIVE_COIN_GET_ADDRESSES,
+ addresses: json,
+ }
+}
+
+export function getKMDAddressesNative(coin, mode, currentAddress) {
+ const type = ['public', 'private'];
+
+ if (mode !== 'native') {
+ type.pop();
+ }
+
+ return dispatch => {
+ Promise.all(type.map((_type, index) => {
+ return new Promise((resolve, reject) => {
+ let payload,
+ ajax_data_to_hex = '',
+ ajax_function_input = '',
+ tmplistaddr_hex_input = '',
+ passthru_agent = getPassthruAgent(coin),
+ tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth');
+
+ if (_type === 'public') {
+ ajax_function_input = 'getaddressesbyaccount';
+ tmplistaddr_hex_input = '222200';
+ }
+ if (_type === 'private') {
+ ajax_function_input = 'z_listaddresses';
+ tmplistaddr_hex_input = '';
+ }
+
+ if (passthru_agent === 'iguana') {
+ payload = {
+ 'userpass': tmpIguanaRPCAuth,
+ 'agent': passthru_agent,
+ 'method': 'passthru',
+ 'asset': coin,
+ 'function': ajax_function_input,
+ 'hex': tmplistaddr_hex_input,
+ };
+ } else {
+ payload = {
+ 'userpass': tmpIguanaRPCAuth,
+ 'agent': passthru_agent,
+ 'method': 'passthru',
+ 'function': ajax_function_input,
+ 'hex': tmplistaddr_hex_input,
+ };
+ }
+
+ if (mode === 'full' || mode === 'basilisk') {
+ payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'coin': coin,
+ 'agent': 'bitcoinrpc',
+ 'method': 'getaddressesbyaccount',
+ 'account': '*',
+ };
+ }
+
+ if (mode === 'basilisk') {
+ const pubkey = JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey;
+
+ fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/cache?pubkey=' + pubkey, {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'getKMDAddressesNative+addresslist+cache', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(function(json) {
+ json = json.result.basilisk;
+
+ if (json[coin].addresses) {
+ resolve({ 'result': json[coin].addresses });
+ }
+ })
+ } else {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'getKMDAddressesNative',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'getKMDAddressesNative', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ resolve(json);
+ })
+ }
+ });
+ }))
+ .then(result => {
+ // TODO: split into 2 functions
+ const passthru_agent = getPassthruAgent(coin),
+ tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth');
+ let payload;
+
+ if (passthru_agent === 'iguana') {
+ payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': passthru_agent,
+ 'method': 'passthru',
+ 'asset': coin,
+ 'function': 'listunspent',
+ 'hex': '',
+ };
+ } else {
+ payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': passthru_agent,
+ 'method': 'passthru',
+ 'function': 'listunspent',
+ 'hex': '',
+ };
+ }
+
+ if (mode === 'full') {
+ payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'coin': coin,
+ 'method': 'listunspent',
+ 'params': [
+ 1,
+ 9999999,
+ ],
+ };
+ }
+
+ // if api cache option is off
+ if (mode === 'basilisk') {
+ payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': 'dex',
+ 'method': 'listunspent',
+ 'address': currentAddress,
+ 'symbol': coin,
+ };
+ }
+
+ function calcBalance(result, json, dispatch, mode) {
+ if (mode === 'full' ||
+ mode === 'basilisk') {
+ result[0] = result[0].result;
+ }
+
+ if (mode !== 'basilisk' &&
+ json &&
+ json.length) {
+ const allAddrArray = json.map(res => res.address).filter((x, i, a) => a.indexOf(x) == i);
+
+ for (let a = 0; a < allAddrArray.length; a++) {
+ const filteredArray = json.filter(res => res.address === allAddrArray[a]).map(res => res.amount);
+
+ let isNewAddr = true;
+ for (let x = 0; x < result.length && isNewAddr; x++) {
+ for (let y=0; y < result[x].length && isNewAddr; y++) {
+ if (allAddrArray[a] === result[x][y]) {
+ isNewAddr = false;
+ }
+ }
+ }
+
+ if (isNewAddr) {
+ if (allAddrArray[a].substring(0, 2) === 'zc' ||
+ allAddrArray[a].substring(0, 2) === 'zt') {
+ result[1][result[1].length] = allAddrArray[a];
+ } else {
+ result[0][result[0].length] = allAddrArray[a];
+ }
+ }
+ }
+ }
+
+ let newAddressArray = [];
+
+ for (let a = 0; a < result.length; a++) {
+ newAddressArray[a] = [];
+
+ for (let b = 0; b < result[a].length; b++) {
+ var filteredArray;
+
+ if (mode === 'basilisk') {
+ filteredArray = json.map(res => res.amount);
+ } else {
+ filteredArray = json.filter(res => res.address === result[a][b]).map(res => res.amount);
+ }
+
+ let sum = 0;
+
+ for (let i=0; i < filteredArray.length; i++) {
+ sum += filteredArray[i];
+ }
+
+ newAddressArray[a][b] = {
+ address: result[a][b],
+ amount: currentAddress === result[a][b] || mode === 'native' ? sum : 'N/A',
+ };
+ }
+ }
+
+ dispatch(getKMDAddressesNativeState({
+ 'public': newAddressArray[0],
+ 'private': newAddressArray[1]
+ }));
+ }
+
+ if (mode === 'basilisk') {
+ const pubkey = JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey;
+
+ fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/cache?pubkey=' + pubkey, {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'getKMDAddressesNative+addresslist+cache', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(function(json) {
+ let updatedCache = Object.assign({}, json.result);
+ json = json.result.basilisk;
+ // if listunspent is not in cache file retrieve new copy
+ // otherwise read from cache data
+ if (json[coin][currentAddress].refresh) {
+ calcBalance(result, json[coin][currentAddress].refresh.data, dispatch, mode);
+ } else {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'getKMDAddressesNative+Balance',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + (Config.useBasiliskInstance && mode === 'basilisk' ? Config.iguanaCorePort + 1 : Config.iguanaCorePort),
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ fetch('http://127.0.0.1:' + (Config.useBasiliskInstance && mode === 'basilisk' ? Config.iguanaCorePort + 1 : Config.iguanaCorePort), {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'getKMDAddressesNative+Balance', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(function(json) {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ updatedCache.basilisk[coin][currentAddress].refresh = {
+ 'data': json,
+ 'status': 'done',
+ 'timestamp': Date.now(),
+ };
+ dispatch(shepherdGroomPost(pubkey, updatedCache));
+ calcBalance(result, json, dispatch, mode);
+ })
+ }
+ })
+ } else {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'getKMDAddressesNative+Balance',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + (Config.useBasiliskInstance && mode === 'basilisk' ? Config.iguanaCorePort + 1 : Config.iguanaCorePort),
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ fetch('http://127.0.0.1:' + (Config.useBasiliskInstance && mode === 'basilisk' ? Config.iguanaCorePort + 1 : Config.iguanaCorePort), {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'getKMDAddressesNative+Balance', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(function(json) {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ calcBalance(result, json, dispatch, mode);
+ })
+ }
+ })
+ }
+}
\ No newline at end of file
diff --git a/react/src/actions/atomic.js b/react/src/actions/atomic.js
new file mode 100644
index 0000000..7f10461
--- /dev/null
+++ b/react/src/actions/atomic.js
@@ -0,0 +1,53 @@
+import * as storeType from './storeType';
+import {
+ triggerToaster,
+ Config
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+export function atomic(payload) {
+ return dispatch => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'atomic',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, payload.method, 'Atomic Explorer error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ dispatch(atomicState(json));
+ });
+ }
+}
+
+function atomicState(json) {
+ return {
+ type: storeType.ATOMIC,
+ response: json,
+ }
+}
\ No newline at end of file
diff --git a/react/src/actions/basiliskCache.js b/react/src/actions/basiliskCache.js
new file mode 100644
index 0000000..588df6c
--- /dev/null
+++ b/react/src/actions/basiliskCache.js
@@ -0,0 +1,175 @@
+import * as storeType from './storeType';
+import {
+ triggerToaster,
+ Config
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+export function deleteCacheFile(_payload) {
+ return dispatch => {
+ return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/groom?', {
+ method: 'DELETE',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({ 'filename': _payload.pubkey }),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'deleteCacheFile', 'Error', 'error'))
+ })
+ .then(response => response.json())
+ .then(json => dispatch(fetchNewCacheData(_payload)));
+ }
+}
+
+export function getCacheFile(pubkey) {
+ const _pubkey = pubkey || JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey;
+
+ return new Promise((resolve, reject) => {
+ fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/groom?filename=' + _pubkey, {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'getCacheFile', 'Error', 'error'))
+ })
+ .then(response => response.json())
+ .then(json => resolve(json))
+ })
+}
+
+export function fetchNewCacheData(_payload) {
+ const _userpass = '?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ _pubkey = '&pubkey=' + _payload.pubkey,
+ _route = _payload.allcoins ? 'cache-all' : 'cache-one',
+ _coin = '&coin=' + _payload.coin,
+ _calls = '&calls=' + _payload.calls,
+ _address = _payload.address ? ('&address=' + _payload.address) : '',
+ _iguanaInstancePort = Config.useBasiliskInstance ? '&port=' + (Config.iguanaCorePort + 1) : '';
+
+ return dispatch => {
+ return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/' + _route + _userpass + _pubkey + _coin + _calls + _address + _iguanaInstancePort, {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'fetchNewCacheData', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => console.log(json))
+ }
+}
+
+export function getShepherdCache(pubkey, coin) {
+ return dispatch => {
+ return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/cache?pubkey=' + pubkey, {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'getShepherdCache', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => dispatch(getShepherdCacheState(json, pubkey, coin)))
+ }
+}
+
+function getShepherdCacheState(json, pubkey, coin) {
+ if (json.result &&
+ json.error &&
+ json.result.indexOf('no file with handle') > -1) {
+ return dispatch => {
+ dispatch(fetchNewCacheData({
+ 'pubkey': pubkey,
+ 'allcoins': false,
+ 'coin': coin,
+ 'calls': 'listtransactions:getbalance',
+ }));
+ }
+ } else {
+ return {
+ type: storeType.DASHBOARD_ACTIVE_COIN_GET_CACHE,
+ cache: json && json.result && json.result.basilisk ? json.result.basilisk : null,
+ }
+ }
+}
+
+export function fetchUtxoCache(_payload) {
+ const _userpass = '?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ _pubkey = '&pubkey=' + _payload.pubkey,
+ _route = _payload.allcoins ? 'cache-all' : 'cache-one',
+ _coin = '&coin=' + _payload.coin,
+ _calls = '&calls=' + _payload.calls,
+ _address = _payload.address ? ('&address=' + _payload.address) : '',
+ _iguanaInstancePort = Config.useBasiliskInstance ? '&port=' + (Config.iguanaCorePort + 1) : '';
+
+ return dispatch => {
+ return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/' + _route + _userpass + _pubkey + _coin + _calls + _address + _iguanaInstancePort, {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'fetchNewCacheData', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => dispatch(getShepherdCache(_pubkey)))
+ }
+}
+
+export function shepherdGroomPost(_filename, _payload) {
+ return dispatch => {
+ return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/groom/', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({
+ 'filename': _filename,
+ 'payload': JSON.stringify(_payload),
+ }),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'shepherdGroomPost', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => console.log(json))
+ }
+}
+
+export function shepherdGroomPostPromise(_filename, _payload) {
+ return new Promise((resolve, reject) => {
+ fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/groom/', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({
+ 'filename': _filename,
+ 'payload': JSON.stringify(_payload),
+ }),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'shepherdGroomPostPromise', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => resolve(json))
+ })
+}
\ No newline at end of file
diff --git a/react/src/actions/basiliskProcessAddress.js b/react/src/actions/basiliskProcessAddress.js
new file mode 100644
index 0000000..fe1582f
--- /dev/null
+++ b/react/src/actions/basiliskProcessAddress.js
@@ -0,0 +1,134 @@
+import * as storeType from './storeType';
+import { translate } from '../translate/translate';
+import {
+ triggerToaster,
+ Config
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+export function checkAddressBasilisk(coin, address) {
+ const payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': 'dex',
+ 'method': 'checkaddress',
+ 'address': address,
+ 'symbol': coin,
+ };
+
+ return dispatch => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'checkAddressBasilisk',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort),
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort), {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'checkAddressBasilisk', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ dispatch(checkAddressBasiliskHandle(json));
+ })
+ }
+}
+
+function checkAddressBasiliskHandle(json) {
+ if (json &&
+ json.error) {
+ return dispatch => {
+ dispatch(triggerToaster(true, json.error, translate('TOASTR.WALLET_NOTIFICATION'), 'error'));
+ }
+ }
+
+ if (json &&
+ json.coin &&
+ json.randipbits) {
+ return dispatch => {
+ dispatch(triggerToaster(true, 'Address already registered', translate('TOASTR.WALLET_NOTIFICATION'), 'warning'));
+ }
+ }
+}
+
+export function validateAddressBasilisk(coin, address) {
+ const payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': 'dex',
+ 'method': 'validateaddress',
+ 'address': address,
+ 'symbol': coin,
+ };
+
+ return dispatch => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'validateAddressBasilisk',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort), {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'validateAddressBasilisk', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ dispatch(validateAddressBasiliskHandle(json));
+ })
+ }
+}
+
+function validateAddressBasiliskHandle(json) {
+ return dispatch => {
+ if (json.iswatchonly === true) {
+ dispatch(triggerToaster(true, translate('TOASTR.VALIDATION_SUCCESS'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error'));
+ }
+ if (json.iswatchonly === false) {
+ dispatch(triggerToaster(true, translate('TOASTR.ADDR_ISNT_REG'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error'));
+ }
+ if (json.iswatchonly === undefined) {
+ dispatch(triggerToaster(true, translate('TOASTR.INVALID_QUERY_ALT'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error'));
+ }
+ if (json.error === 'less than required responses') {
+ dispatch(triggerToaster(true, translate('TOASTR.LESS_RESPONSES_REQ'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error'));
+ }
+ }
+}
\ No newline at end of file
diff --git a/react/src/actions/basiliskTxHistory.js b/react/src/actions/basiliskTxHistory.js
new file mode 100644
index 0000000..50d38f4
--- /dev/null
+++ b/react/src/actions/basiliskTxHistory.js
@@ -0,0 +1,40 @@
+import * as storeType from './storeType';
+import {
+ triggerToaster,
+ Config,
+ getNativeTxHistoryState
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+export function getBasiliskTransactionsList(coin, address) {
+ const pubkey = JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey;
+
+ return dispatch => {
+ return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/cache?pubkey=' + pubkey, {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'getBasiliskTransactionsList+cache', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(function(json) {
+ if (json.result &&
+ !json.result.basilisk &&
+ json.result.indexOf('no file with handle') > -1) {
+ console.log('new cache');
+ }
+
+ json = json.result.basilisk;
+ if (json[coin][address].listtransactions) {
+ dispatch(getNativeTxHistoryState({ 'result': json[coin][address].listtransactions.data }));
+ }
+ })
+ }
+}
\ No newline at end of file
diff --git a/react/src/actions/coinList.js b/react/src/actions/coinList.js
new file mode 100644
index 0000000..0e4f31b
--- /dev/null
+++ b/react/src/actions/coinList.js
@@ -0,0 +1,44 @@
+import * as storeType from './storeType';
+import {
+ triggerToaster,
+ Config
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+export function shepherdGetCoinList() {
+ return new Promise((resolve, reject) => {
+ fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/coinslist', {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'shepherdGetCoinList', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => resolve(json))
+ });
+}
+
+export function shepherdPostCoinList(data) {
+ return new Promise((resolve, reject) => {
+ fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/coinslist', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({ 'payload': data }),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'shepherdPostCoinList', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => resolve(json))
+ });
+}
\ No newline at end of file
diff --git a/react/src/actions/copyAddress.js b/react/src/actions/copyAddress.js
new file mode 100644
index 0000000..3b4dd3d
--- /dev/null
+++ b/react/src/actions/copyAddress.js
@@ -0,0 +1,21 @@
+import { copyToClipboard } from '../util/copyToClipboard';
+import { translate } from '../translate/translate';
+import * as storeType from './storeType';
+import {
+ triggerToaster,
+ Config
+} from './actionCreators';
+
+export function copyCoinAddress(address) {
+ const _result = copyToClipboard(address);
+
+ if (_result) {
+ return dispatch => {
+ dispatch(triggerToaster(true, translate('DASHBOARD.ADDR_COPIED'), translate('TOASTR.COIN_NOTIFICATION'), 'success'));
+ }
+ } else {
+ return dispatch => {
+ dispatch(triggerToaster(true, 'Couldn\'t copy address to clipboard', translate('TOASTR.COIN_NOTIFICATION'), 'error'));
+ }
+ }
+}
\ No newline at end of file
diff --git a/react/src/actions/createWallet.js b/react/src/actions/createWallet.js
new file mode 100644
index 0000000..425a2b6
--- /dev/null
+++ b/react/src/actions/createWallet.js
@@ -0,0 +1,68 @@
+import * as storeType from './storeType';
+import { translate } from '../translate/translate';
+import {
+ triggerToaster,
+ Config
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+function createNewWalletState(json) {
+ if (json &&
+ json.result &&
+ json.result === 'success') {
+ return dispatch => {
+ dispatch(triggerToaster(true, translate('TOASTR.WALLET_CREATED_SUCCESFULLY'), translate('TOASTR.ACCOUNT_NOTIFICATION'), 'success'));
+ }
+ } else {
+ return dispatch => {
+ dispatch(triggerToaster(true, 'Couldn\'t create new wallet seed', translate('TOASTR.ACCOUNT_NOTIFICATION'), 'error'));
+ }
+ }
+}
+
+export function createNewWallet(_passphrase) {
+ const payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': 'bitcoinrpc',
+ 'method': 'encryptwallet',
+ 'passphrase': _passphrase,
+ };
+
+ return dispatch => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'createNewWallet',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'createNewWallet', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ dispatch(createNewWalletState(json));
+ })
+ }
+}
\ No newline at end of file
diff --git a/react/src/actions/dexCoins.js b/react/src/actions/dexCoins.js
new file mode 100644
index 0000000..7f10dd2
--- /dev/null
+++ b/react/src/actions/dexCoins.js
@@ -0,0 +1,53 @@
+import * as storeType from './storeType';
+import {
+ triggerToaster,
+ Config,
+ dashboardCoinsState
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+export function getDexCoins() {
+ const _payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': 'InstantDEX',
+ 'method': 'allcoins',
+ };
+
+ return dispatch => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'getDexCoins',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': _payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(_payload)
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'Error getDexCoins', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ dispatch(dashboardCoinsState(json));
+ });
+ }
+}
\ No newline at end of file
diff --git a/react/src/actions/edexBalance.js b/react/src/actions/edexBalance.js
new file mode 100644
index 0000000..b760791
--- /dev/null
+++ b/react/src/actions/edexBalance.js
@@ -0,0 +1,107 @@
+import * as storeType from './storeType';
+import {
+ triggerToaster,
+ Config
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+export function iguanaEdexBalance(coin) {
+ const _payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': 'bitcoinrpc',
+ 'method': 'getbalance',
+ 'coin': coin,
+ };
+
+ return dispatch => {
+ if (coin) {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'iguanaEdexBalance',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': _payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(_payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'Error iguanaEdexBalance', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => dispatch(iguanaEdexBalanceState(json)));
+ }
+ }
+}
+
+function iguanaEdexBalanceState(json) {
+ return {
+ type: storeType.DASHBOARD_ACTIVE_COIN_BALANCE,
+ balance: json && json.result ? json.result : 0,
+ }
+}
+
+export function getDexBalance(coin, mode, addr) {
+ Promise.all(addr.map((_addr, index) => {
+ const payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': 'dex',
+ 'method': 'listunspent',
+ 'address': _addr,
+ 'symbol': coin,
+ };
+
+ return new Promise((resolve, reject) => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'getDexBalance',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort),
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ fetch('http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort), {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'getDexBalance', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ console.log(json);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ })
+
+ resolve(index);
+ });
+ }))
+ .then(result => {
+ console.log(result);
+ });
+}
\ No newline at end of file
diff --git a/react/src/actions/edexGetTx.js b/react/src/actions/edexGetTx.js
new file mode 100644
index 0000000..8cd1139
--- /dev/null
+++ b/react/src/actions/edexGetTx.js
@@ -0,0 +1,55 @@
+import * as storeType from './storeType';
+import {
+ triggerToaster,
+ Config
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+export function edexGetTransaction(data) {
+ const payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'symbol': data.coin,
+ 'agent': 'dex',
+ 'method': 'gettransaction',
+ 'vout': 1,
+ 'txid': data.txid
+ };
+
+ return new Promise((resolve, reject) => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'edexGetTransaction',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'edexGetTransaction', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ resolve(json);
+ })
+ });
+}
diff --git a/react/src/actions/fullTxHistory.js b/react/src/actions/fullTxHistory.js
new file mode 100644
index 0000000..f73492e
--- /dev/null
+++ b/react/src/actions/fullTxHistory.js
@@ -0,0 +1,58 @@
+import * as storeType from './storeType';
+import {
+ triggerToaster,
+ Config,
+ getNativeTxHistoryState
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+export function getFullTransactionsList(coin) {
+ const payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'coin': coin,
+ 'method': 'listtransactions',
+ 'params': [
+ 0,
+ 9999999,
+ []
+ ],
+ };
+
+ return dispatch => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'getFullTransactionsList',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'getFullTransactionsList', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ dispatch(getNativeTxHistoryState(json));
+ })
+ }
+}
\ No newline at end of file
diff --git a/react/src/actions/getAddrByAccount.js b/react/src/actions/getAddrByAccount.js
new file mode 100644
index 0000000..f1238d0
--- /dev/null
+++ b/react/src/actions/getAddrByAccount.js
@@ -0,0 +1,76 @@
+import * as storeType from './storeType';
+import {
+ triggerToaster,
+ Config
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+export function getAddressesByAccountState(json, coin, mode) {
+ if (mode === 'full' ||
+ mode === 'basilisk') {
+ let publicAddressArray = [];
+
+ for (let i = 0; i < json.result.length; i++) {
+ publicAddressArray.push({
+ 'address': json.result[i],
+ 'amount': 'N/A'
+ });
+ }
+
+ json.result = publicAddressArray;
+ }
+
+ return {
+ type: storeType.ACTIVE_COIN_GET_ADDRESSES,
+ addresses: { 'public': json.result },
+ }
+}
+
+export function getAddressesByAccount(coin, mode) {
+ const payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'coin': coin,
+ 'agent': 'bitcoinrpc',
+ 'method': 'getaddressesbyaccount',
+ 'account': '*',
+ };
+
+ return dispatch => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'getAddressesByAccount',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(updateErrosStack('activeHandle'));
+ dispatch(triggerToaster(true, 'getAddressesByAccount', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ dispatch(getAddressesByAccountState(json, coin, mode));
+ })
+ }
+}
\ No newline at end of file
diff --git a/react/src/actions/iguanaHelpers.js b/react/src/actions/iguanaHelpers.js
new file mode 100644
index 0000000..97b8371
--- /dev/null
+++ b/react/src/actions/iguanaHelpers.js
@@ -0,0 +1,66 @@
+import * as storeType from './storeType';
+import {
+ triggerToaster,
+ Config
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+import { checkAC } from '../components/addcoin/payload';
+
+export function getPassthruAgent(coin) {
+ let passthruAgent;
+
+ if (coin === 'KMD') { passthruAgent = 'komodo'; };
+ if (coin === 'ZEC') { passthruAgent = 'zcash'; };
+
+ if (checkAC(coin)) { passthruAgent = 'iguana'; };
+
+ return passthruAgent;
+}
+
+export function iguanaHashHex(data, dispatch) {
+ const payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': 'hash',
+ 'method': 'hex',
+ 'message': data,
+ };
+
+ return new Promise((resolve, reject) => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'iguanaHashHex',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'iguanaHashHex', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ resolve(json.hex);
+ })
+ })
+}
+
diff --git a/react/src/actions/iguanaInstance.js b/react/src/actions/iguanaInstance.js
new file mode 100644
index 0000000..4a6adfd
--- /dev/null
+++ b/react/src/actions/iguanaInstance.js
@@ -0,0 +1,80 @@
+import * as storeType from './storeType';
+import {
+ triggerToaster,
+ Config
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+export function restartIguanaInstance(pmid) {
+ return new Promise((resolve, reject) => {
+ fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks/restart?pmid=' + pmid, {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'restartIguanaInstance', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => resolve(json))
+ });
+}
+
+export function restartBasiliskInstance() {
+ return dispatch => {
+ getIguanaInstancesList()
+ .then(function(json) {
+ for (let port in json.result) {
+ if (json.result[port].mode === 'basilisk') {
+ restartIguanaInstance(json.result[port].pmid)
+ .then(function(json) {
+ console.log('restartBasiliskInstance', json);
+ });
+ }
+ }
+ });
+ }
+}
+
+export function startIguanaInstance(mode, coin) {
+ return new Promise((resolve, reject) => {
+ fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({
+ mode,
+ coin
+ }),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'startIguanaInstance', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => resolve(json))
+ });
+}
+
+export function getIguanaInstancesList() {
+ return new Promise((resolve, reject) => {
+ fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks', {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'getIguanaInstanceList', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => resolve(json))
+ });
+}
\ No newline at end of file
diff --git a/react/src/actions/log.js b/react/src/actions/log.js
new file mode 100644
index 0000000..51e17ba
--- /dev/null
+++ b/react/src/actions/log.js
@@ -0,0 +1,58 @@
+import * as storeType from './storeType';
+import {
+ triggerToaster,
+ Config
+} from './actionCreators';
+
+export function logGuiHttp(payload) {
+ return dispatch => {
+ dispatch(guiLogState(payload));
+
+ // disabled for now
+ /*return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/guilog', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'logGuiHttp', 'Error', 'error'));
+ })
+ .then(response => response.json())*/
+ }
+}
+
+export function getAgamaLog(type) {
+ return dispatch => {
+ return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/getlog?type=' + type, {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'getAgamaLog', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then()
+ }
+}
+
+export function guiLogState(logData) {
+ return {
+ type: storeType.LOG_GUI_HTTP,
+ timestamp: logData.timestamp,
+ log: {
+ timestamp: logData.timestamp,
+ function: logData.function,
+ httpMethod: logData.type,
+ url: logData.url,
+ payload: logData.payload,
+ status: logData.status,
+ response: logData.response,
+ }
+ }
+}
\ No newline at end of file
diff --git a/react/src/actions/logout.js b/react/src/actions/logout.js
new file mode 100644
index 0000000..bfeb1e2
--- /dev/null
+++ b/react/src/actions/logout.js
@@ -0,0 +1,67 @@
+import * as storeType from './storeType';
+import {
+ triggerToaster,
+ Config
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+function logoutState(json, dispatch) {
+ sessionStorage.removeItem('IguanaActiveAccount');
+
+ return {
+ type: storeType.LOGIN,
+ isLoggedIn: false,
+ }
+}
+
+export function logout() {
+ return dispatch => {
+ dispatch(walletLock());
+ }
+}
+
+function walletLock() {
+ const payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': 'bitcoinrpc',
+ 'method': 'walletlock',
+ };
+
+ return dispatch => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'walletLock',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'walletLock', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ dispatch(logoutState(json));
+ })
+ }
+}
\ No newline at end of file
diff --git a/react/src/actions/nativeBalance.js b/react/src/actions/nativeBalance.js
new file mode 100644
index 0000000..f8931b2
--- /dev/null
+++ b/react/src/actions/nativeBalance.js
@@ -0,0 +1,79 @@
+import * as storeType from './storeType';
+import {
+ triggerToaster,
+ Config,
+ getPassthruAgent
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+export function getKMDBalanceTotal(coin) {
+ let payload;
+
+ if (coin !== 'KMD' &&
+ coin !== 'ZEC') {
+ payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': 'iguana',
+ 'method': 'passthru',
+ 'asset': coin,
+ 'function': 'z_gettotalbalance',
+ 'hex': '3000',
+ };
+ } else {
+ payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': getPassthruAgent(coin),
+ 'method': 'passthru',
+ 'function': 'z_gettotalbalance',
+ 'hex': '3000',
+ };
+ }
+
+ return dispatch => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'getKMDBalanceTotal',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'getKMDBalanceTotal', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(function(json) { // TODO: figure out why komodod spits out "parse error"
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ if (json &&
+ !json.error) {
+ dispatch(getNativeBalancesState(json));
+ }
+ })
+ }
+}
+
+export function getNativeBalancesState(json) {
+ return {
+ type: storeType.DASHBOARD_ACTIVE_COIN_NATIVE_BALANCE,
+ balance: json && !json.error ? json : 0,
+ }
+}
\ No newline at end of file
diff --git a/react/src/actions/nativeNewAddress.js b/react/src/actions/nativeNewAddress.js
new file mode 100644
index 0000000..93f3425
--- /dev/null
+++ b/react/src/actions/nativeNewAddress.js
@@ -0,0 +1,87 @@
+import * as storeType from './storeType';
+import { translate } from '../translate/translate';
+import {
+ triggerToaster,
+ Config,
+ getPassthruAgent
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+function handleGetNewKMDAddresses(pubpriv, coin, dispatch) {
+ dispatch(triggerToaster(true, translate('KMD_NATIVE.NEW_ADDR_GENERATED'), translate('TOASTR.WALLET_NOTIFICATION'), 'success'));
+ dispatch(getKMDAddressesNative(coin));
+
+ return {};
+}
+
+export function getNewKMDAddresses(coin, pubpriv) {
+ let payload,
+ ajax_function_input = '';
+
+ if (pubpriv === 'public') {
+ ajax_function_input = 'getnewaddress';
+ }
+ if (pubpriv === 'private') {
+ ajax_function_input = 'z_getnewaddress';
+ }
+
+ if (getPassthruAgent(coin) === 'iguana') {
+ payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': getPassthruAgent(coin),
+ 'method': 'passthru',
+ 'asset': coin,
+ 'function': ajax_function_input,
+ 'hex': '',
+ };
+ } else {
+ payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': coin,
+ 'method': 'passthru',
+ 'function': ajax_function_input,
+ 'hex': '',
+ };
+ }
+
+ return dispatch => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'getNewKMDAddresses',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'getNewKMDAddresses', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ dispatch(handleGetNewKMDAddresses(pubpriv, coin, dispatch));
+ })
+ .catch(function(ex) {
+ dispatch(handleGetNewKMDAddresses(pubpriv, coin, dispatch))
+ })
+ }
+}
\ No newline at end of file
diff --git a/react/src/actions/nativeSend.js b/react/src/actions/nativeSend.js
new file mode 100644
index 0000000..4d005d4
--- /dev/null
+++ b/react/src/actions/nativeSend.js
@@ -0,0 +1,174 @@
+import * as storeType from './storeType';
+import { translate } from '../translate/translate';
+import {
+ triggerToaster,
+ Config,
+ getPassthruAgent,
+ iguanaHashHex
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+export function sendNativeTx(coin, _payload) {
+ let ajax_data_to_hex;
+ let payload;
+ let _apiMethod;
+
+ if (_payload.addressType === 'public') {
+ _apiMethod = 'sendtoaddress';
+ ajax_data_to_hex = '["' + _payload.sendTo + '", ' + (Number(_payload.amount) - Number(_payload.fee)) + ']';
+ } else {
+ _apiMethod = 'z_sendmany';
+ ajax_data_to_hex = '["' + _payload.sendFrom + '",[{"address":"' + _payload.sendTo + '","amount":' + (Number(_payload.amount) - Number(_payload.fee)) + '}]]';
+ }
+
+ return dispatch => {
+ return iguanaHashHex(ajax_data_to_hex, dispatch).then((hashHexJson) => {
+ if (getPassthruAgent(coin) === 'iguana') {
+ payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': getPassthruAgent(coin),
+ 'method': 'passthru',
+ 'asset': coin,
+ 'function': _apiMethod,
+ 'hex': hashHexJson,
+ };
+ } else {
+ payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': getPassthruAgent(coin),
+ 'method': 'passthru',
+ 'function': _apiMethod,
+ 'hex': hashHexJson,
+ };
+ }
+
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'sendNativeTx',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'sendNativeTx', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(function(json) {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+
+ if (json.error &&
+ json.error.toString().indexOf('code:') > -1) {
+ dispatch(triggerToaster(true, 'Send failed', translate('TOASTR.WALLET_NOTIFICATION'), 'error'));
+ } else {
+ dispatch(triggerToaster(true, translate('TOASTR.TX_SENT_ALT'), translate('TOASTR.WALLET_NOTIFICATION'), 'success'));
+ }
+ })
+ .catch(function(ex) {
+ dispatch(triggerToaster(true, translate('TOASTR.TX_SENT_ALT'), translate('TOASTR.WALLET_NOTIFICATION'), 'success'));
+ console.log('parsing failed', ex);
+ })
+ });
+ }
+}
+
+export function getKMDOPIDState(json) {
+ return {
+ type: storeType.DASHBOARD_ACTIVE_COIN_NATIVE_OPIDS,
+ opids: json,
+ }
+}
+
+export function getKMDOPID(opid, coin) {
+ let tmpopid_output = '',
+ ajax_data_to_hex;
+
+ if (opid === undefined) {
+ ajax_data_to_hex = null;
+ } else {
+ ajax_data_to_hex = '["' + opid + '"]';
+ }
+
+ return dispatch => {
+ return iguanaHashHex(ajax_data_to_hex, dispatch).then((hashHexJson) => {
+ if (hashHexJson === '5b226e756c6c225d00') {
+ hashHexJson = '';
+ }
+
+ let payload,
+ passthru_agent = getPassthruAgent(coin),
+ tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth');
+
+ if (passthru_agent == 'iguana') {
+ payload = {
+ 'userpass': tmpIguanaRPCAuth,
+ 'agent': passthru_agent,
+ 'method': 'passthru',
+ 'asset': coin,
+ 'function': 'z_getoperationstatus',
+ 'hex': hashHexJson,
+ };
+ } else {
+ payload = {
+ 'userpass': tmpIguanaRPCAuth,
+ 'agent': passthru_agent,
+ 'method': 'passthru',
+ 'function': 'z_getoperationstatus',
+ 'hex': hashHexJson,
+ };
+ }
+
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'getKMDOPID',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'getKMDOPID', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ dispatch(getKMDOPIDState(json));
+ })
+ })
+ }
+}
\ No newline at end of file
diff --git a/react/src/actions/nativeSyncInfo.js b/react/src/actions/nativeSyncInfo.js
new file mode 100644
index 0000000..18f6b26
--- /dev/null
+++ b/react/src/actions/nativeSyncInfo.js
@@ -0,0 +1,111 @@
+import * as storeType from './storeType';
+import {
+ triggerToaster,
+ Config
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+export function getSyncInfoNativeKMD(skipDebug) {
+ const coin = 'KMD';
+
+ return dispatch => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'getSyncInfoNativeKMD',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort + '/api/dex/getinfo?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth') + '&symbol=' + coin,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + Config.iguanaCorePort + '/api/dex/getinfo?userpass=tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth') + '&symbol=' + coin, {
+ method: 'GET',
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'getSyncInfoNativeKMD', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ dispatch(getSyncInfoNativeState({ 'remoteKMDNode': json }));
+ })
+ .then(function() {
+ if (!skipDebug) {
+ dispatch(getDebugLog('komodo', 1));
+ }
+ })
+ }
+}
+
+function getSyncInfoNativeState(json, coin, skipDebug) {
+ if (coin === 'KMD' &&
+ json &&
+ json.error) {
+ return getSyncInfoNativeKMD(skipDebug);
+ } else {
+ return {
+ type: storeType.SYNCING_NATIVE_MODE,
+ progress: json,
+ }
+ }
+}
+
+export function getSyncInfoNative(coin, skipDebug) {
+ const payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': getPassthruAgent(coin),
+ 'method': 'passthru',
+ 'asset': coin,
+ 'function': 'getinfo',
+ 'hex': '',
+ };
+
+ return dispatch => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'getSyncInfo',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'getSyncInfo', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ dispatch(getSyncInfoNativeState(json, coin, skipDebug));
+ })
+ }
+}
\ No newline at end of file
diff --git a/react/src/actions/nativeTxHistory.js b/react/src/actions/nativeTxHistory.js
new file mode 100644
index 0000000..2b45e07
--- /dev/null
+++ b/react/src/actions/nativeTxHistory.js
@@ -0,0 +1,69 @@
+import * as storeType from './storeType';
+import {
+ triggerToaster,
+ Config,
+ getPassthruAgent,
+ getNativeTxHistoryState
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+export function getNativeTxHistory(coin) {
+ let payload;
+
+ if (getPassthruAgent(coin) === 'iguana') {
+ payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': 'iguana',
+ 'method': 'passthru',
+ 'asset': coin,
+ 'function': 'listtransactions',
+ 'hex': '',
+ };
+ } else {
+ payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': getPassthruAgent(coin),
+ 'method': 'passthru',
+ 'function': 'listtransactions',
+ 'hex': '',
+ };
+ }
+
+ return dispatch => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'getNativeTxHistory',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'getNativeTxHistory', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ dispatch(getNativeTxHistoryState(json));
+ })
+ }
+}
\ No newline at end of file
diff --git a/react/src/actions/notary.js b/react/src/actions/notary.js
new file mode 100644
index 0000000..2582b70
--- /dev/null
+++ b/react/src/actions/notary.js
@@ -0,0 +1,175 @@
+import * as storeType from './storeType';
+import { translate } from '../translate/translate';
+import {
+ triggerToaster,
+ Config
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+function initNotaryNodesConSequence(nodes) {
+ return dispatch => {
+ Promise.all(nodes.map((node, index) => {
+ const payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': 'dex',
+ 'method': 'getinfo',
+ 'symbol': node,
+ 'timeout': 10000
+ };
+
+ return new Promise((resolve, reject) => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'initNotaryNodesConSequence+' + node,
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ fetch('http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort) + '/api/dex/getinfo?userpass=' + ('tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth')) + '&symbol=' + node, {
+ method: 'GET',
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'getInfoDexNode+' + node, 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ dispatch(updateNotaryNodeConState(json, nodes.length, index, node));
+ })
+ });
+ }));
+ }
+}
+
+function updateNotaryNodeConState(json, totalNodes, currentNodeIndex, currentNodeName) {
+ if (currentNodeIndex === totalNodes - 1) {
+ return dispatch => {
+ dispatch(basiliskConnectionState(false));
+ };
+ } else {
+ if (json &&
+ json.error === 'less than required responses') {
+ return {
+ type: storeType.DASHBOARD_CONNECT_NOTARIES,
+ total: totalNodes - 1,
+ current: currentNodeIndex,
+ name: currentNodeName,
+ failedNode: currentNodeName,
+ }
+ } else {
+ return {
+ type: storeType.DASHBOARD_CONNECT_NOTARIES,
+ total: totalNodes - 1,
+ current: currentNodeIndex,
+ name: currentNodeName,
+ }
+ }
+ }
+}
+
+function connectAllNotaryNodes(json, dispatch) {
+ if (json &&
+ json.length) {
+ dispatch(initNotaryNodesConSequence(json));
+
+ return {
+ type: storeType.DASHBOARD_CONNECT_NOTARIES,
+ total: json.length - 1,
+ current: 0,
+ name: json[0],
+ }
+ }
+}
+
+export function connectNotaries() {
+ const payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': 'dpow',
+ 'method': 'notarychains',
+ };
+
+ 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, 'connectNotaries', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => dispatch(connectAllNotaryNodes(json, dispatch)))
+ }
+}
+
+function getDexNotariesState(json) {
+ if (json.error === 'less than required responses') {
+ return dispatch => {
+ dispatch(triggerToaster(true, translate('TOASTR.LESS_RESPONSES_REQ'), translate('TOASTR.BASILISK_NOTIFICATION'), 'error'));
+ }
+ } else {
+ return {
+ type: storeType.DASHBOARD_GET_NOTARIES_LIST,
+ notaries: json,
+ }
+ }
+}
+
+export function getDexNotaries(coin) {
+ const payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': 'dex',
+ 'method': 'getnotaries',
+ 'symbol': coin,
+ };
+
+ return dispatch => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'getDexNotaries',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort),
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+ return fetch('http://127.0.0.1:' + (Config.useBasiliskInstance ? Config.iguanaCorePort + 1 : Config.iguanaCorePort), {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'getDexNotaries', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ dispatch(getDexNotariesState(json));
+ })
+ }
+}
\ No newline at end of file
diff --git a/react/src/actions/openAlias.js b/react/src/actions/openAlias.js
new file mode 100644
index 0000000..a9037f1
--- /dev/null
+++ b/react/src/actions/openAlias.js
@@ -0,0 +1,25 @@
+import * as storeType from './storeType';
+import {
+ triggerToaster,
+ Config
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+export function resolveOpenAliasAddress(email) {
+ const url = email.replace('@', '.');
+
+ return new Promise((resolve, reject) => {
+ fetch('https://dns.google.com/resolve?name=' + url + '&type=txt', {
+ method: 'GET',
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'resolveOpenAliasAddress', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => resolve(json))
+ });
+}
\ No newline at end of file
diff --git a/react/src/actions/sendFullBasilisk.js b/react/src/actions/sendFullBasilisk.js
new file mode 100644
index 0000000..2ce0ce5
--- /dev/null
+++ b/react/src/actions/sendFullBasilisk.js
@@ -0,0 +1,245 @@
+import * as storeType from './storeType';
+import { translate } from '../translate/translate';
+import {
+ triggerToaster,
+ Config
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+export function sendToAddress(coin, _payload) {
+ const payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'coin': coin,
+ 'method': 'sendtoaddress',
+ 'params': [
+ _payload.sendTo,
+ _payload.amount,
+ 'EasyDEX',
+ 'EasyDEXTransaction'
+ ],
+ };
+
+ return dispatch => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'sendToAddress',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'sendToAddress', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ dispatch(sendToAddressState(json, dispatch));
+ })
+ }
+}
+
+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 => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'sendFromAddress',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'sendFromAddress', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ dispatch(sendToAddressState(json, dispatch));
+ })
+ }
+}
+
+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) => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'iguanaUTXORawTX',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'iguanaUTXORawTX', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ resolve(json);
+ })
+ });
+}
+
+export function dexSendRawTX(data) {
+ const payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': 'dex',
+ 'method': 'sendrawtransaction',
+ 'signedtx': data.signedtx,
+ 'symbol': data.coin
+ };
+
+ return new Promise((resolve, reject) => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'dexSendRawTX',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'dexSendRawTX', 'Error', 'error'));
+ })
+ .then(function(response) {
+ const _response = response.text().then(function(text) { return text; });
+
+ return _response;
+ })
+ .then(function(json) {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ resolve(json);
+ })
+ });
+}
+
+function sendToAddressState(json, dispatch) {
+ if (json &&
+ json.error) {
+ dispatch(triggerToaster(true, json.error, 'Error', 'error'));
+
+ return {
+ type: storeType.DASHBOARD_ACTIVE_COIN_SENDTO,
+ lastSendToResponse: json,
+ }
+ } else if (json && json.result && json.complete) {
+ dispatch(triggerToaster(true, translate('TOASTR.TX_SENT_ALT'), translate('TOASTR.WALLET_NOTIFICATION'), 'success'));
+
+ return {
+ type: storeType.DASHBOARD_ACTIVE_COIN_SENDTO,
+ lastSendToResponse: json,
+ }
+ }
+}
+
+export function sendToAddressStateAlt(json) {
+ return {
+ type: storeType.DASHBOARD_ACTIVE_COIN_SENDTO,
+ lastSendToResponse: json,
+ }
+}
+
+export function clearLastSendToResponseState() {
+ return {
+ type: storeType.DASHBOARD_ACTIVE_COIN_SENDTO,
+ lastSendToResponse: null,
+ }
+}
\ No newline at end of file
diff --git a/react/src/actions/settings.js b/react/src/actions/settings.js
new file mode 100644
index 0000000..25d7832
--- /dev/null
+++ b/react/src/actions/settings.js
@@ -0,0 +1,318 @@
+import * as storeType from './storeType';
+import { translate } from '../translate/translate';
+import {
+ triggerToaster,
+ Config
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+function getAppInfoState(json) {
+ return {
+ type: storeType.LOAD_APP_INFO,
+ info: json,
+ }
+}
+
+export function getAppInfo() {
+ return dispatch => {
+ return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/appinfo', {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'getAppInfo', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => dispatch(getAppInfoState(json)))
+ }
+}
+
+export function settingsWifkeyState(json, coin) {
+ return {
+ type: storeType.GET_WIF_KEY,
+ wifkey: json[coin + 'wif'],
+ address: json[coin],
+ }
+}
+
+function parseImportPrivKeyResponse(json, dispatch) {
+ if (json.error === 'illegal privkey') {
+ return dispatch => {
+ dispatch(triggerToaster(true, 'Illegal privkey', translate('TOASTR.SETTINGS_NOTIFICATION'), 'error'));
+ }
+ }
+ if (json.error === 'privkey already in wallet') {
+ return dispatch => {
+ dispatch(triggerToaster(true, 'Privkey already in wallet', translate('TOASTR.SETTINGS_NOTIFICATION'), 'warning'));
+ }
+ }
+ if (json &&
+ json.result !== undefined &&
+ json.result == 'success') {
+ return dispatch => {
+ dispatch(triggerToaster(true, translate('TOASTR.PRIV_KEY_IMPORTED'), translate('TOASTR.SETTINGS_NOTIFICATION'), 'success'));
+ }
+ }
+}
+
+export function importPrivKey(wifKey) {
+ const payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'method': 'importprivkey',
+ 'params': [
+ wifKey,
+ 'imported'
+ ],
+ };
+
+ return dispatch => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'importPrivKey',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'importPrivKey', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ dispatch(parseImportPrivKeyResponse(json, dispatch));
+ })
+ .catch(function(ex) {
+ dispatch(parseImportPrivKeyResponse({
+ 'error': 'privkey already in wallet'
+ }, dispatch));
+ console.log('parsing failed', ex);
+ })
+ }
+}
+
+function getDebugLogState(json) {
+ const _data = json.result.replace('\n', '\r\n');
+
+ return {
+ type: storeType.GET_DEBUG_LOG,
+ data: _data,
+ }
+}
+
+export function getDebugLog(target, linesCount) {
+ const payload = {
+ 'herdname': target,
+ 'lastLines': linesCount
+ };
+
+ return dispatch => {
+ return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/debuglog', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'getDebugLog', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => dispatch(getDebugLogState(json)))
+ }
+}
+
+export function getPeersList(coin) {
+ const payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': 'SuperNET',
+ 'method': 'getpeers',
+ 'activecoin': coin,
+ };
+
+ return dispatch => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'getPeersList',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'getPeersList', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ dispatch(getPeersListState(json, dispatch));
+ })
+ }
+}
+
+export function getPeersListState(json) {
+ let peersList = {};
+
+ if (json &&
+ json.rawpeers &&
+ json.rawpeers.length) {
+ for (let i = 0; i < json.rawpeers.length; i++) {
+ peersList[json.rawpeers[i].coin] = json.rawpeers[i].peers;
+ }
+ }
+
+ return {
+ type: storeType.GET_PEERS_LIST,
+ supernetPeers: json && json.supernet[0] ? json.supernet : null,
+ rawPeers: peersList,
+ }
+}
+
+function addPeerNodeState(json, dispatch) {
+ if (json.error === 'addnode needs active coin, do an addcoin first') {
+ return dispatch => {
+ dispatch(triggerToaster(true, 'Addnode needs active coin', translate('TOASTR.SETTINGS_NOTIFICATION'), 'error'));
+ }
+ }
+ if (json.result === 'peer was already connected') {
+ return dispatch => {
+ dispatch(triggerToaster(true, 'Peer was already connected', translate('TOASTR.SETTINGS_NOTIFICATION'), 'warning'));
+ }
+ }
+ if (json.result === 'addnode connection was already pending') {
+ return dispatch => {
+ dispatch(triggerToaster(true, 'Addnode connection was already pending', translate('TOASTR.SETTINGS_NOTIFICATION'), 'warning'));
+ }
+ }
+ if (json.result === 'addnode submitted') {
+ return dispatch => {
+ dispatch(triggerToaster(true, 'Peer is added', translate('TOASTR.SETTINGS_NOTIFICATION'), 'success'));
+ }
+ }
+}
+
+export function addPeerNode(coin, ip) {
+ const payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': 'iguana',
+ 'method': 'addnode',
+ 'activecoin': coin,
+ 'ipaddr': ip,
+ };
+
+ return dispatch => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'addPeerNode',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'addPeerNode', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ dispatch(addPeerNodeState(json, dispatch));
+ })
+ }
+}
+
+export function saveAppConfig(_payload) {
+ return dispatch => {
+ return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/appconf', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({ 'payload': _payload }),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'saveAppConfig', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => dispatch(getAppConfig()))
+ }
+}
+
+function getAppConfigState(json) {
+ return {
+ type: storeType.LOAD_APP_CONFIG,
+ config: json,
+ }
+}
+
+export function getAppConfig() {
+ return dispatch => {
+ return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/appconf', {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'getAppConfig', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => dispatch(getAppConfigState(json)))
+ }
+}
\ No newline at end of file
diff --git a/react/src/actions/storeType.js b/react/src/actions/storeType.js
new file mode 100644
index 0000000..245db57
--- /dev/null
+++ b/react/src/actions/storeType.js
@@ -0,0 +1,43 @@
+export const TOASTER_MESSAGE = 'TOASTER_MESSAGE';
+export const DISPLAY_ADDCOIN_MODAL = 'DISPLAY_ADDCOIN_MODAL';
+export const GET_ACTIVE_COINS = 'GET_ACTIVE_COINS';
+export const LOGIN = 'LOGIN';
+export const ACTIVE_HANDLE = 'ACTIVE_HANDLE';
+export const DASHBOARD_SECTION_CHANGE = 'DASHBOARD_SECTION_CHANGE';
+export const DASHBOARD_ACTIVE_COIN_CHANGE = 'DASHBOARD_ACTIVE_COIN_CHANGE';
+export const GET_MAIN_ADDRESS = 'GET_MAIN_ADDRESS';
+export const DASHBOARD_ACTIVE_COIN_BALANCE = 'DASHBOARD_ACTIVE_COIN_BALANCE';
+export const DASHBOARD_ACTIVE_COIN_SEND_FORM = 'DASHBOARD_ACTIVE_COIN_SEND_FORM';
+export const DASHBOARD_ACTIVE_COIN_RECEIVE_FORM = 'DASHBOARD_ACTIVE_COIN_RECEIVE_FORM';
+export const DASHBOARD_ACTIVE_COIN_RESET_FORMS = 'DASHBOARD_ACTIVE_COIN_RESET_FORMS';
+export const ATOMIC = 'ATOMIC';
+export const GET_WIF_KEY = 'GET_WIF_KEY';
+export const GET_PEERS_LIST = 'GET_PEERS_LIST';
+export const GET_DEBUG_LOG = 'GET_DEBUG_LOG';
+export const BASILISK_REFRESH = 'BASILISK_REFRESH';
+export const BASILISK_CONNECTION = 'BASILISK_CONNECTION';
+export const SYNCING_FULL_MODE = 'SYNCING_FULL_MODE';
+export const SYNCING_NATIVE_MODE = 'SYNCING_NATIVE_MODE';
+export const ACTIVE_COIN_GET_ADDRESSES = 'ACTIVE_COIN_GET_ADDRESSES';
+export const START_INTERVAL= 'START_INTERVAL';
+export const STOP_INTERVAL= 'STOP_INTERVAL';
+export const DASHBOARD_ACTIVE_SECTION = 'DASHBOARD_ACTIVE_SECTION';
+export const DASHBOARD_ACTIVE_TXINFO_MODAL = 'DASHBOARD_ACTIVE_TXINFO_MODAL';
+export const DASHBOARD_ACTIVE_COIN_NATIVE_BALANCE = 'DASHBOARD_ACTIVE_COIN_NATIVE_BALANCE';
+export const DASHBOARD_ACTIVE_COIN_NATIVE_TXHISTORY = 'DASHBOARD_ACTIVE_COIN_NATIVE_TXHISTORY';
+export const DASHBOARD_ACTIVE_COIN_NATIVE_OPIDS = 'DASHBOARD_ACTIVE_COIN_NATIVE_OPIDS';
+export const DASHBOARD_ACTIVE_COIN_SENDTO = 'DASHBOARD_ACTIVE_COIN_SENDTO';
+export const DASHBOARD_ACTIVE_COIN_GET_CACHE = 'DASHBOARD_ACTIVE_COIN_GET_CACHE';
+export const DASHBOARD_ACTIVE_COIN_MAIN_BASILISK_ADDR = 'DASHBOARD_ACTIVE_COIN_MAIN_BASILISK_ADDR';
+export const DASHBOARD_GET_NOTARIES_LIST = 'DASHBOARD_GET_NOTARIES_LIST';
+export const DASHBOARD_DISPLAY_NOTARIES_MODAL = 'DASHBOARD_DISPLAY_NOTARIES_MODAL';
+export const DASHBOARD_CONNECT_NOTARIES = 'DASHBOARD_CONNECT_NOTARIES';
+export const VIEW_CACHE_DATA = 'VIEW_CACHE_DATA';
+export const SYNC_ONLY_MODAL_TOGGLE = 'SYNC_ONLY_MODAL_TOGGLE';
+export const SYNC_ONLY_DATA = 'SYNC_ONLY_DATA';
+export const LOAD_APP_CONFIG = 'LOAD_APP_CONFIG';
+export const SAVE_APP_CONFIG = 'SAVE_APP_CONFIG';
+export const SERVICE_ERROR = 'SERVICE_ERROR';
+export const DASHBOARD_ACTIVE_ADDRESS = 'DASHBOARD_ACTIVE_ADDRESS';
+export const LOAD_APP_INFO = 'LOAD_APP_INFO';
+export const LOG_GUI_HTTP = 'LOG_GUI_HTTP';
\ No newline at end of file
diff --git a/react/src/actions/syncInfo.js b/react/src/actions/syncInfo.js
new file mode 100644
index 0000000..7a07627
--- /dev/null
+++ b/react/src/actions/syncInfo.js
@@ -0,0 +1,74 @@
+import * as storeType from './storeType';
+import {
+ triggerToaster,
+ Config
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+// TODO: add custom json parser
+function getSyncInfoState(json) {
+ try {
+ JSON.parse(json);
+ json = JSON.parse(json);
+ } catch(e) {
+ //
+ }
+
+ return {
+ type: storeType.SYNCING_FULL_MODE,
+ progress: json,
+ }
+}
+
+export function getSyncInfo(coin) {
+ const payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'coin': coin,
+ 'agent': 'bitcoinrpc',
+ 'method': 'getinfo',
+ };
+
+ return dispatch => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'getSyncInfo',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'getSyncInfo', 'Error', 'error'));
+ })
+ .then(function(response) {
+ const _response = response.text().then(function(text) { return text; });
+
+ return _response;
+ })
+ .then(function(json) {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ if (json.indexOf('coin is busy processing') === -1) {
+ dispatch(getSyncInfoState(json, dispatch));
+ }
+ })
+ }
+}
\ No newline at end of file
diff --git a/react/src/actions/syncOnly.js b/react/src/actions/syncOnly.js
new file mode 100644
index 0000000..0415818
--- /dev/null
+++ b/react/src/actions/syncOnly.js
@@ -0,0 +1,58 @@
+import * as storeType from './storeType';
+import { translate } from '../translate/translate';
+import {
+ triggerToaster,
+ Config
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+export function toggleSyncOnlyModal(display) {
+ return {
+ type: storeType.SYNC_ONLY_MODAL_TOGGLE,
+ display,
+ }
+}
+
+function getSyncOnlyForksState(json) {
+ return {
+ type: storeType.SYNC_ONLY_DATA,
+ forks: JSON.parse(json.result),
+ }
+}
+
+export function getSyncOnlyForks() {
+ return dispatch => {
+ return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks/info/show', {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'getSyncOnlyForks', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => dispatch(getSyncOnlyForksState(json)))
+ }
+}
+
+export function stopIguanaFork(pmid) {
+ return dispatch => {
+ return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/forks/stop?pmid=' + pmid, {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'stopIguanaFork', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => dispatch(triggerToaster(true, 'Iguana instance is stopped', translate('TOASTR.SERVICE_NOTIFICATION'), 'success')))
+ }
+}
\ No newline at end of file
diff --git a/react/src/actions/sysInfo.js b/react/src/actions/sysInfo.js
new file mode 100644
index 0000000..b652a27
--- /dev/null
+++ b/react/src/actions/sysInfo.js
@@ -0,0 +1,26 @@
+import * as storeType from './storeType';
+import {
+ triggerToaster,
+ Config
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+export function shepherdGetSysInfo() {
+ return dispatch => {
+ return fetch('http://127.0.0.1:' + Config.agamaPort + '/shepherd/sysinfo', {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json',
+ }
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(triggerToaster(true, 'Failed to get sys info', 'Error', 'error'))
+ })
+ .then(response => response.json())
+ .then(json => console.log(json));
+ }
+}
\ No newline at end of file
diff --git a/react/src/actions/walletAuth.js b/react/src/actions/walletAuth.js
new file mode 100644
index 0000000..15ff1aa
--- /dev/null
+++ b/react/src/actions/walletAuth.js
@@ -0,0 +1,209 @@
+import * as storeType from './storeType';
+import { translate } from '../translate/translate';
+import {
+ triggerToaster,
+ Config,
+ getMainAddressState
+} from './actionCreators';
+import {
+ logGuiHttp,
+ guiLogState
+} from './log';
+
+export function encryptWallet(_passphrase, cb, coin) {
+ const payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': 'bitcoinrpc',
+ 'method': 'encryptwallet',
+ 'passphrase': _passphrase,
+ };
+
+ return dispatch => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'encryptWallet',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'encryptWallet', 'Error', 'error'));
+ })
+ .then(dispatch(walletPassphrase(_passphrase)))
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': 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': '300000',
+ };
+
+ return dispatch => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'walletpassphrase',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'walletPassphrase', 'Error', 'error'));
+ })
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ })
+ }
+}
+
+export function iguanaWalletPassphrase(_passphrase) {
+ const _payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'handle': '',
+ 'password': _passphrase,
+ 'timeout': '2592000',
+ 'agent': 'bitcoinrpc',
+ 'method': 'walletpassphrase',
+ };
+
+ return dispatch => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'iguanaWalletPassphrase',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': _payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(_payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(triggerToaster(true, 'Error iguanaWalletPassphrase', 'Error', 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ dispatch(iguanaWalletPassphraseState(json, dispatch));
+ });
+ }
+}
+
+export function iguanaActiveHandle(getMainAddress) {
+ const _payload = {
+ 'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
+ 'agent': 'SuperNET',
+ 'method': 'activehandle',
+ };
+
+ return dispatch => {
+ const _timestamp = Date.now();
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'function': 'iguanaActiveHandle',
+ 'type': 'post',
+ 'url': 'http://127.0.0.1:' + Config.iguanaCorePort,
+ 'payload': _payload,
+ 'status': 'pending',
+ }));
+
+ return fetch('http://127.0.0.1:' + Config.iguanaCorePort, {
+ method: 'POST',
+ body: JSON.stringify(_payload),
+ })
+ .catch(function(error) {
+ console.log(error);
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'error',
+ 'response': error,
+ }));
+ dispatch(updateErrosStack('activeHandle'));
+ dispatch(triggerToaster(true, translate('TOASTR.IGUANA_ARE_YOU_SURE'), translate('TOASTR.SERVICE_NOTIFICATION'), 'error'));
+ })
+ .then(response => response.json())
+ .then(json => {
+ dispatch(logGuiHttp({
+ 'timestamp': _timestamp,
+ 'status': 'success',
+ 'response': json,
+ }));
+ dispatch(getMainAddress ? getMainAddressState(json) : iguanaActiveHandleState(json));
+ });
+ }
+}
+
+function iguanaWalletPassphraseState(json, dispatch) {
+ sessionStorage.setItem('IguanaActiveAccount', JSON.stringify(json));
+ dispatch(triggerToaster(true, translate('TOASTR.LOGIN_SUCCESSFULL'), translate('TOASTR.ACCOUNT_NOTIFICATION'), 'success'));
+ dispatch(getMainAddressState(json));
+ dispatch(iguanaActiveHandleState(json));
+
+ return {
+ type: storeType.LOGIN,
+ isLoggedIn: json && json.pubkey ? true : false,
+ }
+}
+
+function iguanaActiveHandleState(json) {
+ return {
+ type: storeType.ACTIVE_HANDLE,
+ isLoggedIn: sessionStorage.getItem('IguanaActiveAccount') && JSON.parse(sessionStorage.getItem('IguanaActiveAccount')).pubkey === json.pubkey && json.status === 'unlocked' ? true : false,
+ handle: json,
+ }
+}
\ No newline at end of file
diff --git a/react/src/assets/autoupdater/update.xml b/react/src/assets/autoupdater/update.xml
deleted file mode 100644
index afc980c..0000000
--- a/react/src/assets/autoupdater/update.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
{{message}}
", - log: "{{message}}
", - log: "Copied '+lines+' row'+plural+' to the clipboard.
', - 1500 - ); - } - } ), - - "pdf": $.extend( {}, TableTools.buttonBase, { - "sAction": "flash_pdf", - "sNewLine": "\n", - "sFileName": "*.pdf", - "sButtonClass": "DTTT_button_pdf", - "sButtonText": "PDF", - "sPdfOrientation": "portrait", - "sPdfSize": "A4", - "sPdfMessage": "", - "fnClick": function( nButton, oConfig, flash ) { - this.fnSetText( flash, - "title:"+ this.fnGetTitle(oConfig) +"\n"+ - "message:"+ oConfig.sPdfMessage +"\n"+ - "colWidth:"+ this.fnCalcColRatios(oConfig) +"\n"+ - "orientation:"+ oConfig.sPdfOrientation +"\n"+ - "size:"+ oConfig.sPdfSize +"\n"+ - "--/TableToolsOpts--\n" + - this.fnGetTableData(oConfig) - ); - } - } ), - - "print": $.extend( {}, TableTools.buttonBase, { - "sInfo": "Please use your browser's print function to "+ - "print this table. Press escape when finished.
", - "sMessage": null, - "bShowAll": true, - "sToolTip": "View print view", - "sButtonClass": "DTTT_button_print", - "sButtonText": "Print", - "fnClick": function ( nButton, oConfig ) { - this.fnPrint( true, oConfig ); - } - } ), - - "text": $.extend( {}, TableTools.buttonBase ), - - "select": $.extend( {}, TableTools.buttonBase, { - "sButtonText": "Select button", - "fnSelect": function( nButton, oConfig ) { - if ( this.fnGetSelected().length !== 0 ) { - $(nButton).removeClass( this.classes.buttons.disabled ); - } else { - $(nButton).addClass( this.classes.buttons.disabled ); - } - }, - "fnInit": function( nButton, oConfig ) { - $(nButton).addClass( this.classes.buttons.disabled ); - } - } ), - - "select_single": $.extend( {}, TableTools.buttonBase, { - "sButtonText": "Select button", - "fnSelect": function( nButton, oConfig ) { - var iSelected = this.fnGetSelected().length; - if ( iSelected == 1 ) { - $(nButton).removeClass( this.classes.buttons.disabled ); - } else { - $(nButton).addClass( this.classes.buttons.disabled ); - } - }, - "fnInit": function( nButton, oConfig ) { - $(nButton).addClass( this.classes.buttons.disabled ); - } - } ), - - "select_all": $.extend( {}, TableTools.buttonBase, { - "sButtonText": "Select all", - "fnClick": function( nButton, oConfig ) { - this.fnSelectAll(); - }, - "fnSelect": function( nButton, oConfig ) { - if ( this.fnGetSelected().length == this.s.dt.fnRecordsDisplay() ) { - $(nButton).addClass( this.classes.buttons.disabled ); - } else { - $(nButton).removeClass( this.classes.buttons.disabled ); - } - } - } ), - - "select_none": $.extend( {}, TableTools.buttonBase, { - "sButtonText": "Deselect all", - "fnClick": function( nButton, oConfig ) { - this.fnSelectNone(); - }, - "fnSelect": function( nButton, oConfig ) { - if ( this.fnGetSelected().length !== 0 ) { - $(nButton).removeClass( this.classes.buttons.disabled ); - } else { - $(nButton).addClass( this.classes.buttons.disabled ); - } - }, - "fnInit": function( nButton, oConfig ) { - $(nButton).addClass( this.classes.buttons.disabled ); - } - } ), - - "ajax": $.extend( {}, TableTools.buttonBase, { - "sAjaxUrl": "/xhr.php", - "sButtonText": "Ajax button", - "fnClick": function( nButton, oConfig ) { - var sData = this.fnGetTableData(oConfig); - $.ajax( { - "url": oConfig.sAjaxUrl, - "data": [ - { "name": "tableData", "value": sData } - ], - "success": oConfig.fnAjaxComplete, - "dataType": "json", - "type": "POST", - "cache": false, - "error": function () { - alert( "Error detected when sending table data to server" ); - } - } ); - }, - "fnAjaxComplete": function( json ) { - alert( 'Ajax complete' ); - } - } ), - - "div": $.extend( {}, TableTools.buttonBase, { - "sAction": "div", - "sTag": "div", - "sButtonClass": "DTTT_nonbutton", - "sButtonText": "Text button" - } ), - - "collection": $.extend( {}, TableTools.buttonBase, { - "sAction": "collection", - "sButtonClass": "DTTT_button_collection", - "sButtonText": "Collection", - "fnClick": function( nButton, oConfig ) { - this._fnCollectionShow(nButton, oConfig); - } - } ) -}; -/* - * on* callback parameters: - * 1. node - button element - * 2. object - configuration object for this button - * 3. object - ZeroClipboard reference (flash button only) - * 4. string - Returned string from Flash (flash button only - and only on 'complete') - */ - -// Alias to match the other plug-ins styling -TableTools.buttons = TableTools.BUTTONS; - - -/** - * @namespace Classes used by TableTools - allows the styles to be override easily. - * Note that when TableTools initialises it will take a copy of the classes object - * and will use its internal copy for the remainder of its run time. - */ -TableTools.classes = { - "container": "DTTT_container", - "buttons": { - "normal": "DTTT_button", - "disabled": "DTTT_disabled" - }, - "collection": { - "container": "DTTT_collection", - "background": "DTTT_collection_background", - "buttons": { - "normal": "DTTT_button", - "disabled": "DTTT_disabled" - } - }, - "select": { - "table": "DTTT_selectable", - "row": "DTTT_selected selected" - }, - "print": { - "body": "DTTT_Print", - "info": "DTTT_print_info", - "message": "DTTT_PrintMessage" - } -}; - - -/** - * @namespace ThemeRoller classes - built in for compatibility with DataTables' - * bJQueryUI option. - */ -TableTools.classes_themeroller = { - "container": "DTTT_container ui-buttonset ui-buttonset-multi", - "buttons": { - "normal": "DTTT_button ui-button ui-state-default" - }, - "collection": { - "container": "DTTT_collection ui-buttonset ui-buttonset-multi" - } -}; - - -/** - * @namespace TableTools default settings for initialisation - */ -TableTools.DEFAULTS = { - "sSwfPath": "../swf/copy_csv_xls_pdf.swf", - "sRowSelect": "none", - "sRowSelector": "tr", - "sSelectedClass": null, - "fnPreRowSelect": null, - "fnRowSelected": null, - "fnRowDeselected": null, - "aButtons": [ "copy", "csv", "xls", "pdf", "print" ], - "oTags": { - "container": "div", - "button": "a", // We really want to use buttons here, but Firefox and IE ignore the - // click on the Flash element in the button (but not mouse[in|out]). - "liner": "span", - "collection": { - "container": "div", - "button": "a", - "liner": "span" - } - } -}; - -// Alias to match the other plug-ins -TableTools.defaults = TableTools.DEFAULTS; - - -/** - * Name of this class - * @constant CLASS - * @type String - * @default TableTools - */ -TableTools.prototype.CLASS = "TableTools"; - - -/** - * TableTools version - * @constant VERSION - * @type String - * @default See code - */ -TableTools.version = "2.2.4"; - - - -// DataTables 1.10 API -// -// This will be extended in a big way in in TableTools 3 to provide API methods -// such as rows().select() and rows.selected() etc, but for the moment the -// tabletools() method simply returns the instance. - -if ( $.fn.dataTable.Api ) { - $.fn.dataTable.Api.register( 'tabletools()', function () { - var tt = null; - - if ( this.context.length > 0 ) { - tt = TableTools.fnGetInstance( this.context[0].nTable ); - } - - return tt; - } ); -} - - - - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Initialisation - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Register a new feature with DataTables - */ -if ( typeof $.fn.dataTable == "function" && - typeof $.fn.dataTableExt.fnVersionCheck == "function" && - $.fn.dataTableExt.fnVersionCheck('1.9.0') ) -{ - $.fn.dataTableExt.aoFeatures.push( { - "fnInit": function( oDTSettings ) { - var init = oDTSettings.oInit; - var opts = init ? - init.tableTools || init.oTableTools || {} : - {}; - - return new TableTools( oDTSettings.oInstance, opts ).dom.container; - }, - "cFeature": "T", - "sFeature": "TableTools" - } ); -} -else -{ - alert( "Warning: TableTools requires DataTables 1.9.0 or newer - www.datatables.net/download"); -} - -$.fn.DataTable.TableTools = TableTools; - -})(jQuery, window, document); - -/* - * Register a new feature with DataTables - */ -if ( typeof $.fn.dataTable == "function" && - typeof $.fn.dataTableExt.fnVersionCheck == "function" && - $.fn.dataTableExt.fnVersionCheck('1.9.0') ) -{ - $.fn.dataTableExt.aoFeatures.push( { - "fnInit": function( oDTSettings ) { - var oOpts = typeof oDTSettings.oInit.oTableTools != 'undefined' ? - oDTSettings.oInit.oTableTools : {}; - - var oTT = new TableTools( oDTSettings.oInstance, oOpts ); - TableTools._aInstances.push( oTT ); - - return oTT.dom.container; - }, - "cFeature": "T", - "sFeature": "TableTools" - } ); -} -else -{ - alert( "Warning: TableTools 2 requires DataTables 1.9.0 or newer - www.datatables.net/download"); -} - - -$.fn.dataTable.TableTools = TableTools; -$.fn.DataTable.TableTools = TableTools; - - -return TableTools; -}; // /factory - - -// Define as an AMD module if possible -if ( typeof define === 'function' && define.amd ) { - define( ['jquery', 'datatables'], factory ); -} -else if ( typeof exports === 'object' ) { - // Node/CommonJS - factory( require('jquery'), require('datatables') ); -} -else if ( jQuery && !jQuery.fn.dataTable.TableTools ) { - // Otherwise simply initialise as normal, stopping multiple evaluation - factory( jQuery, jQuery.fn.dataTable ); -} - - -})(window, document); - diff --git a/react/src/assets/global/vendor/datatables/jquery.dataTables.min.js b/react/src/assets/global/vendor/datatables/jquery.dataTables.min.js deleted file mode 100644 index 1bba1d4..0000000 --- a/react/src/assets/global/vendor/datatables/jquery.dataTables.min.js +++ /dev/null @@ -1,166 +0,0 @@ -/*! - DataTables 1.10.12-dev - ©2008-2015 SpryMedia Ltd - datatables.net/license -*/ -(function(h){"function"===typeof define&&define.amd?define(["jquery"],function(D){return h(D,window,document)}):"object"===typeof exports?module.exports=function(D,I){D||(D=window);I||(I="undefined"!==typeof window?require("jquery"):require("jquery")(D));return h(I,D,D.document)}:h(jQuery,window,document)})(function(h,D,I,k){function Y(a){var b,c,d={};h.each(a,function(e){if((b=e.match(/^([^A-Z]+?)([A-Z])/))&&-1!=="a aa ai ao as b fn i m o s ".indexOf(b[1]+" "))c=e.replace(b[0],b[2].toLowerCase()), -d[c]=e,"o"===b[1]&&Y(a[e])});a._hungarianMap=d}function K(a,b,c){a._hungarianMap||Y(a);var d;h.each(b,function(e){d=a._hungarianMap[e];if(d!==k&&(c||b[d]===k))"o"===d.charAt(0)?(b[d]||(b[d]={}),h.extend(!0,b[d],b[e]),K(a[d],b[d],c)):b[d]=b[e]})}function Fa(a){var b=m.defaults.oLanguage,c=a.sZeroRecords;!a.sEmptyTable&&(c&&"No data available in table"===b.sEmptyTable)&&E(a,a,"sZeroRecords","sEmptyTable");!a.sLoadingRecords&&(c&&"Loading..."===b.sLoadingRecords)&&E(a,a,"sZeroRecords","sLoadingRecords"); -a.sInfoThousands&&(a.sThousands=a.sInfoThousands);(a=a.sDecimal)&&db(a)}function eb(a){A(a,"ordering","bSort");A(a,"orderMulti","bSortMulti");A(a,"orderClasses","bSortClasses");A(a,"orderCellsTop","bSortCellsTop");A(a,"order","aaSorting");A(a,"orderFixed","aaSortingFixed");A(a,"paging","bPaginate");A(a,"pagingType","sPaginationType");A(a,"pageLength","iDisplayLength");A(a,"searching","bFilter");"boolean"===typeof a.sScrollX&&(a.sScrollX=a.sScrollX?"100%":"");"boolean"===typeof a.scrollX&&(a.scrollX= -a.scrollX?"100%":"");if(a=a.aoSearchCols)for(var b=0,c=a.length;b- | - - | -
BTC Jumblr | -- - - - | -
- | - - | -
KMD Jumblr | -- - - - | -
- | - - | -
- | - - | -
- | - - | -
- | - - | -
- | - - | -
- | - - | -
- | - - | -
- | - |
---|---|
pubkey | -- - | -
btcpubkey | -- - | -
rmd160 | -- - | -
NXT | -- - | -
notary | -- - | -
status | -- - | -
-
-
' + - '' + wifkey_coin_handle + '' + - ' | ' + - '' + EncryptWalletDataOutput[wifkey_coin_handle] + ' | ' + - '
' + - '' + wifkey_coin_handle + 'Wif' + - ' | ' + - '' + EncryptWalletDataOutput[wifkey_coin_handle + 'wif'] + ' | ' + - '