This commit is contained in:
Josh Harvey 2016-04-05 17:53:42 +01:00
parent f55e9355ef
commit f03151d670
2 changed files with 10 additions and 11 deletions

View file

@ -332,16 +332,8 @@ exports.trade = function trade (session, rawTrade, cb) {
return db.recordBill(session, newRawTrade, cb) return db.recordBill(session, newRawTrade, cb)
} }
var tx = {
txId: rawTrade.txId,
fiat: 0,
satoshis: 0,
toAddress: rawTrade.toAddress,
currencyCode: rawTrade.currency
}
async.parallel([ async.parallel([
async.apply(db.addOutgoingPending, session, tx.currencyCode, tx.toAddress), async.apply(db.addOutgoingPending, session, rawTrade.currency, rawTrade.toAddress),
async.apply(db.recordBill, session, rawTrade) async.apply(db.recordBill, session, rawTrade)
], cb) ], cb)
} }
@ -506,7 +498,12 @@ exports.getBalance = function getBalance (cryptoCode) {
function purchase (trade, cb) { function purchase (trade, cb) {
var cryptoCode = trade.cryptoCode var cryptoCode = trade.cryptoCode
var traderPlugin = traderPlugins[cryptoCode] var traderPlugin = traderPlugins[cryptoCode]
traderPlugin.purchase(trade.satoshis, null, function (err) { var opts = {
cryptoCode: cryptoCode,
fiat: deviceCurrency
}
traderPlugin.purchase(trade.cryptoAtoms, opts, function (err) {
if (err) return cb(err) if (err) return cb(err)
pollBalance(cryptoCode) pollBalance(cryptoCode)
if (typeof cb === 'function') cb() if (typeof cb === 'function') cb()
@ -514,7 +511,7 @@ function purchase (trade, cb) {
} }
function consolidateTrades (cryptoCode) { function consolidateTrades (cryptoCode) {
// NOTE: value in satoshis stays the same no matter the currency // NOTE: value in cryptoAtoms stays the same no matter the currency
var cryptoAtoms = tradesQueues[cryptoCode].reduce(function (prev, current) { var cryptoAtoms = tradesQueues[cryptoCode].reduce(function (prev, current) {
return current.cryptoAtoms.plus(prev) return current.cryptoAtoms.plus(prev)
}, new BigNumber(0)) }, new BigNumber(0))

View file

@ -9,3 +9,5 @@ backwards compatibility:
- parse out bignumber when loading in routes - parse out bignumber when loading in routes
- making a trade -- convert to units - making a trade -- convert to units
- clean up db stuff satoshis/cryptoAtoms
- clean up other stuff