fix: remove createdByOperator from blacklist type
fix: check for reused address
This commit is contained in:
parent
d7519d477e
commit
830b8132d0
2 changed files with 9 additions and 8 deletions
|
|
@ -34,14 +34,14 @@ function post (machineTx, pi) {
|
||||||
let blacklisted = false
|
let blacklisted = false
|
||||||
let addressReuse = false
|
let addressReuse = false
|
||||||
|
|
||||||
return Promise.all([settingsLoader.loadLatest(), checkForBlacklisted(updatedTx), getAddresses()])
|
return Promise.all([settingsLoader.loadLatest(), checkForBlacklisted(updatedTx), doesTxReuseAddress(updatedTx)])
|
||||||
.then(([{ config }, blacklistItems, addresses]) => {
|
.then(([{ config }, blacklistItems, isReusedAddress]) => {
|
||||||
const rejectAddressReuse = configManager.getCompliance(config).rejectAddressReuse
|
const rejectAddressReuse = configManager.getCompliance(config).rejectAddressReuse
|
||||||
|
|
||||||
if (_.some(it => it.address === updatedTx.toAddress)(blacklistItems)) {
|
if (_.some(it => it.address === updatedTx.toAddress)(blacklistItems)) {
|
||||||
blacklisted = true
|
blacklisted = true
|
||||||
notifier.notifyIfActive('compliance', 'blacklistNotify', r.tx, false)
|
notifier.notifyIfActive('compliance', 'blacklistNotify', r.tx, false)
|
||||||
} else if (_.some(it => it === updatedTx.toAddress)(addresses) && rejectAddressReuse) {
|
} else if (isReusedAddress && rejectAddressReuse) {
|
||||||
notifier.notifyIfActive('compliance', 'blacklistNotify', r.tx, true)
|
notifier.notifyIfActive('compliance', 'blacklistNotify', r.tx, true)
|
||||||
addressReuse = true
|
addressReuse = true
|
||||||
}
|
}
|
||||||
|
|
@ -139,10 +139,12 @@ function postProcess (r, pi, isBlacklisted, addressReuse) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAddresses () {
|
function doesTxReuseAddress (tx) {
|
||||||
const sql = `SELECT DISTINCT to_address FROM cash_in_txs`
|
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).then(res => res.map(it => it.to_address))
|
return db.any(sql, [tx.toAddress])
|
||||||
|
}
|
||||||
|
return Promise.resolve(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
function monitorPending (settings) {
|
function monitorPending (settings) {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ const { gql } = require('apollo-server-express')
|
||||||
|
|
||||||
const typeDef = gql`
|
const typeDef = gql`
|
||||||
type Blacklist {
|
type Blacklist {
|
||||||
createdByOperator: Boolean!
|
|
||||||
cryptoCode: String!
|
cryptoCode: String!
|
||||||
address: String!
|
address: String!
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue