WIPP
This commit is contained in:
parent
7e5515a873
commit
b16d11045c
10 changed files with 368 additions and 550 deletions
11
lib/app.js
11
lib/app.js
|
|
@ -9,7 +9,7 @@ const plugins = require('./plugins')
|
|||
const logger = require('./logger')
|
||||
var argv = require('minimist')(process.argv.slice(2))
|
||||
|
||||
const configManager = require('./config-manager')
|
||||
const settingsLoader = require('./settings-loader')
|
||||
const options = require('./options')
|
||||
|
||||
const devMode = argv.dev || argv.http || options.http
|
||||
|
|
@ -35,12 +35,10 @@ function runOnce () {
|
|||
const seedPath = options.seedPath || './seeds/seed.txt'
|
||||
plugins.init(seedPath)
|
||||
|
||||
return configManager.load()
|
||||
.then(config => {
|
||||
return plugins.configure(config)
|
||||
.then(() => {
|
||||
return settingsLoader.settings()
|
||||
.then(settings => {
|
||||
plugins.startPolling()
|
||||
plugins.startCheckingNotification()
|
||||
plugins.startCheckingNotification(settings.config)
|
||||
|
||||
const httpsServerOptions = {
|
||||
key: fs.readFileSync(options.keyPath),
|
||||
|
|
@ -76,7 +74,6 @@ function runOnce () {
|
|||
console.log('lamassu-server listening on local port ' + localPort)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {run}
|
||||
|
|
|
|||
|
|
@ -1,31 +1,10 @@
|
|||
var R = require('ramda')
|
||||
var db = require('./db')
|
||||
|
||||
function load () {
|
||||
return db.one('select data from user_config where type=$1', 'config')
|
||||
.then(function (data) {
|
||||
return data.data
|
||||
})
|
||||
}
|
||||
|
||||
function loadAccounts () {
|
||||
const toFields = fieldArr => R.fromPairs(R.map(r => [r.code, r.value], fieldArr))
|
||||
const toPairs = r => [r.code, toFields(r.fields)]
|
||||
|
||||
return db.oneOrNone('select data from user_config where type=$1', 'accounts')
|
||||
.then(function (data) {
|
||||
if (!data) return {}
|
||||
return R.fromPairs(R.map(toPairs, data.data.accounts))
|
||||
})
|
||||
}
|
||||
const R = require('ramda')
|
||||
|
||||
module.exports = {
|
||||
load,
|
||||
unscoped,
|
||||
cryptoScoped,
|
||||
machineScoped,
|
||||
scoped,
|
||||
loadAccounts
|
||||
scoped
|
||||
}
|
||||
|
||||
function matchesValue (crypto, machine, instance) {
|
||||
|
|
|
|||
36
lib/exchange.js
Normal file
36
lib/exchange.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
const settingsLoader = require('./settings-loader')
|
||||
const configManager = require('./config-manager')
|
||||
|
||||
function fetchExchange (cryptoCode) {
|
||||
return settingsLoader.settings()
|
||||
.then(settings => {
|
||||
const plugin = configManager.cryptoScoped(cryptoCode, settings.config).cryptoServices.wallet
|
||||
if (!plugin) throw new Error('No exchange plugin defined for: ' + cryptoCode)
|
||||
const account = settings.accounts.plugin
|
||||
const exchange = require('lamassu-' + plugin)
|
||||
|
||||
return {exchange, account}
|
||||
})
|
||||
}
|
||||
|
||||
function buy (cryptoAtoms, fiatCode, cryptoCode) {
|
||||
return fetchExchange(cryptoCode)
|
||||
.then(r => r.exchange.buy(r.account, cryptoAtoms, fiatCode, cryptoCode))
|
||||
}
|
||||
|
||||
function sell (cryptoAtoms, fiatCode, cryptoCode) {
|
||||
return fetchExchange(cryptoCode)
|
||||
.then(r => r.exchange.sell(r.account, cryptoAtoms, fiatCode, cryptoCode))
|
||||
}
|
||||
|
||||
function active (cryptoCode) {
|
||||
return fetchExchange(cryptoCode)
|
||||
.then(() => true)
|
||||
.catch(() => false)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
buy,
|
||||
sell,
|
||||
active
|
||||
}
|
||||
496
lib/plugins.js
496
lib/plugins.js
|
|
@ -1,9 +1,7 @@
|
|||
'use strict'
|
||||
|
||||
const fs = require('fs')
|
||||
const uuid = require('uuid')
|
||||
const R = require('ramda')
|
||||
const HKDF = require('node-hkdf-sync')
|
||||
const BigNumber = require('bignumber.js')
|
||||
|
||||
// Needed for BigNumber for now
|
||||
|
|
@ -14,13 +12,18 @@ const db = require('./postgresql_interface')
|
|||
const logger = require('./logger')
|
||||
const notifier = require('./notifier')
|
||||
const T = require('./time')
|
||||
const settingsLoader = require('./settings')
|
||||
const configManager = require('./config-manager')
|
||||
const ticker = require('./ticker')
|
||||
const wallet = require('./wallet')
|
||||
const exchange = require('./exchange')
|
||||
const sms = require('./sms')
|
||||
const email = require('./email')
|
||||
|
||||
const tradeIntervals = {}
|
||||
|
||||
const CHECK_NOTIFICATION_INTERVAL = T.minute
|
||||
const ALERT_SEND_INTERVAL = T.hour
|
||||
const POLLING_RATE = T.minute
|
||||
const INCOMING_TX_INTERVAL = 30 * T.seconds
|
||||
const LIVE_INCOMING_TX_INTERVAL = 5 * T.seconds
|
||||
const STALE_INCOMING_TX_AGE = T.week
|
||||
|
|
@ -34,22 +37,6 @@ const SWEEP_OLD_HD_INTERVAL = 2 * T.minutes
|
|||
const TRADE_INTERVAL = T.minute
|
||||
const TRADE_TTL = 5 * T.minutes
|
||||
|
||||
const tickerPlugins = {}
|
||||
const traderPlugins = {}
|
||||
const walletPlugins = {}
|
||||
let idVerifierPlugin = null
|
||||
let emailPlugin = null
|
||||
let smsPlugin = null
|
||||
let hkdf = null
|
||||
|
||||
const currentlyUsedPlugins = {}
|
||||
|
||||
let cachedConfig = null
|
||||
let deviceCurrency = 'USD'
|
||||
|
||||
const lastBalances = {}
|
||||
const lastRates = {}
|
||||
|
||||
const tradesQueues = {}
|
||||
|
||||
const coins = {
|
||||
|
|
@ -60,201 +47,9 @@ const coins = {
|
|||
let alertFingerprint = null
|
||||
let lastAlertTime = null
|
||||
|
||||
exports.init = function init (seedPath) {
|
||||
const masterSeed = new Buffer(fs.readFileSync(seedPath, 'utf8').trim(), 'hex')
|
||||
hkdf = new HKDF('sha256', 'lamassu-server-salt', masterSeed)
|
||||
}
|
||||
|
||||
function loadPlugin (name, config) {
|
||||
// plugins definitions
|
||||
const moduleMethods = {
|
||||
ticker: ['ticker'],
|
||||
trader: ['purchase', 'sell'],
|
||||
wallet: ['balance', 'sendCoins', 'newAddress'],
|
||||
idVerifier: ['verifyUser', 'verifyTransaction'],
|
||||
info: ['checkAddress'],
|
||||
email: ['sendMessage']
|
||||
}
|
||||
|
||||
let plugin = null
|
||||
|
||||
// each used plugin MUST be installed
|
||||
try {
|
||||
plugin = require('lamassu-' + name)
|
||||
} catch (err) {
|
||||
logger.debug(err.stack)
|
||||
if (err.code === 'MODULE_NOT_FOUND') {
|
||||
throw new Error(name + ' module is not installed. ' +
|
||||
'Try running \'npm install --save lamassu-' + name + '\' first')
|
||||
}
|
||||
logger.error('Error in %s plugin', name)
|
||||
logger.error(err)
|
||||
throw err
|
||||
}
|
||||
|
||||
// each plugin MUST implement those
|
||||
if (typeof plugin.SUPPORTED_MODULES !== 'undefined') {
|
||||
if (plugin.SUPPORTED_MODULES === 'string') {
|
||||
plugin.SUPPORTED_MODULES = [plugin.SUPPORTED_MODULES]
|
||||
}
|
||||
}
|
||||
|
||||
if (!(plugin.SUPPORTED_MODULES instanceof Array)) {
|
||||
throw new Error('\'' + name + '\' fails to implement *required* ' +
|
||||
'\'SUPPORTED_MODULES\' constant')
|
||||
}
|
||||
|
||||
plugin.SUPPORTED_MODULES.forEach(moduleName => {
|
||||
moduleMethods[moduleName].forEach(methodName => {
|
||||
if (typeof plugin[methodName] !== 'function') {
|
||||
throw new Error('\'' + name + '\' declares \'' + moduleName +
|
||||
'\', but fails to implement \'' + methodName + '\' method')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
// each plugin SHOULD implement those
|
||||
if (typeof plugin.NAME === 'undefined') {
|
||||
logger.warn(new Error('\'' + name +
|
||||
'\' fails to implement *recommended* \'NAME\' field'))
|
||||
}
|
||||
|
||||
if (typeof plugin.config !== 'function') {
|
||||
logger.warn(new Error('\'' + name +
|
||||
'\' fails to implement *recommended* \'config\' method'))
|
||||
plugin.config = () => {}
|
||||
} else if (config !== null) {
|
||||
plugin.config(config, logger) // only when plugin supports it, and config is passed
|
||||
}
|
||||
|
||||
return plugin
|
||||
}
|
||||
|
||||
function loadOrConfigPlugin (pluginHandle, pluginType, cryptoCode, config, accounts, options,
|
||||
onChangeCallback) {
|
||||
const currentName = config.cryptoServices[pluginType] ||
|
||||
config.extraServices[pluginType] ||
|
||||
config.compliance[pluginType]
|
||||
|
||||
currentlyUsedPlugins[cryptoCode] = currentlyUsedPlugins[cryptoCode] || {}
|
||||
|
||||
const pluginChanged = currentlyUsedPlugins[cryptoCode][pluginType] !== currentName
|
||||
|
||||
if (!currentName) pluginHandle = null
|
||||
else { // some plugins may be disabled
|
||||
const pluginConfig = accounts[currentName]
|
||||
|
||||
const mergedConfig = R.merge(pluginConfig, options)
|
||||
|
||||
if (pluginHandle && !pluginChanged) pluginHandle.config(mergedConfig)
|
||||
else {
|
||||
pluginHandle = loadPlugin(currentName, mergedConfig)
|
||||
currentlyUsedPlugins[cryptoCode] = currentlyUsedPlugins[cryptoCode] || {}
|
||||
currentlyUsedPlugins[cryptoCode][pluginType] = currentName
|
||||
const pluginName = pluginHandle.NAME || currentName
|
||||
|
||||
cryptoCode
|
||||
? logger.debug('[%s] plugin(%s) loaded: %s', cryptoCode, pluginType, pluginName)
|
||||
: logger.debug('plugin(%s) loaded: %s', pluginType, pluginName)
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof onChangeCallback === 'function') onChangeCallback(pluginHandle)
|
||||
|
||||
return pluginHandle
|
||||
}
|
||||
exports.loadOrConfigPlugin = loadOrConfigPlugin
|
||||
|
||||
// Note: this whole function gets called every time there's a config update
|
||||
exports.configure = function configure (config) {
|
||||
cachedConfig = config
|
||||
|
||||
const cryptoCodes = getAllCryptoCodes()
|
||||
|
||||
return configManager.loadAccounts()
|
||||
.then(accounts => {
|
||||
cryptoCodes.forEach(cryptoCode => {
|
||||
const cryptoScopedConfig = configManager.cryptoScoped(cryptoCode, cachedConfig)
|
||||
|
||||
// TICKER [required] configure (or load)
|
||||
loadOrConfigPlugin(
|
||||
tickerPlugins[cryptoCode],
|
||||
'ticker',
|
||||
cryptoCode,
|
||||
cryptoScopedConfig,
|
||||
accounts,
|
||||
{currency: deviceCurrency},
|
||||
function onTickerChange (newTicker) {
|
||||
tickerPlugins[cryptoCode] = newTicker
|
||||
cache.clearRate()
|
||||
}
|
||||
)
|
||||
|
||||
// Give each crypto a different derived seed so as not to allow any
|
||||
// plugin to spend another plugin's funds
|
||||
const cryptoSeed = hkdf.derive(cryptoCode, 32)
|
||||
|
||||
loadOrConfigPlugin(
|
||||
walletPlugins[cryptoCode],
|
||||
'wallet',
|
||||
cryptoCode,
|
||||
cryptoScopedConfig,
|
||||
accounts,
|
||||
{masterSeed: cryptoSeed},
|
||||
function onWalletChange (newWallet) {
|
||||
walletPlugins[cryptoCode] = newWallet
|
||||
pollBalance(cryptoCode)
|
||||
}
|
||||
)
|
||||
|
||||
tradesQueues[cryptoCode] = tradesQueues[cryptoCode] || []
|
||||
|
||||
loadOrConfigPlugin(
|
||||
traderPlugins[cryptoCode],
|
||||
'trader',
|
||||
cryptoCode,
|
||||
cryptoScopedConfig,
|
||||
accounts,
|
||||
null,
|
||||
function onTraderChange (newTrader) {
|
||||
traderPlugins[cryptoCode] = newTrader
|
||||
if (newTrader === null) stopTrader(cryptoCode)
|
||||
else startTrader(cryptoCode)
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
const unscopedCfg = configManager.unscoped(cachedConfig)
|
||||
|
||||
// ID VERIFIER [optional] configure (or load)
|
||||
idVerifierPlugin = loadOrConfigPlugin(
|
||||
idVerifierPlugin,
|
||||
'idVerifier',
|
||||
null,
|
||||
unscopedCfg,
|
||||
accounts
|
||||
)
|
||||
|
||||
emailPlugin = loadOrConfigPlugin(
|
||||
emailPlugin,
|
||||
'email',
|
||||
null,
|
||||
unscopedCfg,
|
||||
accounts
|
||||
)
|
||||
|
||||
smsPlugin = loadOrConfigPlugin(
|
||||
smsPlugin,
|
||||
'sms',
|
||||
null,
|
||||
unscopedCfg,
|
||||
accounts
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
function getConfig (machineId) {
|
||||
return configManager.machineScoped(machineId, cachedConfig)
|
||||
const config = settingsLoader.settings().config
|
||||
return configManager.machineScoped(machineId, config)
|
||||
}
|
||||
|
||||
exports.getConfig = getConfig
|
||||
|
|
@ -288,22 +83,16 @@ exports.pollQueries = function pollQueries (deviceId) {
|
|||
}))
|
||||
}
|
||||
|
||||
function _sendCoins (toAddress, cryptoAtoms, cryptoCode) {
|
||||
const walletPlugin = walletPlugins[cryptoCode]
|
||||
return walletPlugin.sendCoins(toAddress, cryptoAtoms.toNumber(), cryptoCode)
|
||||
}
|
||||
|
||||
// NOTE: This will fail if we have already sent coins because there will be
|
||||
// a db unique db record in the table already.
|
||||
function executeTx (deviceId, tx) {
|
||||
return db.addOutgoingTx(deviceId, tx)
|
||||
.then(() => _sendCoins(tx.toAddress, tx.cryptoAtoms, tx.cryptoCode))
|
||||
.then(() => wallet.sendCoins(tx.toAddress, tx.cryptoAtoms, tx.cryptoCode))
|
||||
.then(txHash => {
|
||||
const fee = null // Need to fill this out in plugins
|
||||
const toSend = {cryptoAtoms: tx.cryptoAtoms, fiat: tx.fiat}
|
||||
|
||||
return db.sentCoins(tx, toSend, fee, null, txHash)
|
||||
.then(() => pollBalance(tx.cryptoCode))
|
||||
.then(() => ({
|
||||
statusCode: 201, // Created
|
||||
txHash,
|
||||
|
|
@ -316,10 +105,13 @@ function executeTx (deviceId, tx) {
|
|||
exports.trade = function trade (deviceId, rawTrade) {
|
||||
// TODO: move this to DB, too
|
||||
// add bill to trader queue (if trader is enabled)
|
||||
const cryptoCode = rawTrade.cryptoCode || 'BTC'
|
||||
const traderPlugin = traderPlugins[cryptoCode]
|
||||
const cryptoCode = rawTrade.cryptoCode
|
||||
|
||||
return db.recordBill(deviceId, rawTrade)
|
||||
.then(() => exchange.active(cryptoCode))
|
||||
.then(active => {
|
||||
if (!active) return
|
||||
|
||||
if (traderPlugin) {
|
||||
logger.debug('[%s] Pushing trade: %d', cryptoCode, rawTrade.cryptoAtoms)
|
||||
tradesQueues[cryptoCode].push({
|
||||
currency: rawTrade.currency,
|
||||
|
|
@ -327,9 +119,7 @@ exports.trade = function trade (deviceId, rawTrade) {
|
|||
cryptoCode,
|
||||
timestamp: Date.now()
|
||||
})
|
||||
}
|
||||
|
||||
return db.recordBill(deviceId, rawTrade)
|
||||
})
|
||||
}
|
||||
|
||||
exports.stateChange = function stateChange (deviceId, deviceTime, rec, cb) {
|
||||
|
|
@ -359,22 +149,21 @@ exports.sendCoins = function sendCoins (deviceId, rawTx) {
|
|||
}
|
||||
|
||||
exports.cashOut = function cashOut (deviceId, tx) {
|
||||
const cryptoCode = tx.cryptoCode || 'BTC'
|
||||
const walletPlugin = walletPlugins[cryptoCode]
|
||||
const cryptoCode = tx.cryptoCode
|
||||
|
||||
const serialPromise = walletPlugin.supportsHD
|
||||
const serialPromise = wallet.supportsHD
|
||||
? db.nextCashOutSerialHD(tx.id, cryptoCode)
|
||||
: Promise.resolve()
|
||||
|
||||
return serialPromise
|
||||
.then(serialNumber => {
|
||||
const tmpInfo = {
|
||||
const info = {
|
||||
label: 'TX ' + Date.now(),
|
||||
account: 'deposit',
|
||||
serialNumber
|
||||
}
|
||||
|
||||
return walletPlugin.newAddress(tmpInfo)
|
||||
return wallet.newAddress(cryptoCode, info)
|
||||
.then(address => {
|
||||
const newTx = R.assoc('toAddress', address, tx)
|
||||
|
||||
|
|
@ -392,19 +181,17 @@ exports.dispenseAck = function (deviceId, tx) {
|
|||
return db.addDispense(deviceId, tx, cartridges)
|
||||
}
|
||||
|
||||
exports.fiatBalance = function fiatBalance (cryptoCode, deviceId) {
|
||||
const config = configManager.scoped(cryptoCode, deviceId, cachedConfig)
|
||||
const deviceRate = exports.getDeviceRate(cryptoCode)
|
||||
exports.fiatBalance = function fiatBalance (fiatCode, cryptoCode, deviceId) {
|
||||
const _config = settingsLoader.settings().config
|
||||
const config = configManager.scoped(cryptoCode, deviceId, _config)
|
||||
|
||||
if (!deviceRate) return null
|
||||
const rawRate = deviceRate.rates.ask
|
||||
return Promise.all([ticker.ticker(cryptoCode), wallet.balance(cryptoCode)])
|
||||
.then(([rates, balanceRec]) => {
|
||||
const rawRate = rates[cryptoCode].rates.ask
|
||||
const commission = (new BigNumber(config.commissions.cashInCommission).div(100)).plus(1)
|
||||
const lastBalanceRec = lastBalances[cryptoCode]
|
||||
if (!lastBalanceRec) return null
|
||||
const balance = balanceRec.balance
|
||||
|
||||
const lastBalance = lastBalanceRec.balance
|
||||
|
||||
if (!rawRate || !lastBalance) return null
|
||||
if (!rawRate || !balance) return null
|
||||
|
||||
// The rate is actually our commission times real rate.
|
||||
const rate = rawRate.times(commission)
|
||||
|
|
@ -414,23 +201,15 @@ exports.fiatBalance = function fiatBalance (cryptoCode, deviceId) {
|
|||
const lowBalanceMargin = (new BigNumber(config.commissions.lowBalanceMargin).div(100)).plus(1)
|
||||
|
||||
const unitScale = new BigNumber(10).pow(coins[cryptoCode].unitScale)
|
||||
const fiatTransferBalance = lastBalance.div(unitScale).times(rate).div(lowBalanceMargin)
|
||||
const fiatTransferBalance = balance.div(unitScale).times(rate).div(lowBalanceMargin)
|
||||
|
||||
return {timestamp: lastBalanceRec.timestamp, balance: fiatTransferBalance.round(3).toNumber()}
|
||||
return {timestamp: balanceRec.timestamp, balance: fiatTransferBalance.round(3).toNumber()}
|
||||
})
|
||||
}
|
||||
|
||||
function processTxStatus (tx) {
|
||||
const cryptoCode = tx.cryptoCode
|
||||
const walletPlugin = walletPlugins[cryptoCode]
|
||||
|
||||
if (!walletPlugin) return logger.warn('Trying to check tx status but no wallet plugins for: ' + cryptoCode)
|
||||
|
||||
return walletPlugin.getStatus(tx.toAddress, tx.cryptoAtoms)
|
||||
return wallet.getStatus(tx.toAddress, tx.cryptoAtoms, tx.cryptoCode)
|
||||
.then(res => db.updateTxStatus(tx, res.status))
|
||||
.catch(err => {
|
||||
console.log(err.stack)
|
||||
logger.error('[%s] Tx status processing error: %s', cryptoCode, err.stack)
|
||||
})
|
||||
}
|
||||
|
||||
function notifyConfirmation (tx) {
|
||||
|
|
@ -444,7 +223,7 @@ function notifyConfirmation (tx) {
|
|||
}
|
||||
}
|
||||
|
||||
return smsPlugin.sendMessage(rec)
|
||||
return sms.sendMessage(rec)
|
||||
.then(() => db.updateNotify(tx))
|
||||
}
|
||||
|
||||
|
|
@ -493,172 +272,80 @@ exports.startPolling = function startPolling () {
|
|||
}
|
||||
|
||||
function startTrader (cryptoCode) {
|
||||
// Always start trading, even if we don't have a trade exchange configured,
|
||||
// since configuration can always change in `Trader#configure`.
|
||||
// `Trader#executeTrades` returns early if we don't have a trade exchange
|
||||
// configured at the moment.
|
||||
const traderPlugin = traderPlugins[cryptoCode]
|
||||
if (!traderPlugin || tradeIntervals[cryptoCode]) return
|
||||
if (tradeIntervals[cryptoCode]) return
|
||||
|
||||
logger.debug('[%s] startTrader', cryptoCode)
|
||||
|
||||
tradeIntervals[cryptoCode] = setInterval(
|
||||
() => { executeTrades(cryptoCode) },
|
||||
TRADE_INTERVAL
|
||||
)
|
||||
}
|
||||
|
||||
function stopTrader (cryptoCode) {
|
||||
if (!tradeIntervals[cryptoCode]) return
|
||||
|
||||
logger.debug('[%s] stopTrader', cryptoCode)
|
||||
clearInterval(tradeIntervals[cryptoCode])
|
||||
tradeIntervals[cryptoCode] = null
|
||||
tradesQueues[cryptoCode] = []
|
||||
}
|
||||
|
||||
function pollBalance (cryptoCode) {
|
||||
logger.debug('[%s] collecting balance', cryptoCode)
|
||||
|
||||
const walletPlugin = walletPlugins[cryptoCode]
|
||||
|
||||
return walletPlugin.balance()
|
||||
.then(balance => {
|
||||
const unitScale = new BigNumber(10).pow(coins[cryptoCode].unitScale)
|
||||
const coinBalance = new BigNumber(balance[cryptoCode])
|
||||
const scaledCoinBalance = coinBalance.div(unitScale)
|
||||
logger.debug('[%s] Balance update: %s', cryptoCode, scaledCoinBalance.toString())
|
||||
lastBalances[cryptoCode] = {timestamp: Date.now(), balance: coinBalance}
|
||||
|
||||
return lastBalances
|
||||
})
|
||||
.catch(err => {
|
||||
logger.error('[%s] Error loading balance: %s', cryptoCode, err.message)
|
||||
return lastBalances
|
||||
})
|
||||
}
|
||||
|
||||
/*
|
||||
* Getters | Helpers
|
||||
*/
|
||||
|
||||
exports.getDeviceRate = function getDeviceRate (cryptoCode) {
|
||||
const lastRate = lastRates[cryptoCode]
|
||||
if (!lastRate) return null
|
||||
|
||||
return lastRate[deviceCurrency]
|
||||
tradeIntervals[cryptoCode] = setInterval(() => executeTrades(cryptoCode), TRADE_INTERVAL)
|
||||
}
|
||||
|
||||
/*
|
||||
* Trader functions
|
||||
*/
|
||||
function purchase (trade, cb) {
|
||||
const cryptoCode = trade.cryptoCode
|
||||
const traderPlugin = traderPlugins[cryptoCode]
|
||||
|
||||
traderPlugin.purchase(trade.cryptoAtoms, deviceCurrency, cryptoCode, err => {
|
||||
if (err) return cb(err)
|
||||
pollBalance(cryptoCode)
|
||||
if (typeof cb === 'function') cb()
|
||||
})
|
||||
function buy (trade) {
|
||||
return exchange.buy(trade.cryptoAtoms, trade.fiatCode, trade.cryptoCode)
|
||||
}
|
||||
|
||||
function consolidateTrades (cryptoCode) {
|
||||
// NOTE: value in cryptoAtoms stays the same no matter the currency
|
||||
function consolidateTrades (cryptoCode, fiatCode) {
|
||||
const market = [fiatCode, cryptoCode].join('')
|
||||
|
||||
if (tradesQueues[cryptoCode].length === 0) return null
|
||||
if (tradesQueues[market].length === 0) return null
|
||||
|
||||
logger.debug('tradesQueues size: %d', tradesQueues[cryptoCode].length)
|
||||
logger.debug('tradesQueues head: %j', tradesQueues[cryptoCode][0])
|
||||
logger.debug('[%s] tradesQueues size: %d', market, tradesQueues[market].length)
|
||||
logger.debug('[%s] tradesQueues head: %j', market, tradesQueues[market][0])
|
||||
|
||||
const t0 = Date.now()
|
||||
|
||||
const filtered = tradesQueues[cryptoCode]
|
||||
const filtered = tradesQueues[market]
|
||||
.filter(trade => t0 - trade.timestamp < TRADE_TTL)
|
||||
|
||||
const filteredCount = tradesQueues[cryptoCode].length - filtered.length
|
||||
const filteredCount = tradesQueues[market].length - filtered.length
|
||||
|
||||
if (filteredCount > 0) {
|
||||
tradesQueues[cryptoCode] = filtered
|
||||
logger.debug('[%s] expired %d trades', cryptoCode, filteredCount)
|
||||
tradesQueues[market] = filtered
|
||||
logger.debug('[%s] expired %d trades', market, filteredCount)
|
||||
}
|
||||
|
||||
const cryptoAtoms = filtered
|
||||
.reduce((prev, current) => prev.plus(current.cryptoAtoms), new BigNumber(0))
|
||||
|
||||
const consolidatedTrade = {
|
||||
currency: deviceCurrency,
|
||||
fiatCode,
|
||||
cryptoAtoms,
|
||||
cryptoCode
|
||||
}
|
||||
|
||||
tradesQueues[cryptoCode] = []
|
||||
tradesQueues[market] = []
|
||||
|
||||
logger.debug('[%s] consolidated: %j', cryptoCode, consolidatedTrade)
|
||||
logger.debug('[%s] consolidated: %j', market, consolidatedTrade)
|
||||
return consolidatedTrade
|
||||
}
|
||||
|
||||
function executeTrades (cryptoCode) {
|
||||
const traderPlugin = traderPlugins[cryptoCode]
|
||||
if (!traderPlugin) return
|
||||
function executeTrades (cryptoCode, fiatCode) {
|
||||
const market = [fiatCode, cryptoCode].join('')
|
||||
logger.debug('[%s] checking for trades', market)
|
||||
|
||||
logger.debug('[%s] checking for trades', cryptoCode)
|
||||
|
||||
const trade = consolidateTrades(cryptoCode)
|
||||
if (trade === null) return logger.debug('[%s] no trades', cryptoCode)
|
||||
const trade = consolidateTrades(cryptoCode, fiatCode)
|
||||
if (trade === null) return logger.debug('[%s] no trades', market)
|
||||
|
||||
if (trade.cryptoAtoms.eq(0)) {
|
||||
logger.debug('[%s] rejecting 0 trade', cryptoCode)
|
||||
logger.debug('[%s] rejecting 0 trade', market)
|
||||
return
|
||||
}
|
||||
|
||||
logger.debug('making a trade: %d', trade.cryptoAtoms.toString())
|
||||
purchase(trade, err => {
|
||||
if (err) {
|
||||
tradesQueues[cryptoCode].push(trade)
|
||||
if (err.name !== 'orderTooSmall') return logger.error(err)
|
||||
else return logger.debug(err)
|
||||
}
|
||||
logger.debug('Successful trade.')
|
||||
})
|
||||
}
|
||||
|
||||
/*
|
||||
* ID Verifier functions
|
||||
*/
|
||||
exports.verifyUser = function verifyUser (data, cb) {
|
||||
return new Promise((resolve, reject) => {
|
||||
idVerifierPlugin.verifyUser(data, (err, res) => {
|
||||
if (err) return reject(err)
|
||||
return resolve(res)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
exports.verifyTx = function verifyTx (data, cb) {
|
||||
return new Promise((resolve, reject) => {
|
||||
idVerifierPlugin.verifyTransaction(data, (err, res) => {
|
||||
if (err) return reject(err)
|
||||
return resolve(res)
|
||||
logger.debug('[%s] making a trade: %d', market, trade.cryptoAtoms.toString())
|
||||
return buy(trade)
|
||||
.catch(err => {
|
||||
tradesQueues[market].push(trade)
|
||||
logger.error(err)
|
||||
})
|
||||
.then(() => {
|
||||
logger.debug('[%s] Successful trade.', market)
|
||||
})
|
||||
}
|
||||
|
||||
function sendMessage (rec) {
|
||||
const pluginPromises = []
|
||||
const config = configManager.unscoped(cachedConfig)
|
||||
|
||||
if (!config.notifications.notificationsEnabled) return Promise.all([])
|
||||
|
||||
if (config.notifications.notificationsEmailEnabled) {
|
||||
pluginPromises.push(emailPlugin.sendMessage(rec))
|
||||
}
|
||||
|
||||
if (config.notifications.notificationsSMSEnabled) {
|
||||
pluginPromises.push(smsPlugin.sendMessage(rec))
|
||||
}
|
||||
|
||||
return Promise.all(pluginPromises)
|
||||
return Promise.all([sms.sendMessage(rec), email.sendMessage(rec)])
|
||||
}
|
||||
exports.sendMessage = sendMessage
|
||||
|
||||
|
|
@ -715,36 +402,54 @@ function checkNotification () {
|
|||
}
|
||||
|
||||
function getCryptoCodes (deviceId) {
|
||||
return configManager.machineScoped(deviceId, cachedConfig).currencies.cryptoCurrencies
|
||||
return settingsLoader.settings()
|
||||
.then(settings => {
|
||||
return configManager.machineScoped(deviceId, settings.config).currencies.cryptoCurrencies
|
||||
})
|
||||
}
|
||||
exports.getCryptoCodes = getCryptoCodes
|
||||
|
||||
// Get union of all cryptoCodes from all machines
|
||||
function getAllCryptoCodes () {
|
||||
return db.devices()
|
||||
.then(rows => {
|
||||
return Promise.all([db.devices(), settingsLoader.settings()])
|
||||
.then(([rows, settings]) => {
|
||||
return rows.reduce((acc, r) => {
|
||||
getCryptoCodes(r.device_id).forEach(c => acc.add(c))
|
||||
const cryptoCodes = configManager.machineScoped(r.device_id, settings.config).currencies.cryptoCurrencies
|
||||
cryptoCodes.forEach(c => acc.add(c))
|
||||
return acc
|
||||
}, new Set())
|
||||
})
|
||||
}
|
||||
|
||||
function getAllMarkets () {
|
||||
return Promise.all([db.devices(), settingsLoader.settings()])
|
||||
.then(([rows, settings]) => {
|
||||
return rows.reduce((acc, r) => {
|
||||
const currencies = configManager.machineScoped(r.device_id, settings.config).currencies
|
||||
const cryptoCodes = currencies.cryptoCurrencies
|
||||
const fiatCodes = currencies.fiatCodes
|
||||
fiatCodes.forEach(fiatCode => cryptoCodes.forEach(cryptoCode => acc.add(fiatCode + cryptoCode)))
|
||||
return acc
|
||||
}, new Set())
|
||||
})
|
||||
}
|
||||
|
||||
function checkBalances () {
|
||||
return Promise.all([getAllCryptoCodes(), db.devices()])
|
||||
.then(arr => {
|
||||
const cryptoCodes = arr[0]
|
||||
const deviceIds = arr[1].map(r => r.device_id)
|
||||
return Promise.all([getAllMarkets(), db.devices()])
|
||||
.then(([markets, devices]) => {
|
||||
const deviceIds = devices.map(r => r.device_id)
|
||||
const balances = []
|
||||
|
||||
cryptoCodes.forEach(cryptoCode => {
|
||||
markets.forEach(market => {
|
||||
const fiatCode = market.fiatCode
|
||||
const cryptoCode = market.cryptoCode
|
||||
const minBalance = deviceIds.map(deviceId => {
|
||||
const fiatBalanceRec = exports.fiatBalance(cryptoCode, deviceId)
|
||||
const fiatBalanceRec = exports.fiatBalance(fiatCode, cryptoCode, deviceId)
|
||||
return fiatBalanceRec ? fiatBalanceRec.balance : Infinity
|
||||
})
|
||||
.reduce((min, cur) => Math.min(min, cur), Infinity)
|
||||
|
||||
const rec = {fiatBalance: minBalance, cryptoCode, fiatCode: deviceCurrency}
|
||||
const rec = {fiatBalance: minBalance, cryptoCode, fiatCode}
|
||||
balances.push(rec)
|
||||
})
|
||||
|
||||
|
|
@ -752,15 +457,16 @@ function checkBalances () {
|
|||
})
|
||||
}
|
||||
|
||||
exports.startCheckingNotification = function startCheckingNotification () {
|
||||
const config = configManager.unscoped(cachedConfig)
|
||||
exports.startCheckingNotification = function startCheckingNotification (config) {
|
||||
notifier.init(db, checkBalances, config.notifications)
|
||||
checkNotification()
|
||||
setInterval(checkNotification, CHECK_NOTIFICATION_INTERVAL)
|
||||
}
|
||||
|
||||
exports.getPhoneCode = function getPhoneCode (phone) {
|
||||
const code = smsPlugin.NAME === 'MockSMS'
|
||||
return sms.name()
|
||||
.then(name => {
|
||||
const code = name === 'MockSMS'
|
||||
? '123'
|
||||
: BigNumber.random().toFixed(6).slice(2)
|
||||
|
||||
|
|
@ -771,8 +477,9 @@ exports.getPhoneCode = function getPhoneCode (phone) {
|
|||
}
|
||||
}
|
||||
|
||||
return smsPlugin.sendMessage(rec)
|
||||
return sms.sendMessage(rec)
|
||||
.then(() => code)
|
||||
})
|
||||
}
|
||||
|
||||
exports.updatePhone = db.addIncomingPhone
|
||||
|
|
@ -803,13 +510,8 @@ exports.fetchTx = db.fetchTx
|
|||
|
||||
function sweepHD (row) {
|
||||
const cryptoCode = row.crypto_code
|
||||
const walletPlugin = walletPlugins[cryptoCode]
|
||||
|
||||
if (!walletPlugin) {
|
||||
return logger.warn('Trying to sweep but no plugin set up for: ' + cryptoCode)
|
||||
}
|
||||
|
||||
return walletPlugin.sweep(row.hd_serial)
|
||||
return wallet.sweep(row.hd_serial)
|
||||
.then(txHash => {
|
||||
if (txHash) {
|
||||
logger.debug('[%s] Swept address with tx: %s', cryptoCode, txHash)
|
||||
|
|
|
|||
|
|
@ -47,10 +47,11 @@ function buildRates (deviceId) {
|
|||
|
||||
function buildBalances (deviceId) {
|
||||
const cryptoCodes = plugins.getCryptoCodes(deviceId)
|
||||
|
||||
const fiatCode = plugins.getFiatCode(deviceId)
|
||||
const _balances = {}
|
||||
|
||||
cryptoCodes.forEach(cryptoCode => {
|
||||
const balanceRec = plugins.fiatBalance(cryptoCode, deviceId)
|
||||
const balanceRec = plugins.fiatBalance(fiatCode, cryptoCode, deviceId)
|
||||
if (!balanceRec) return logger.warn('No balance for ' + cryptoCode + ' yet')
|
||||
if (Date.now() - balanceRec.timestamp > STALE_BALANCE) return logger.warn('Stale balance for ' + cryptoCode)
|
||||
|
||||
|
|
|
|||
43
lib/settings-loader.js
Normal file
43
lib/settings-loader.js
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
const R = require('ramda')
|
||||
|
||||
const db = require('./db')
|
||||
|
||||
// Note: We won't prematurely optimize by caching yet
|
||||
// This shouldn't really affect performance at these scales
|
||||
|
||||
function load () {
|
||||
return Promise.all([
|
||||
db.one('select data from user_config where type=$1', 'config'),
|
||||
loadAccounts()
|
||||
])
|
||||
.then(function ([data, accounts]) {
|
||||
return {
|
||||
config: data.data,
|
||||
accounts: accounts
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function loadAccounts () {
|
||||
const toFields = fieldArr => R.fromPairs(R.map(r => [r.code, r.value], fieldArr))
|
||||
const toPairs = r => [r.code, toFields(r.fields)]
|
||||
|
||||
return db.oneOrNone('select data from user_config where type=$1', 'accounts')
|
||||
.then(function (data) {
|
||||
if (!data) return {}
|
||||
return R.fromPairs(R.map(toPairs, data.data.accounts))
|
||||
})
|
||||
}
|
||||
|
||||
function settings () {
|
||||
return load()
|
||||
}
|
||||
|
||||
function clear () {
|
||||
// Do nothing, since no caching
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
settings,
|
||||
clear
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
const mem = require('mem')
|
||||
const settingsLoader = require('./settings-loader')
|
||||
const configManager = require('./config-manager')
|
||||
|
||||
const FETCH_INTERVAL = 10000
|
||||
function getRates (fiatCode, cryptoCode) {
|
||||
return Promise.resolve()
|
||||
.then(() => {
|
||||
return settingsLoader.settings()
|
||||
.then(settings => {
|
||||
const config = settings.config
|
||||
const plugin = configManager.cryptoScoped(cryptoCode, config).cryptoServices.ticker
|
||||
const account = settings.accounts.plugin
|
||||
const ticker = require('lamassu-' + plugin)
|
||||
|
||||
return ticker.ticker(account, fiatCode, cryptoCode)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getRates: mem(getRates, {maxAge: FETCH_INTERVAL})
|
||||
}
|
||||
50
lib/wallet.js
Normal file
50
lib/wallet.js
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
const mem = require('mem')
|
||||
const settingsLoader = require('./settings-loader')
|
||||
const configManager = require('./config-manager')
|
||||
|
||||
const FETCH_INTERVAL = 5000
|
||||
|
||||
function fetchWallet (cryptoCode) {
|
||||
return settingsLoader.settings()
|
||||
.then(settings => {
|
||||
const plugin = configManager.cryptoScoped(cryptoCode, settings.config).cryptoServices.wallet
|
||||
const account = settings.accounts.plugin
|
||||
const wallet = require('lamassu-' + plugin)
|
||||
|
||||
return {wallet, account}
|
||||
})
|
||||
}
|
||||
|
||||
function balance (cryptoCode) {
|
||||
return fetchWallet(cryptoCode)
|
||||
.then(r => r.wallet.balance(r.account))
|
||||
.then(balance => ({balance, timestamp: Date.now()}))
|
||||
}
|
||||
|
||||
function sendCoins (toAddress, cryptoAtoms, cryptoCode) {
|
||||
return fetchWallet(cryptoCode)
|
||||
.then(r => {
|
||||
return r.wallet.sendCoins(r.account, toAddress, cryptoAtoms, cryptoCode)
|
||||
.then(res => {
|
||||
mem.clear(module.exports.balance)
|
||||
return res
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function newAddress (cryptoCode, info) {
|
||||
return fetchWallet(cryptoCode)
|
||||
.then(r => r.wallet.newAddress(r.account, cryptoCode, info))
|
||||
}
|
||||
|
||||
function getStatus (toAdress, cryptoAtoms, cryptoCode) {
|
||||
return fetchWallet(cryptoCode)
|
||||
.then(r => r.wallet.getStatus(r.account, toAdress, cryptoAtoms, cryptoCode))
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
balance: mem(balance, {maxAge: FETCH_INTERVAL}),
|
||||
sendCoins,
|
||||
newAddress,
|
||||
getStatus
|
||||
}
|
||||
|
|
@ -22,6 +22,7 @@
|
|||
"lamassu-mock-sms": "^1.0.1",
|
||||
"lamassu-mock-wallet": "^1.0.3",
|
||||
"lamassu-twilio": "^1.1.3",
|
||||
"mem": "^1.1.0",
|
||||
"migrate": "^0.2.2",
|
||||
"minimist": "^1.2.0",
|
||||
"morgan": "^1.7.0",
|
||||
|
|
|
|||
146
yarn.lock
146
yarn.lock
|
|
@ -104,7 +104,7 @@ async@^1.4.0, async@^1.5.2:
|
|||
version "1.5.2"
|
||||
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"
|
||||
|
||||
async@^2.0.1, async@^2.1.2:
|
||||
async@^2.0.1:
|
||||
version "2.1.4"
|
||||
resolved "https://registry.yarnpkg.com/async/-/async-2.1.4.tgz#2d2160c7788032e4dd6cbe2502f1f9a2c8f6cde4"
|
||||
dependencies:
|
||||
|
|
@ -130,6 +130,12 @@ aws4@^1.2.1:
|
|||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.5.0.tgz#0a29ffb79c31c9e712eeb087e8e7a64b4a56d755"
|
||||
|
||||
axios@^0.15.2:
|
||||
version "0.15.2"
|
||||
resolved "https://registry.yarnpkg.com/axios/-/axios-0.15.2.tgz#496f50980b2ce1ad2e195af93c2d03b4d035e90d"
|
||||
dependencies:
|
||||
follow-redirects "0.0.7"
|
||||
|
||||
balanced-match@^0.4.1:
|
||||
version "0.4.2"
|
||||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838"
|
||||
|
|
@ -152,10 +158,6 @@ bcrypt-pbkdf@^1.0.0:
|
|||
dependencies:
|
||||
tweetnacl "^0.14.3"
|
||||
|
||||
big.js@^3.1.3:
|
||||
version "3.1.3"
|
||||
resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.1.3.tgz#4cada2193652eb3ca9ec8e55c9015669c9806978"
|
||||
|
||||
bigi@^1.1.0, bigi@^1.4.0:
|
||||
version "1.4.2"
|
||||
resolved "https://registry.yarnpkg.com/bigi/-/bigi-1.4.2.tgz#9c665a95f88b8b08fc05cfd731f561859d725825"
|
||||
|
|
@ -176,7 +178,7 @@ bindings@^1.2.1:
|
|||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.2.1.tgz#14ad6113812d2d37d72e67b4cacb4bb726505f11"
|
||||
|
||||
bip66@^1.1.0, bip66@^1.1.3:
|
||||
bip66@^1.1.0:
|
||||
version "1.1.4"
|
||||
resolved "https://registry.yarnpkg.com/bip66/-/bip66-1.1.4.tgz#8a59f8ae16eccb94681c3c2a7b224774605aadfb"
|
||||
|
||||
|
|
@ -200,13 +202,12 @@ bitcoinjs-lib@2.1.4:
|
|||
typeforce "^1.5.5"
|
||||
wif "^1.1.0"
|
||||
|
||||
bitgo@^2.0.4:
|
||||
version "2.0.4"
|
||||
resolved "https://registry.yarnpkg.com/bitgo/-/bitgo-2.0.4.tgz#83757c8cbb8481b5011c50b1eea4769d52ebabf6"
|
||||
bitgo@^1.5.4:
|
||||
version "1.8.0"
|
||||
resolved "https://registry.yarnpkg.com/bitgo/-/bitgo-1.8.0.tgz#f7180fe377139dd062b0829e0290250ce22d51fd"
|
||||
dependencies:
|
||||
argparse "^0.1.16"
|
||||
assert "0.4.9"
|
||||
big.js "^3.1.3"
|
||||
bigi "1.4.0"
|
||||
bitcoinjs-lib "2.1.4"
|
||||
body-parser "^1.10.2"
|
||||
|
|
@ -214,12 +215,9 @@ bitgo@^2.0.4:
|
|||
bs58check "1.0.4"
|
||||
create-hmac "^1.1.4"
|
||||
ecurve "^1.0.2"
|
||||
ethereumjs-abi "^0.6.2"
|
||||
ethereumjs-util "^4.4.1"
|
||||
express "^4.11.1"
|
||||
http-proxy "1.11.1"
|
||||
keccakjs "^0.2.1"
|
||||
lodash "4.13.1"
|
||||
lodash "3.7.0"
|
||||
minimist "0.2.0"
|
||||
moment "^2.11.2"
|
||||
morgan "1.5.3"
|
||||
|
|
@ -240,7 +238,7 @@ bluebird@*, bluebird@^3.3.5:
|
|||
version "3.4.6"
|
||||
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.4.6.tgz#01da8d821d87813d158967e743d5fe6c62cf8c0f"
|
||||
|
||||
bn.js@^4.10.0, bn.js@^4.11.3, bn.js@^4.4.0, bn.js@^4.8.0:
|
||||
bn.js@^4.10.0, bn.js@^4.4.0:
|
||||
version "4.11.6"
|
||||
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.6.tgz#53344adb14617a13f6e8dd2ce28905d1c0ba3215"
|
||||
|
||||
|
|
@ -290,12 +288,6 @@ browserify-aes@^1.0.6:
|
|||
evp_bytestokey "^1.0.0"
|
||||
inherits "^2.0.1"
|
||||
|
||||
browserify-sha3@^0.0.1:
|
||||
version "0.0.1"
|
||||
resolved "https://registry.yarnpkg.com/browserify-sha3/-/browserify-sha3-0.0.1.tgz#3ff34a3006ef15c0fb3567e541b91a2340123d11"
|
||||
dependencies:
|
||||
js-sha3 "^0.3.1"
|
||||
|
||||
bs58@^2.0.1, bs58@2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/bs58/-/bs58-2.0.1.tgz#55908d58f1982aba2008fa1bed8f91998a29bf8d"
|
||||
|
|
@ -627,7 +619,7 @@ dont-sniff-mimetype@1.0.0:
|
|||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/dont-sniff-mimetype/-/dont-sniff-mimetype-1.0.0.tgz#5932890dc9f4e2f19e5eb02a20026e5e5efc8f58"
|
||||
|
||||
drbg.js@^1.0.0, drbg.js@^1.0.1:
|
||||
drbg.js@^1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/drbg.js/-/drbg.js-1.0.1.tgz#3e36b6c42b37043823cdbc332d58f31e2445480b"
|
||||
dependencies:
|
||||
|
|
@ -723,23 +715,6 @@ etag@~1.7.0:
|
|||
version "1.7.0"
|
||||
resolved "https://registry.yarnpkg.com/etag/-/etag-1.7.0.tgz#03d30b5f67dd6e632d2945d30d6652731a34d5d8"
|
||||
|
||||
ethereumjs-abi@^0.6.2:
|
||||
version "0.6.4"
|
||||
resolved "https://registry.yarnpkg.com/ethereumjs-abi/-/ethereumjs-abi-0.6.4.tgz#9ba1bb056492d00c27279f6eccd4d58275912c1a"
|
||||
dependencies:
|
||||
bn.js "^4.10.0"
|
||||
ethereumjs-util "^4.3.0"
|
||||
|
||||
ethereumjs-util@^4.3.0, ethereumjs-util@^4.4.1:
|
||||
version "4.5.0"
|
||||
resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-4.5.0.tgz#3e9428b317eebda3d7260d854fddda954b1f1bc6"
|
||||
dependencies:
|
||||
bn.js "^4.8.0"
|
||||
create-hash "^1.1.2"
|
||||
keccakjs "^0.2.0"
|
||||
rlp "^2.0.0"
|
||||
secp256k1 "^3.0.1"
|
||||
|
||||
eventemitter3@1.x.x:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-1.2.0.tgz#1c86991d816ad1e504750e73874224ecf3bec508"
|
||||
|
|
@ -831,6 +806,13 @@ find-up@^1.0.0:
|
|||
path-exists "^2.0.0"
|
||||
pinkie-promise "^2.0.0"
|
||||
|
||||
follow-redirects@0.0.7:
|
||||
version "0.0.7"
|
||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-0.0.7.tgz#34b90bab2a911aa347571da90f22bd36ecd8a919"
|
||||
dependencies:
|
||||
debug "^2.2.0"
|
||||
stream-consume "^0.1.0"
|
||||
|
||||
forever-agent@~0.6.1:
|
||||
version "0.6.1"
|
||||
resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"
|
||||
|
|
@ -1172,10 +1154,6 @@ jodid25519@^1.0.0:
|
|||
dependencies:
|
||||
jsbn "~0.1.0"
|
||||
|
||||
js-sha3@^0.3.1:
|
||||
version "0.3.1"
|
||||
resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.3.1.tgz#86122802142f0828502a0d1dee1d95e253bb0243"
|
||||
|
||||
jsbn@~0.1.0:
|
||||
version "0.1.0"
|
||||
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.0.tgz#650987da0dd74f4ebf5a11377a2aa2d273e97dfd"
|
||||
|
|
@ -1256,13 +1234,6 @@ jws@^3.0.0:
|
|||
jwa "^1.1.4"
|
||||
safe-buffer "^5.0.1"
|
||||
|
||||
keccakjs@^0.2.0, keccakjs@^0.2.1:
|
||||
version "0.2.1"
|
||||
resolved "https://registry.yarnpkg.com/keccakjs/-/keccakjs-0.2.1.tgz#1d633af907ef305bbf9f2fa616d56c44561dfa4d"
|
||||
dependencies:
|
||||
browserify-sha3 "^0.0.1"
|
||||
sha3 "^1.1.0"
|
||||
|
||||
kind-of@^3.0.2:
|
||||
version "3.0.4"
|
||||
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.0.4.tgz#7b8ecf18a4e17f8269d73b501c9f232c96887a74"
|
||||
|
|
@ -1283,11 +1254,10 @@ kind-of@^3.0.2:
|
|||
version "0.2.2"
|
||||
resolved "https://github.com/lamassu/lamassu-bitgo/tarball/alpha#c8057065d2754e1e595e9d07dd33e8349e98e1b7"
|
||||
dependencies:
|
||||
bignumber.js "^2.3.0"
|
||||
bitgo "^1.5.4"
|
||||
bignumber.js "^3.0.1"
|
||||
bitgo "^2.0.4"
|
||||
lamassu-config "^0.4.4"
|
||||
lodash "^2.4.1"
|
||||
promptly "~0.2.0"
|
||||
lodash "^4.17.2"
|
||||
|
||||
lamassu-bitpay@~1.0.0:
|
||||
version "1.0.3"
|
||||
|
|
@ -1297,6 +1267,14 @@ lamassu-bitpay@~1.0.0:
|
|||
lodash "^2.4.1"
|
||||
wreck "^3.0.0"
|
||||
|
||||
"lamassu-bitstamp@https://github.com/lamassu/lamassu-bitstamp/tarball/alpha":
|
||||
version "1.0.4"
|
||||
resolved "https://github.com/lamassu/lamassu-bitstamp/tarball/alpha#bf19094bbd5eba8204792968ee480667bde3470d"
|
||||
dependencies:
|
||||
axios "^0.15.2"
|
||||
bignumber.js "^3.0.1"
|
||||
lodash "^4.17.2"
|
||||
|
||||
lamassu-coindesk@^1.0.4:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/lamassu-coindesk/-/lamassu-coindesk-1.0.4.tgz#e5c3ce422acfc8fad0264c21c3b8454e39342b2e"
|
||||
|
|
@ -1376,9 +1354,9 @@ lodash@^4.14.0, lodash@^4.17.2:
|
|||
version "4.17.2"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.2.tgz#34a3055babe04ce42467b607d700072c7ff6bf42"
|
||||
|
||||
lodash@4.13.1:
|
||||
version "4.13.1"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.13.1.tgz#83e4b10913f48496d4d16fec4a560af2ee744b68"
|
||||
lodash@3.7.0:
|
||||
version "3.7.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.7.0.tgz#3678bd8ab995057c07ade836ed2ef087da811d45"
|
||||
|
||||
longest@^1.0.1:
|
||||
version "1.0.1"
|
||||
|
|
@ -1407,6 +1385,12 @@ media-typer@0.3.0:
|
|||
version "0.3.0"
|
||||
resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
|
||||
|
||||
mem:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/mem/-/mem-1.1.0.tgz#5edd52b485ca1d900fe64895505399a0dfa45f76"
|
||||
dependencies:
|
||||
mimic-fn "^1.0.0"
|
||||
|
||||
meow@^3.3.0:
|
||||
version "3.7.0"
|
||||
resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb"
|
||||
|
|
@ -1450,6 +1434,10 @@ mime@^1.3.4, mime@1.3.4:
|
|||
version "1.3.4"
|
||||
resolved "https://registry.yarnpkg.com/mime/-/mime-1.3.4.tgz#115f9e3b6b3daf2959983cb38f149a2d40eb5d53"
|
||||
|
||||
mimic-fn@^1.0.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.1.0.tgz#e667783d92e89dbd342818b5230b9d62a672ad18"
|
||||
|
||||
"minimatch@2 || 3":
|
||||
version "3.0.3"
|
||||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774"
|
||||
|
|
@ -1509,7 +1497,11 @@ ms@0.7.1:
|
|||
version "0.7.1"
|
||||
resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098"
|
||||
|
||||
nan@^2.0.5, nan@^2.2.0, nan@^2.2.1:
|
||||
mute-stream@~0.0.4:
|
||||
version "0.0.6"
|
||||
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.6.tgz#48962b19e169fd1dfc240b3f1e7317627bbc47db"
|
||||
|
||||
nan@^2.2.0:
|
||||
version "2.4.0"
|
||||
resolved "https://registry.yarnpkg.com/nan/-/nan-2.4.0.tgz#fb3c59d45fe4effe215f0b890f8adf6eb32d2232"
|
||||
|
||||
|
|
@ -1832,6 +1824,12 @@ process-nextick-args@~1.0.6:
|
|||
version "1.0.7"
|
||||
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3"
|
||||
|
||||
promptly@~0.2.0:
|
||||
version "0.2.1"
|
||||
resolved "https://registry.yarnpkg.com/promptly/-/promptly-0.2.1.tgz#6444e7ca4dbd9899e7eeb5ec3922827ebdc22b3b"
|
||||
dependencies:
|
||||
read "~1.0.4"
|
||||
|
||||
proxy-addr@~1.1.2:
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-1.1.2.tgz#b4cc5f22610d9535824c123aef9d3cf73c40ba37"
|
||||
|
|
@ -1927,6 +1925,12 @@ read-pkg@^1.0.0:
|
|||
normalize-package-data "^2.3.2"
|
||||
path-type "^1.0.0"
|
||||
|
||||
read@~1.0.4:
|
||||
version "1.0.7"
|
||||
resolved "https://registry.yarnpkg.com/read/-/read-1.0.7.tgz#b3da19bd052431a97671d44a42634adf710b40c4"
|
||||
dependencies:
|
||||
mute-stream "~0.0.4"
|
||||
|
||||
readable-stream@^2.0.5, readable-stream@2:
|
||||
version "2.2.2"
|
||||
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.2.tgz#a9e6fec3c7dda85f8bb1b3ba7028604556fc825e"
|
||||
|
|
@ -2100,10 +2104,6 @@ ripemd160@^1.0.0:
|
|||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-1.0.1.tgz#93a4bbd4942bc574b69a8fa57c71de10ecca7d6e"
|
||||
|
||||
rlp@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/rlp/-/rlp-2.0.0.tgz#9db384ff4b89a8f61563d92395d8625b18f3afb0"
|
||||
|
||||
safe-buffer@^5.0.1:
|
||||
version "5.0.1"
|
||||
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.0.1.tgz#d263ca54696cd8a306b5ca6551e92de57918fbe7"
|
||||
|
|
@ -2112,18 +2112,6 @@ scmp@0.0.3:
|
|||
version "0.0.3"
|
||||
resolved "https://registry.yarnpkg.com/scmp/-/scmp-0.0.3.tgz#3648df2d7294641e7f78673ffc29681d9bad9073"
|
||||
|
||||
secp256k1@^3.0.1:
|
||||
version "3.2.2"
|
||||
resolved "https://registry.yarnpkg.com/secp256k1/-/secp256k1-3.2.2.tgz#2103620789ca2c9b79650cdf8cfc9c542be36597"
|
||||
dependencies:
|
||||
bindings "^1.2.1"
|
||||
bip66 "^1.1.3"
|
||||
bn.js "^4.11.3"
|
||||
create-hash "^1.1.2"
|
||||
drbg.js "^1.0.1"
|
||||
elliptic "^6.2.3"
|
||||
nan "^2.2.1"
|
||||
|
||||
secp256k1@3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/secp256k1/-/secp256k1-3.0.1.tgz#1e9205135a4ed3503150dd00e7a4eb219f2900b3"
|
||||
|
|
@ -2187,12 +2175,6 @@ sha.js@^2.3.6:
|
|||
dependencies:
|
||||
inherits "^2.0.1"
|
||||
|
||||
sha3@^1.1.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/sha3/-/sha3-1.2.0.tgz#6989f1b70a498705876a373e2c62ace96aa9399a"
|
||||
dependencies:
|
||||
nan "^2.0.5"
|
||||
|
||||
signal-exit@^3.0.0:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.1.tgz#5a4c884992b63a7acd9badb7894c3ee9cfccad81"
|
||||
|
|
@ -2297,6 +2279,10 @@ stack-trace@0.0.x:
|
|||
version "1.3.1"
|
||||
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e"
|
||||
|
||||
stream-consume@^0.1.0:
|
||||
version "0.1.0"
|
||||
resolved "https://registry.yarnpkg.com/stream-consume/-/stream-consume-0.1.0.tgz#a41ead1a6d6081ceb79f65b061901b6d8f3d1d0f"
|
||||
|
||||
stream-to-buffer@0.1.0:
|
||||
version "0.1.0"
|
||||
resolved "https://registry.yarnpkg.com/stream-to-buffer/-/stream-to-buffer-0.1.0.tgz#26799d903ab2025c9bd550ac47171b00f8dd80a9"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue