WIP -- running with BTC only

This commit is contained in:
Josh Harvey 2016-04-06 17:25:43 +01:00
parent f03151d670
commit d6ec60db55
3 changed files with 20 additions and 9 deletions

View file

@ -119,6 +119,8 @@ function loadOrConfigPlugin (pluginHandle, pluginType, cryptoCode, currency,
? cachedConfig.exchanges.plugins.current[pluginType] ? cachedConfig.exchanges.plugins.current[pluginType]
: cachedConfig.exchanges.plugins.current[cryptoCode][pluginType] : cachedConfig.exchanges.plugins.current[cryptoCode][pluginType]
currentlyUsedPlugins[cryptoCode] = currentlyUsedPlugins[cryptoCode] || {}
var pluginChanged = currentlyUsedPlugins[cryptoCode][pluginType] !== currentName var pluginChanged = currentlyUsedPlugins[cryptoCode][pluginType] !== currentName
if (!currentName) pluginHandle = null if (!currentName) pluginHandle = null
@ -149,7 +151,7 @@ exports.configure = function configure (config) {
cachedConfig = config cachedConfig = config
deviceCurrency = config.exchanges.settings.currency deviceCurrency = config.exchanges.settings.currency
cryptoCodes = config.exchanges.settings.coins || 'BTC' cryptoCodes = config.exchanges.settings.coins || ['BTC']
cryptoCodes.forEach(function (cryptoCode) { cryptoCodes.forEach(function (cryptoCode) {
// TICKER [required] configure (or load) // TICKER [required] configure (or load)
@ -448,8 +450,8 @@ function pollBalance (cryptoCode, cb) {
} }
function pollRate (cryptoCode, cb) { function pollRate (cryptoCode, cb) {
logger.debug('[%s] polling for rates (%s)', cryptoCode, tickerPlugin.NAME)
var tickerPlugin = tickerPlugins[cryptoCode] var tickerPlugin = tickerPlugins[cryptoCode]
logger.debug('[%s] polling for rates (%s)', cryptoCode, tickerPlugin.NAME)
var currencies = deviceCurrency var currencies = deviceCurrency
if (typeof currencies === 'string') currencies = [currencies] if (typeof currencies === 'string') currencies = [currencies]
@ -464,8 +466,14 @@ function pollRate (cryptoCode, cb) {
return cb && cb(err) return cb && cb(err)
} }
logger.debug('got rates: %j', resRates)
resRates.timestamp = new Date() resRates.timestamp = new Date()
var rates = resRates[deviceCurrency].rates
if (rates) {
rates.ask = rates.ask && new BigNumber(rates.ask)
rates.bid = rates.bid && new BigNumber(rates.bid)
}
logger.debug('got rates: %j', resRates)
lastRates[cryptoCode] = resRates lastRates[cryptoCode] = resRates
return cb && cb(null, lastRates) return cb && cb(null, lastRates)

View file

@ -1,5 +1,6 @@
'use strict' 'use strict'
var BigNumber = require('bignumber.js')
var logger = require('./logger') var logger = require('./logger')
var mock = false var mock = false
@ -101,14 +102,20 @@ function poll (req, res) {
} }
function trade (req, res) { function trade (req, res) {
plugins.trade(session(req), req.body, function (err) { var tx = req.body
tx.cryptoAtoms = new BigNumber(tx.cryptoAtoms)
plugins.trade(session(req), tx, function (err) {
var statusCode = err ? 500 : 201 var statusCode = err ? 500 : 201
res.json(statusCode, {err: err}) res.json(statusCode, {err: err})
}) })
} }
function send (req, res) { function send (req, res) {
plugins.sendCoins(session(req), req.body, function (err, status) { var tx = req.body
tx.cryptoAtoms = new BigNumber(tx.cryptoAtoms)
plugins.sendCoins(session(req), tx, function (err, status) {
// TODO: use status.statusCode here after confirming machine compatibility // TODO: use status.statusCode here after confirming machine compatibility
// FIX: (joshm) set txHash to status.txId instead of previous status.txHash which wasn't being set // FIX: (joshm) set txHash to status.txId instead of previous status.txHash which wasn't being set
// Need to clean up txHash vs txId // Need to clean up txHash vs txId

View file

@ -1,5 +1,3 @@
- specify crypto and fiat for trades
- make sure ticker is in full coins
- getDeviceRate should return bignumber - getDeviceRate should return bignumber
- test with l-m - test with l-m
@ -7,7 +5,5 @@ backwards compatibility:
- new l-m must be backwards compatible with old l-s - new l-m must be backwards compatible with old l-s
- parse out bignumber when loading in routes
- making a trade -- convert to units
- clean up db stuff satoshis/cryptoAtoms - clean up db stuff satoshis/cryptoAtoms
- clean up other stuff - clean up other stuff