This commit is contained in:
Josh Harvey 2016-11-20 17:49:36 +02:00
parent becd62a1fb
commit 938eb9ac97
9 changed files with 153 additions and 68 deletions

View file

@ -171,16 +171,11 @@ exports.configure = function configure (config) {
const cryptoCodes = getCryptoCodes()
console.log('DEBUG30')
return configManager.loadAccounts()
.then(accounts => {
cryptoCodes.forEach(cryptoCode => {
console.log('DEBUG31')
const cryptoScopedConfig = configManager.cryptoScoped(cryptoCode, cachedConfig)
console.log('DEBUG31.1')
// TICKER [required] configure (or load)
loadOrConfigPlugin(
tickerPlugins[cryptoCode],
@ -195,8 +190,6 @@ exports.configure = function configure (config) {
}
)
console.log('DEBUG31.2')
// 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)
@ -298,7 +291,6 @@ exports.pollQueries = function pollQueries (deviceId) {
function _sendCoins (toAddress, cryptoAtoms, cryptoCode) {
return new Promise((resolve, reject) => {
_sendCoinsCb(toAddress, cryptoAtoms, cryptoCode, (err, txHash) => {
console.log('DEBUG12: %j, %j', err, txHash)
if (err) return reject(err)
return resolve(txHash)
})
@ -308,7 +300,6 @@ function _sendCoins (toAddress, cryptoAtoms, cryptoCode) {
function _sendCoinsCb (toAddress, cryptoAtoms, cryptoCode, cb) {
const walletPlugin = walletPlugins[cryptoCode]
const transactionFee = null
logger.debug('Sending coins [%s] to: %s', cryptoCode, toAddress)
if (cryptoCode === 'BTC') {
walletPlugin.sendBitcoins(toAddress, cryptoAtoms.truncated().toNumber(), transactionFee, cb)
@ -320,12 +311,9 @@ function _sendCoinsCb (toAddress, cryptoAtoms, cryptoCode, cb) {
// 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) {
console.log('DEBUG16: %j', tx)
return db.addOutgoingTx(deviceId, tx)
.then(() => _sendCoins(tx.toAddress, tx.cryptoAtoms, tx.cryptoCode))
.then(txHash => {
console.log('DEBUG13: %j', txHash)
const fee = null // Need to fill this out in plugins
const toSend = {cryptoAtoms: tx.cryptoAtoms, fiat: tx.fiat}
@ -412,7 +400,6 @@ exports.cashOut = function cashOut (deviceId, tx) {
}
exports.dispenseAck = function (deviceId, tx) {
console.log('DEBUG23: %j', tx)
const config = getConfig(deviceId)
const cartridges = [ config.currencies.topCashOutDenomination,
config.currencies.bottomCashOutDenomination ]
@ -767,7 +754,6 @@ function checkNotification () {
return sendMessage(rec)
})
.then(results => {
console.log('DEBUG25')
if (results && results.length > 0) logger.debug('Successfully sent alerts')
})
.catch(err => {