fix: move transaction hash fetching to the right place

This commit is contained in:
siiky 2022-09-30 13:09:13 +01:00
parent 7abc10b28e
commit 5095d66b49

View file

@ -59,6 +59,10 @@ function getAddressTransactionsHashes (receivingAddress, cryptoCode, client, wal
return axios.get(`https://rest.ciphertrace.com/api/${apiVersion}/${_.toLower(cryptoCode) !== 'btc' ? `${_.toLower(cryptoCode)}_` : ``}address/search?features=tx&address=${receivingAddress}&mempool=true`, {
headers: authHeader
})
.then(_.flow(
_.get(['data', 'txHistory']),
_.map(_.get(['txHash']))
))
.catch(err => {
console.log(`** DEBUG ** getTransactionHash ERROR: ${err}`)
console.log(`** DEBUG ** Fetching transactions hashes via wallet node...`)
@ -70,9 +74,7 @@ function getTransactionHash (account, cryptoCode, receivingAddress, wallet) {
const client = getClient(account)
if (!_.includes(_.toUpper(cryptoCode), SUPPORTED_COINS) || _.isNil(client)) return Promise.resolve(null)
return getAddressTransactionsHashes(receivingAddress, cryptoCode, client, wallet)
.then(({ data: { txHistory } }) => {
const txHashes = _.map(_.get(['txHash']), txHistory)
.then(txHashes => {
if (_.size(txHashes) > 1) {
logger.warn('An address generated by this wallet was used in more than one transaction')
}