feat: allow address reuse if same customer
This commit is contained in:
parent
546f446523
commit
1cf692946e
1 changed files with 14 additions and 14 deletions
|
|
@ -195,23 +195,23 @@ function postProcess(r, pi, isBlacklisted, addressReuse, walletScore) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// At most only one authenticated customer can use an address.
|
||||||
|
// We count distinct customers plus the current customer if they are not anonymous
|
||||||
|
// To prevent malicious blocking of address, we only check for txs with actual fiat
|
||||||
function doesTxReuseAddress(tx) {
|
function doesTxReuseAddress(tx) {
|
||||||
const sql = `
|
const sql = `
|
||||||
SELECT EXISTS (
|
SELECT COUNT(*) > 1 as exists
|
||||||
SELECT 1
|
FROM (SELECT DISTINCT customer_id
|
||||||
FROM cash_in_txs
|
FROM cash_in_txs
|
||||||
WHERE id != $1
|
WHERE to_address = $1
|
||||||
AND to_address = $2
|
|
||||||
AND customer_id != $3
|
AND customer_id != $3
|
||||||
AND customer_id != $4
|
AND fiat > 0
|
||||||
);`
|
UNION
|
||||||
|
SELECT $2
|
||||||
|
WHERE $2 != $3) t;
|
||||||
|
`
|
||||||
return db
|
return db
|
||||||
.one(sql, [
|
.one(sql, [tx.toAddress, tx.customerId, constants.anonymousCustomer.uuid])
|
||||||
tx.id,
|
|
||||||
tx.toAddress,
|
|
||||||
tx.customerId,
|
|
||||||
constants.anonymousCustomer.uuid,
|
|
||||||
])
|
|
||||||
.then(({ exists }) => exists)
|
.then(({ exists }) => exists)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue