WIP
This commit is contained in:
parent
f55e9355ef
commit
f03151d670
2 changed files with 10 additions and 11 deletions
|
|
@ -332,16 +332,8 @@ exports.trade = function trade (session, rawTrade, 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.apply(db.addOutgoingPending, session, tx.currencyCode, tx.toAddress),
|
||||
async.apply(db.addOutgoingPending, session, rawTrade.currency, rawTrade.toAddress),
|
||||
async.apply(db.recordBill, session, rawTrade)
|
||||
], cb)
|
||||
}
|
||||
|
|
@ -506,7 +498,12 @@ exports.getBalance = function getBalance (cryptoCode) {
|
|||
function purchase (trade, cb) {
|
||||
var cryptoCode = trade.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)
|
||||
pollBalance(cryptoCode)
|
||||
if (typeof cb === 'function') cb()
|
||||
|
|
@ -514,7 +511,7 @@ function purchase (trade, cb) {
|
|||
}
|
||||
|
||||
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) {
|
||||
return current.cryptoAtoms.plus(prev)
|
||||
}, new BigNumber(0))
|
||||
|
|
|
|||
2
todo.txt
2
todo.txt
|
|
@ -9,3 +9,5 @@ backwards compatibility:
|
|||
|
||||
- parse out bignumber when loading in routes
|
||||
- making a trade -- convert to units
|
||||
- clean up db stuff satoshis/cryptoAtoms
|
||||
- clean up other stuff
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue