Merge pull request #1428 from ubavic/address-reuse-fix
fix: address reuse query
This commit is contained in:
commit
f3c50d5f59
1 changed files with 8 additions and 3 deletions
|
|
@ -45,7 +45,7 @@ function post (machineTx, pi) {
|
|||
if (_.some(it => it.address === updatedTx.toAddress)(blacklistItems)) {
|
||||
blacklisted = true
|
||||
notifier.notifyIfActive('compliance', 'blacklistNotify', r.tx, false)
|
||||
} else if (isReusedAddress && rejectAddressReuse) {
|
||||
} else if (isReusedAddress[0].exists && rejectAddressReuse) {
|
||||
notifier.notifyIfActive('compliance', 'blacklistNotify', r.tx, true)
|
||||
addressReuse = true
|
||||
}
|
||||
|
|
@ -167,8 +167,13 @@ function postProcess (r, pi, isBlacklisted, addressReuse, walletScore) {
|
|||
|
||||
function doesTxReuseAddress (tx) {
|
||||
if (!tx.fiat || tx.fiat.isZero()) {
|
||||
const sql = `SELECT EXISTS (SELECT DISTINCT to_address FROM cash_in_txs WHERE to_address = $1)`
|
||||
return db.any(sql, [tx.toAddress])
|
||||
const sql = `
|
||||
SELECT EXISTS (
|
||||
SELECT DISTINCT to_address FROM (
|
||||
SELECT to_address FROM cash_in_txs WHERE id != $1
|
||||
) AS x WHERE to_address = $2
|
||||
)`
|
||||
return db.any(sql, [tx.id, tx.toAddress])
|
||||
}
|
||||
return Promise.resolve(false)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue