From 63e0782e3236bc4dd97a13a207eb7202771812be Mon Sep 17 00:00:00 2001 From: Fabio Cigliano Date: Wed, 13 Jun 2018 01:15:58 +1200 Subject: [PATCH] Expired transaction after bugfix (#121) * other minor fixes * reedemable transaction expiry fix --- lib/coinatmradar/coinatmradar.js | 8 +++++++- lib/route-helpers.js | 4 ++-- lib/wallet.js | 4 ++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/coinatmradar/coinatmradar.js b/lib/coinatmradar/coinatmradar.js index c28f55a0..19e72850 100644 --- a/lib/coinatmradar/coinatmradar.js +++ b/lib/coinatmradar/coinatmradar.js @@ -103,8 +103,14 @@ function getMachines (info) { } function sendRadar (data) { + const url = _.get(['coinAtmRadar', 'url'], options) + + if (_.isEmpty(url)) { + return Promise.reject(new Error('Missing coinAtmRadar url!')) + } + const config = { - url: options.coinAtmRadar.url, + url, method: 'post', data, timeout: TIMEOUT, diff --git a/lib/route-helpers.js b/lib/route-helpers.js index eff676d6..ce43e322 100644 --- a/lib/route-helpers.js +++ b/lib/route-helpers.js @@ -6,7 +6,7 @@ const T = require('./time') const BN = require('./bn') const settingsLoader = require('./settings-loader') -const TRANSACTION_EXPIRATION = 2 * T.days +const TRANSACTION_EXPIRATION = T.day function httpError (msg, code) { const err = new Error(msg) @@ -49,7 +49,7 @@ function toCashOutTx (row) { function fetchPhoneTx (phone) { const sql = `select * from cash_out_txs where phone=$1 and dispense=$2 - and (extract(epoch from (coalesce(confirmed_at, now()) - created))) * 1000 < $3` + and (extract(epoch from (now() - created))) * 1000 < $3` const values = [phone, false, TRANSACTION_EXPIRATION] diff --git a/lib/wallet.js b/lib/wallet.js index 7a7f5bcf..6a5e5b47 100644 --- a/lib/wallet.js +++ b/lib/wallet.js @@ -138,6 +138,10 @@ function authorizeZeroConf (settings, tx, machineId) { const plugin = cryptoConfig.zeroConf const zeroConfLimit = machineConfig.zeroConfLimit + if (!_.isObject(tx.fiat)) { + return Promise.reject(new Error('tx.fiat is undefined!')) + } + if (plugin === 'no-zero-conf' || tx.fiat.gt(zeroConfLimit)) { return Promise.resolve(false) }