Merge pull request #1223 from josepfo/feat/ciphetrace-debug-logs

feat: ciphertrace debug logs
This commit is contained in:
Rafael Taranto 2022-05-16 19:03:54 +01:00 committed by GitHub
commit 74e9a50f51

View file

@ -28,10 +28,20 @@ function rateWallet (account, cryptoCode, address) {
const { apiVersion, authHeader } = client const { apiVersion, authHeader } = client
const threshold = account.scoreThreshold const threshold = account.scoreThreshold
console.log(`** DEBUG ** rateWallet ENDPOINT: https://rest.ciphertrace.com/aml/${apiVersion}/${_.toLower(cryptoCode)}/risk?address=${address}`)
return axios.get(`https://rest.ciphertrace.com/aml/${apiVersion}/${_.toLower(cryptoCode)}/risk?address=${address}`, { return axios.get(`https://rest.ciphertrace.com/aml/${apiVersion}/${_.toLower(cryptoCode)}/risk?address=${address}`, {
headers: authHeader headers: authHeader
}) })
.then(res => ({ address, score: res.data.risk, isValid: res.data.risk < threshold })) .then(res => ({ address, score: res.data.risk, isValid: res.data.risk < threshold }))
.then(result => {
console.log(`** DEBUG ** rateWallet RETURN: ${result}`)
return result
})
.catch(err => {
console.log(`** DEBUG ** rateWallet ERROR: ${err.message}`)
throw err
})
} }
function isValidWalletScore (account, score) { function isValidWalletScore (account, score) {
@ -48,6 +58,8 @@ function getTransactionHash (account, cryptoCode, receivingAddress) {
const { apiVersion, authHeader } = client const { apiVersion, authHeader } = client
console.log(`** DEBUG ** getTransactionHash ENDPOINT: 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`, { 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
}) })
@ -56,8 +68,13 @@ function getTransactionHash (account, cryptoCode, receivingAddress) {
if (_.size(data.txHistory) > 1) { if (_.size(data.txHistory) > 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')
} }
console.log(`** DEBUG ** getTransactionHash RETURN: ${_.join(', ', _.map(it => it.txHash, data.txHistory))}`)
return _.join(', ', _.map(it => it.txHash, data.txHistory)) return _.join(', ', _.map(it => it.txHash, data.txHistory))
}) })
.catch(err => {
console.log(`** DEBUG ** getTransactionHash ERROR: ${err}`)
throw err
})
} }
function getInputAddresses (account, cryptoCode, txHashes) { function getInputAddresses (account, cryptoCode, txHashes) {
@ -66,6 +83,8 @@ function getInputAddresses (account, cryptoCode, txHashes) {
const { apiVersion, authHeader } = client const { apiVersion, authHeader } = client
console.log(`** DEBUG ** getInputAddresses ENDPOINT: https://rest.ciphertrace.com/api/${apiVersion}/${_.toLower(cryptoCode) !== 'btc' ? `${_.toLower(cryptoCode)}_` : ``}tx?txhashes=${txHashes}`)
return axios.get(`https://rest.ciphertrace.com/api/${apiVersion}/${_.toLower(cryptoCode) !== 'btc' ? `${_.toLower(cryptoCode)}_` : ``}tx?txhashes=${txHashes}`, { return axios.get(`https://rest.ciphertrace.com/api/${apiVersion}/${_.toLower(cryptoCode) !== 'btc' ? `${_.toLower(cryptoCode)}_` : ``}tx?txhashes=${txHashes}`, {
headers: authHeader headers: authHeader
}) })
@ -78,8 +97,14 @@ function getInputAddresses (account, cryptoCode, txHashes) {
const transactionInputs = _.flatMap(it => it.inputs, data.transactions) const transactionInputs = _.flatMap(it => it.inputs, data.transactions)
const inputAddresses = _.map(it => it.address, transactionInputs) const inputAddresses = _.map(it => it.address, transactionInputs)
console.log(`** DEBUG ** getInputAddresses RETURN: ${inputAddresses}`)
return inputAddresses return inputAddresses
}) })
.catch(err => {
console.log(`** DEBUG ** getInputAddresses ERROR: ${err.message}`)
throw err
})
} }
module.exports = { module.exports = {