|
|
@ -992,6 +992,35 @@ export function getKMDAddressesNative(coin, mode) { |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
// if api cache option is off
|
|
|
|
/*function Shepherd_GetBasiliskCache() { |
|
|
|
return new Promise((resolve) => { |
|
|
|
var parse_session_data = sessionStorage.getItem('IguanaActiveAccount'); |
|
|
|
parse_session_data = JSON.parse(JSON.parse(parse_session_data)); |
|
|
|
|
|
|
|
var session_pubkey = parse_session_data.pubkey, |
|
|
|
ajax_data = { 'pubkey': session_pubkey }; |
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
type: 'GET', |
|
|
|
data: ajax_data, |
|
|
|
url: 'http://127.0.0.1:17777/shepherd/cache', |
|
|
|
contentType: 'application/json' // send as JSON
|
|
|
|
}) |
|
|
|
.done(function(data) { |
|
|
|
resolve(data); |
|
|
|
data = JSON.parse(data); |
|
|
|
|
|
|
|
if (data.result === 'JSON parse error') { |
|
|
|
Shepherd_GroomData_Delete() |
|
|
|
.then(function(result) { |
|
|
|
console.log('error reading cache, flushing...'); |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}*/ |
|
|
|
|
|
|
|
if (mode === 'basilisk') { |
|
|
|
payload = { |
|
|
|
'userpass': 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'), |
|
|
@ -1002,7 +1031,95 @@ export function getKMDAddressesNative(coin, mode) { |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
fetch('http://127.0.0.1:' + Config.iguanaCorePort, { |
|
|
|
if (mode === 'basilisk') { |
|
|
|
const _addressArray = mode === 'basilisk' ? result[0].result : result; |
|
|
|
|
|
|
|
Promise.all(_addressArray.map((_address, index) => { |
|
|
|
console.log('addrlength', _addressArray.length); |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
console.log(_address); |
|
|
|
resolve(_address); |
|
|
|
}); |
|
|
|
})) |
|
|
|
.then(result => { |
|
|
|
console.log('addrres', result); |
|
|
|
|
|
|
|
fetch('http://127.0.0.1:' + Config.iguanaCorePort, { |
|
|
|
method: 'POST', |
|
|
|
body: JSON.stringify(payload), |
|
|
|
}) |
|
|
|
.catch(function(error) { |
|
|
|
console.log(error); |
|
|
|
dispatch(triggerToaster(true, 'getKMDAddressesNative+Balance', 'Error', 'error')); |
|
|
|
}) |
|
|
|
.then(response => response.json()) |
|
|
|
.then(function(json) { |
|
|
|
console.log('getaddrjson', result[0]); |
|
|
|
if (mode === 'full' || mode === 'basilisk') { |
|
|
|
result[0] = result[0].result; |
|
|
|
} |
|
|
|
|
|
|
|
if (mode !== 'basilisk') { |
|
|
|
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]; |
|
|
|
} |
|
|
|
console.log('new addr ' + allAddrArray[a] + ' | ' + allAddrArray[a].substring(0, 2)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
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: sum, |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
dispatch(getKMDAddressesNativeState({ |
|
|
|
'public': newAddressArray[0], |
|
|
|
'private': newAddressArray[1] |
|
|
|
})); |
|
|
|
}) |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/*fetch('http://127.0.0.1:' + Config.iguanaCorePort, { |
|
|
|
method: 'POST', |
|
|
|
body: JSON.stringify(payload), |
|
|
|
}) |
|
|
@ -1073,7 +1190,7 @@ export function getKMDAddressesNative(coin, mode) { |
|
|
|
'public': newAddressArray[0], |
|
|
|
'private': newAddressArray[1] |
|
|
|
})); |
|
|
|
}) |
|
|
|
})*/ |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -1368,6 +1485,7 @@ export function getNativeTxHistoryState(json) { |
|
|
|
function handleGetNewKMDAddresses(pubpriv, coin, dispatch) { |
|
|
|
dispatch(triggerToaster(true, translate('KMD_NATIVE.NEW_ADDR_GENERATED'), translate('TOASTR.WALLET_NOTIFICATION'), 'success')); |
|
|
|
dispatch(getKMDAddressesNative(coin)); |
|
|
|
|
|
|
|
return {}; |
|
|
|
} |
|
|
|
|
|
|
@ -1551,7 +1669,7 @@ function sendToAddressState(json, dispatch) { |
|
|
|
|
|
|
|
return { |
|
|
|
type: DASHBOARD_ACTIVE_COIN_SENDTO, |
|
|
|
lastSendToResponse: json.error, |
|
|
|
lastSendToResponse: json, |
|
|
|
} |
|
|
|
} else if (json && json.result && json.complete) { |
|
|
|
dispatch(triggerToaster(true, translate('TOASTR.TX_SENT_ALT'), translate('TOASTR.WALLET_NOTIFICATION'), 'success')); |
|
|
@ -1577,10 +1695,6 @@ export function sendToAddress(coin, _payload) { |
|
|
|
}; |
|
|
|
|
|
|
|
return dispatch => { |
|
|
|
const json = {"result":"1c629f37ed45a4734e27e5cf699907dc29d278a09a48d8564e2bf9571687a1d9","signedtx":"0100000001ff3de00c3ef4f2eefbda19debe2d454031f80481fd7a6db07a8faa3e8094f5be010000006b48304502210093ab5029e24645acaa014fc806a43caa8ba55ebc5767647d235f568ce045cf0c022055925b481e9cb9210a17dd5df01360420aea4b3bfd8b632e9b5e506309cfac14012102743d2afdb88ede68fb5938e961b1f41c2b6267b3286516543eb4e4ab87ad0d0affffffff02a0860100000000001976a9142f4c0f91fc06ac228c120aee41741d0d3909683288aca070da14000000001976a9142f4c0f91fc06ac228c120aee41741d0d3909683288ac00000000","complete":true,"sendrawtransaction":"success","tag":"9015189477602923119"}; |
|
|
|
dispatch(sendToAddressState(json, dispatch)); |
|
|
|
} |
|
|
|
/*return dispatch => { |
|
|
|
return fetch('http://127.0.0.1:' + Config.iguanaCorePort, { |
|
|
|
method: 'POST', |
|
|
|
body: JSON.stringify(payload), |
|
|
@ -1591,7 +1705,7 @@ export function sendToAddress(coin, _payload) { |
|
|
|
}) |
|
|
|
.then(response => response.json()) |
|
|
|
.then(json => dispatch(sendToAddressHandler(json))) |
|
|
|
}*/ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/*function Shepherd_SendPendValue() { |
|
|
|