feat: ciphertrace debug logs

This commit is contained in:
José Oliveira 2022-05-16 18:12:52 +01:00
parent e94f1ff223
commit dc10537044
2 changed files with 15 additions and 0 deletions

View file

@ -124,12 +124,21 @@ function getWalletScore (tx, pi) {
if (_.includes(tx.status, statuses) && _.isNil(tx.walletScore)) { if (_.includes(tx.status, statuses) && _.isNil(tx.walletScore)) {
// Transaction shows up on the blockchain, we can request the sender address // Transaction shows up on the blockchain, we can request the sender address
return pi.getTransactionHash(tx) return pi.getTransactionHash(tx)
.catch(err => {
console.log(`** DEBUG ** getTransactionHash ERROR: ${err}`)
})
.then(txHashes => pi.getInputAddresses(tx, txHashes)) .then(txHashes => pi.getInputAddresses(tx, txHashes))
.catch(err => {
console.log(`** DEBUG ** getInputAddresses ERROR: ${err.message}`)
})
.then(addresses => { .then(addresses => {
const addressesPromise = [] const addressesPromise = []
_.forEach(it => addressesPromise.push(pi.rateWallet(tx.cryptoCode, it)), addresses) _.forEach(it => addressesPromise.push(pi.rateWallet(tx.cryptoCode, it)), addresses)
return Promise.all(addressesPromise) return Promise.all(addressesPromise)
}) })
.catch(err => {
console.log(`** DEBUG ** rateWallet ERROR: ${err.message}`)
})
.then(scores => { .then(scores => {
if (_.isNil(scores) || _.isEmpty(scores)) return tx if (_.isNil(scores) || _.isEmpty(scores)) return tx
const highestScore = _.maxBy(it => it.score, scores) const highestScore = _.maxBy(it => it.score, scores)

View file

@ -28,6 +28,8 @@ 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
}) })
@ -48,6 +50,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
}) })
@ -66,6 +70,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
}) })