Feat: compliance blacklisted addresses notifications

This commit is contained in:
Cesar 2020-12-15 18:55:45 +00:00 committed by Josh Harvey
parent 3b3bdf839b
commit 204e421b3d
9 changed files with 55 additions and 21 deletions

View file

@ -8,6 +8,7 @@ const plugins = require('../plugins')
const logger = require('../logger')
const settingsLoader = require('../new-settings-loader')
const configManager = require('../new-config-manager')
const notifier = require("../notifier/index")
const cashInAtomic = require('./cash-in-atomic')
const cashInLow = require('./cash-in-low')
@ -30,10 +31,11 @@ function post (machineTx, pi) {
if (_.some(it => it.created_by_operator === true)(blacklistItems)) {
blacklisted = true
notifier.addBlacklistNotification(r.tx, false)
} else if (_.some(it => it.created_by_operator === false)(blacklistItems) && rejectAddressReuseActive) {
notifier.addBlacklistNotification(r.tx, true)
addressReuse = true
}
return postProcess(r, pi, blacklisted, addressReuse)
})
.then(changes => cashInLow.update(db, updatedTx, changes))

View file

@ -44,6 +44,18 @@ const configSql = 'insert into user_config (type, data, valid, schema_version) v
function saveConfig (config) {
return loadLatestConfigOrNone()
.then(currentConfig => {
if(config.notifications_cryptoHighBalance || config.notifications_cryptoLowBalance) {
clearCryptoBalanceNotifications(currentConfig, config, false)
}
if(config.notifications_cryptoBalanceOverrides) {
clearCryptoBalanceNotifications(currentConfig.notifications_cryptoBalanceOverrides, config.notifications_cryptoBalanceOverrides, true)
}
if(config.notifications_fiatBalanceCassette1 || config.notifications_fiatBalanceCassette2) {
clearCassetteNotifications(currentConfig, config, false)
}
if(config.notifications_fiatBalanceOverrides) {
clearCassetteNotifications(currentConfig.notifications_fiatBalanceOverrides, config.notifications_fiatBalanceOverrides, true)
}
const newConfig = _.assign(currentConfig, config)
return db.none(configSql, ['config', { config: newConfig }, true, NEW_SETTINGS_LOADER_SCHEMA_VERSION])
})

View file

@ -363,11 +363,26 @@ const errorAlertsNotify = (alertRec) => {
}, alerts)
}
const addBlacklistNotification = (tx, isAddressReuse) => {
let detail = ''
let message = ''
if(isAddressReuse) {
detail = `${tx.cryptoCode}_REUSED_${tx.toAddress}`
message = `Blocked address reuse: ${tx.cryptoCode} ${tx.toAddress.substr(0,10)}...`
} else {
detail = `${tx.cryptoCode}_BLOCKED_${tx.toAddress}`
message = `Blocked blacklisted address: ${tx.cryptoCode} ${tx.toAddress.substr(0,10)}...`
}
queries.addComplianceNotification(tx.deviceId, detail, message)
}
module.exports = {
transactionNotify,
checkNotification,
checkPings,
checkStuckScreen,
sendRedemptionMessage,
cashCassettesNotify
cashCassettesNotify,
addBlacklistNotification
}

View file

@ -60,6 +60,11 @@ const invalidateNotification = (id) => {
return db.none(sql, [id])
}
const addComplianceNotification = (deviceId, detail, message) => {
const sql = `INSERT INTO notifications (id, type, detail, device_id, message, created) values ($1, 'compliance', $2, $3, $4, CURRENT_TIMESTAMP)`
return db.oneOrNone(sql, [uuidv4(), detail, deviceId, message])
}
module.exports = {
machineEvents: dbm.machineEvents,
addHighValueTx,
@ -70,4 +75,5 @@ module.exports = {
getAllValidNotifications,
getValidNotifications,
invalidateNotification,
addComplianceNotification
}