Merge pull request #1395 from siiky/fix/lam-600/mock-wallet-structure

fix: move transaction hash fetching to the right place
This commit is contained in:
Rafael Taranto 2022-10-03 14:54:50 +01:00 committed by GitHub
commit 2f04bf1b12

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