fix: CipherTrace scoring for cash-out transactions
This commit is contained in:
parent
5ce5950609
commit
bcbde40a52
2 changed files with 52 additions and 54 deletions
|
|
@ -35,7 +35,7 @@ function rateWallet (account, cryptoCode, address) {
|
|||
})
|
||||
.then(res => ({ address, score: res.data.risk, isValid: res.data.risk < threshold }))
|
||||
.then(result => {
|
||||
console.log(`** DEBUG ** rateWallet RETURN: ${result}`)
|
||||
console.log('** DEBUG ** rateWallet RETURN:', result)
|
||||
return result
|
||||
})
|
||||
.catch(err => {
|
||||
|
|
@ -69,32 +69,42 @@ function getAddressTransactionsHashes (receivingAddress, cryptoCode, client, wal
|
|||
function getTransactionHash (account, cryptoCode, receivingAddress, wallet) {
|
||||
const client = getClient(account)
|
||||
if (!_.includes(_.toUpper(cryptoCode), SUPPORTED_COINS) || _.isNil(client)) return Promise.resolve(null)
|
||||
getAddressTransactionsHashes(receivingAddress, cryptoCode, client, wallet)
|
||||
.then(res => {
|
||||
const data = res.data
|
||||
if (_.size(data.txHistory) > 1) {
|
||||
return getAddressTransactionsHashes(receivingAddress, cryptoCode, client, wallet)
|
||||
.then(({ data: { txHistory } }) => {
|
||||
const txHashes = _.map(_.get(['txHash']), txHistory)
|
||||
|
||||
if (_.size(txHashes) > 1) {
|
||||
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))
|
||||
console.log('** DEBUG ** getTransactionHash RETURN: ', _.join(', ', txHashes))
|
||||
return txHashes
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(`** DEBUG ** getTransactionHash from wallet node ERROR: ${err}`)
|
||||
console.log('** DEBUG ** getTransactionHash from wallet node ERROR: ', err)
|
||||
throw err
|
||||
})
|
||||
}
|
||||
|
||||
function getInputAddresses (account, cryptoCode, txHashes) {
|
||||
const client = getClient(account)
|
||||
if (!_.includes(_.toUpper(cryptoCode), SUPPORTED_COINS) || _.isNil(client)) return Promise.resolve(null)
|
||||
if (_.isEmpty(txHashes) || !_.includes(_.toUpper(cryptoCode), SUPPORTED_COINS) || _.isNil(client))
|
||||
return Promise.resolve([])
|
||||
|
||||
/* NOTE: The API accepts at most 10 hashes, and for us here more than 1 is already an exception, not the norm. */
|
||||
if (_.size(txHashes) > 10)
|
||||
return Promise.reject(new Error("Too many tx hashes -- shouldn't happen!"))
|
||||
|
||||
const { apiVersion, authHeader } = client
|
||||
|
||||
console.log(`** DEBUG ** getInputAddresses ENDPOINT: https://rest.ciphertrace.com/api/${apiVersion}/${_.toLower(cryptoCode) !== 'btc' ? `${_.toLower(cryptoCode)}_` : ``}tx?txhashes=${txHashes}`)
|
||||
cryptoCode = _.toLower(cryptoCode)
|
||||
const lastPathComp = cryptoCode !== 'btc' ? cryptoCode + '_tx' : 'tx'
|
||||
|
||||
return axios.get(`https://rest.ciphertrace.com/api/${apiVersion}/${_.toLower(cryptoCode) !== 'btc' ? `${_.toLower(cryptoCode)}_` : ``}tx?txhashes=${txHashes}`, {
|
||||
headers: authHeader
|
||||
})
|
||||
txHashes = _(txHashes).take(10).join(',')
|
||||
|
||||
const url = `https://rest.ciphertrace.com/api/${apiVersion}/${lastPathComp}?txhashes=${txHashes}`
|
||||
console.log('** DEBUG ** getInputAddresses ENDPOINT: ', url)
|
||||
|
||||
return axios.get(url, { headers: authHeader })
|
||||
.then(res => {
|
||||
const data = res.data
|
||||
if (_.size(data.transactions) > 1) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue