From f03151d6707060b9c59c589862914091fc2aa795 Mon Sep 17 00:00:00 2001 From: Josh Harvey Date: Tue, 5 Apr 2016 17:53:42 +0100 Subject: [PATCH] WIP --- lib/plugins.js | 19 ++++++++----------- todo.txt | 2 ++ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/plugins.js b/lib/plugins.js index db66437b..c92f9ab3 100644 --- a/lib/plugins.js +++ b/lib/plugins.js @@ -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)) diff --git a/todo.txt b/todo.txt index d0493c65..c3230c55 100644 --- a/todo.txt +++ b/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