fix zero-conf stuff
This commit is contained in:
parent
ee3fc3a8f0
commit
0bf4a14383
3 changed files with 29 additions and 16 deletions
|
|
@ -186,7 +186,8 @@ function fetchData () {
|
|||
{code: 'mock-id-verify', display: 'Mock ID verifier', class: 'idVerifier'},
|
||||
{code: 'twilio', display: 'Twilio', class: 'sms'},
|
||||
{code: 'mailjet', display: 'Mailjet', class: 'email'},
|
||||
{code: 'all-zero-conf', display: 'All pass', class: 'zeroConf'},
|
||||
{code: 'all-zero-conf', display: 'All pass', class: 'zeroConf', cryptos: ALL_CRYPTOS},
|
||||
{code: 'no-zero-conf', display: 'None pass', class: 'zeroConf', cryptos: ALL_CRYPTOS},
|
||||
{code: 'blockcypher', display: 'Blockcypher', class: 'zeroConf', cryptos: ['BTC']},
|
||||
{code: 'mock-zero-conf', display: 'Mock 0-conf', class: 'zeroConf', cryptos: ['BTC', 'ZEC', 'LTC', 'DASH']}
|
||||
],
|
||||
|
|
|
|||
|
|
@ -4,8 +4,13 @@ const logger = require('./logger')
|
|||
|
||||
const pgp = Pgp({
|
||||
pgNative: true,
|
||||
error: (_, e) => {
|
||||
error: (err, e) => {
|
||||
if (e.cn) logger.error('Database not reachable.')
|
||||
if (e.query) {
|
||||
logger.error(e.query)
|
||||
logger.error(e.params)
|
||||
}
|
||||
logger.error(err)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -99,8 +99,11 @@ function authorizeZeroConf (settings, tx, machineId) {
|
|||
const plugin = cryptoConfig.zeroConf
|
||||
const zeroConfLimit = machineConfig.zeroConfLimit
|
||||
|
||||
if (tx.fiat.gt(zeroConfLimit)) return Promise.resolve(false)
|
||||
if (tx.cryptoCode !== 'BTC' || plugin === 'all-zero-conf') return Promise.resolve(true)
|
||||
if (plugin === 'no-zero-conf' || tx.fiat.gt(zeroConfLimit)) {
|
||||
return Promise.resolve(false)
|
||||
}
|
||||
|
||||
if (plugin === 'all-zero-conf') return Promise.resolve(true)
|
||||
|
||||
const zeroConf = ph.load(ph.ZERO_CONF, plugin)
|
||||
const account = settings.accounts[plugin]
|
||||
|
|
@ -119,20 +122,24 @@ function getPublishAge (txId) {
|
|||
}
|
||||
|
||||
function getStatus (settings, tx, machineId) {
|
||||
return getWalletStatus(settings, tx)
|
||||
.then((statusRec) => {
|
||||
if (statusRec.status === 'authorized') {
|
||||
const promises = [
|
||||
getWalletStatus(settings, tx),
|
||||
authorizeZeroConf(settings, tx, machineId),
|
||||
getPublishAge(tx.id)
|
||||
getPublishAge(tx.id),
|
||||
authorizeZeroConf(settings, tx, machineId)
|
||||
]
|
||||
|
||||
return Promise.all(promises)
|
||||
.then(([statusRec, isAuthorized, publishAge]) => {
|
||||
if (statusRec.status === 'authorized') {
|
||||
.then(([publishAge, isAuthorized]) => {
|
||||
const unauthorizedStatus = publishAge < ZERO_CONF_EXPIRATION
|
||||
? 'published'
|
||||
: 'rejected'
|
||||
|
||||
return {status: (isAuthorized ? 'authorized' : unauthorizedStatus)}
|
||||
const status = isAuthorized ? 'authorized' : unauthorizedStatus
|
||||
|
||||
return {status}
|
||||
})
|
||||
}
|
||||
|
||||
return statusRec
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue