WIP
This commit is contained in:
parent
cd1e9bdb66
commit
3e48e50757
5 changed files with 110 additions and 11 deletions
|
|
@ -1,6 +1,6 @@
|
|||
'use strict'
|
||||
|
||||
var _ = require('lodash')
|
||||
var R = require('ramda')
|
||||
var async = require('async')
|
||||
|
||||
var BigNumber = require('bignumber.js')
|
||||
|
|
@ -362,12 +362,6 @@ exports.trade = function trade (session, rawTrade, cb) {
|
|||
})
|
||||
}
|
||||
|
||||
if (!rawTrade.toAddress) {
|
||||
var newRawTrade = _.cloneDeep(rawTrade)
|
||||
newRawTrade.toAddress = 'remit'
|
||||
return db.recordBill(session, newRawTrade, cb)
|
||||
}
|
||||
|
||||
async.parallel([
|
||||
async.apply(db.addOutgoingPending, session, rawTrade.currency, rawTrade.cryptoCode, rawTrade.toAddress),
|
||||
async.apply(db.recordBill, session, rawTrade)
|
||||
|
|
@ -412,8 +406,7 @@ exports.cashOut = function cashOut (session, tx, cb) {
|
|||
walletPlugin.newAddress(tmpInfo, function (err, address) {
|
||||
if (err) return cb(err)
|
||||
|
||||
var newTx = _.clone(tx)
|
||||
newTx.toAddress = address
|
||||
const newTx = R.assoc('toAddress', address, tx)
|
||||
db.addInitialIncoming(session, newTx, function (_err) {
|
||||
cb(_err, address)
|
||||
})
|
||||
|
|
@ -729,3 +722,28 @@ exports.getPhoneCode = function getPhoneCode (phone) {
|
|||
return smsPlugin.sendMessage(rec)
|
||||
.then(() => code)
|
||||
}
|
||||
|
||||
exports.updatePhone = function updatePhone (session, tx) {
|
||||
db.addIncomingPhone(session, tx, err => {
|
||||
if (err) return Promise.reject(err)
|
||||
return Promise.resolve()
|
||||
})
|
||||
}
|
||||
|
||||
exports.fetchPhoneTx = function fetchPhoneTx (phone) {
|
||||
db.fetchPhoneTxs(phone)
|
||||
.then(txs => {
|
||||
const authorizedTxs = txs.filter(tx => tx.authorized)
|
||||
if (authorizedTxs.length > 0) {
|
||||
return R.reduce((acc, val) => {
|
||||
!acc || val.cryptoAtoms.gt(acc.cryptoAtoms) ? val : acc
|
||||
}, null, authorizedTxs)
|
||||
}
|
||||
|
||||
if (txs.length > 0) {
|
||||
// pending txs
|
||||
}
|
||||
|
||||
// no txs for this number
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue