diff --git a/lib/route-helpers.js b/lib/route-helpers.js index ce43e322..857dded8 100644 --- a/lib/route-helpers.js +++ b/lib/route-helpers.js @@ -56,6 +56,7 @@ function fetchPhoneTx (phone) { return db.any(sql, values) .then(_.map(toCashOutTx)) .then(txs => { + const seenTxs = _.some(it => it.status !== 'notSeen', txs) const confirmedTxs = txs.filter(tx => _.includes(tx.status, ['instant', 'confirmed'])) if (confirmedTxs.length > 0) { const reducer = (acc, val) => { @@ -67,7 +68,8 @@ function fetchPhoneTx (phone) { return maxTx } - if (txs.length > 0) throw httpError('Pending transactions', 412) + if (txs.length > 0 && !seenTxs) throw httpError('Transaction not seen', 411) + if (txs.length > 0 && seenTxs) throw httpError('Pending transactions', 412) throw httpError('No transactions', 404) }) }