diff --git a/lib/app.js b/lib/app.js index 64eefd48..66c5a8f5 100644 --- a/lib/app.js +++ b/lib/app.js @@ -91,4 +91,5 @@ module.exports = function (options) { return server }) + .catch(e => console.log(e.stack)) } diff --git a/lib/plugins.js b/lib/plugins.js index 7418e479..460031f2 100644 --- a/lib/plugins.js +++ b/lib/plugins.js @@ -61,8 +61,6 @@ let lastAlertTime = null exports.init = function init (connectionString, seedPath) { const masterSeed = new Buffer(fs.readFileSync(seedPath, 'utf8').trim(), 'hex') hkdf = new HKDF('sha256', 'lamassu-server-salt', masterSeed) - - db.init(connectionString) } function loadPlugin (name, config) { @@ -130,9 +128,14 @@ function loadPlugin (name, config) { return plugin } -function loadOrConfigPlugin (pluginHandle, pluginType, cryptoCode, cfg, accounts, options, +function pp (o) { + console.log(require('util').inspect(o, {depth: null})) +} + +function loadOrConfigPlugin (pluginHandle, pluginType, cryptoCode, config, accounts, options, onChangeCallback) { - const currentName = cfg.cryptoServices[pluginType] + pp(config) + const currentName = config.cryptoServices[pluginType] currentlyUsedPlugins[cryptoCode] = currentlyUsedPlugins[cryptoCode] || {} @@ -175,15 +178,15 @@ exports.configure = function configure (config) { const accounts = configManager.loadAccounts() console.log('DEBUG42') - deviceCurrency = config.fiat.fiatCurrency - // cryptoCodes = config.crypto.cryptoCurrencies TODO: add to admin - console.log('DEBUG43') const cryptoCodes = getCryptoCodes() console.log('DEBUG30') cryptoCodes.forEach(cryptoCode => { - const cryptoScopedConfig = config.cryptoScoped(cryptoCode, cachedConfig) + console.log('DEBUG31') + const cryptoScopedConfig = configManager.cryptoScoped(cryptoCode, cachedConfig) + + console.log('DEBUG31.1') // TICKER [required] configure (or load) loadOrConfigPlugin( @@ -199,7 +202,7 @@ exports.configure = function configure (config) { } ) - console.log('DEBUG31') + console.log('DEBUG31.2') // Give each crypto a different derived seed so as not to allow any // plugin to spend another plugin's funds @@ -213,6 +216,7 @@ exports.configure = function configure (config) { accounts, {masterSeed: cryptoSeed}, function onWalletChange (newWallet) { + console.log('DEBUG34: %s, %j', cryptoCode, newWallet) walletPlugins[cryptoCode] = newWallet pollBalance(cryptoCode) }