bug fixes for redeem
This commit is contained in:
parent
996ebd395b
commit
694f3e5e96
3 changed files with 30 additions and 22 deletions
|
|
@ -806,13 +806,13 @@ exports.registerRedeem = function registerRedeem (session) {
|
|||
}
|
||||
|
||||
exports.fetchPhoneTx = function fetchPhoneTx (phone) {
|
||||
db.fetchPhoneTxs(phone, TRANSACTION_EXPIRATION)
|
||||
return db.fetchPhoneTxs(phone, TRANSACTION_EXPIRATION)
|
||||
.then(txs => {
|
||||
const authorizedTxs = txs.filter(tx => tx.authorized)
|
||||
if (authorizedTxs.length > 0) {
|
||||
const confirmedTxs = txs.filter(tx => R.contains(tx.status, ['instant', 'confirmed']))
|
||||
if (confirmedTxs.length > 0) {
|
||||
const maxTx = R.reduce((acc, val) => {
|
||||
!acc || val.cryptoAtoms.gt(acc.cryptoAtoms) ? val : acc
|
||||
}, null, authorizedTxs)
|
||||
return !acc || val.cryptoAtoms.gt(acc.cryptoAtoms) ? val : acc
|
||||
}, null, confirmedTxs)
|
||||
|
||||
return {tx: maxTx}
|
||||
}
|
||||
|
|
@ -827,5 +827,5 @@ exports.fetchTx = function fetchTx (session) {
|
|||
}
|
||||
|
||||
exports.requestDispense = function requestDispense (session, tx) {
|
||||
return db.addDispenseRequest(session.fingerprint, tx)
|
||||
return db.addDispenseRequest(session, tx)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue