fix: ln merge issues and deprecate some libs
This commit is contained in:
parent
c9e3fcd9ca
commit
546ba7b780
11 changed files with 4384 additions and 4814 deletions
|
|
@ -11,9 +11,9 @@ const argv = require('minimist')(process.argv.slice(2))
|
|||
const got = require('got')
|
||||
const morgan = require('morgan')
|
||||
const helmet = require('helmet')
|
||||
const WebSocket = require('ws')
|
||||
// const WebSocket = require('ws')
|
||||
const http = require('http')
|
||||
const SocketIo = require('socket.io')
|
||||
// const SocketIo = require('socket.io')
|
||||
const makeDir = require('make-dir')
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ const pgp = require('pg-promise')()
|
|||
|
||||
const db = require('../db')
|
||||
const E = require('../error')
|
||||
const socket = require('../socket-client')
|
||||
const logger = require('../logger')
|
||||
|
||||
const helper = require('./cash-out-helper')
|
||||
|
|
@ -83,7 +82,7 @@ function preProcess (t, oldTx, newTx, pi) {
|
|||
|
||||
if (hasError || hasDispenseOccurred) {
|
||||
return cashOutActions.logDispense(t, updatedTx)
|
||||
.then(updateCassettes(t, updatedTx))
|
||||
.then(it => updateCassettes(t, updatedTx).then(() => it) )
|
||||
.then((t) => {
|
||||
pi.notifyOperator(updatedTx, { isRedemption: true })
|
||||
.catch((err) => logger.error('Failure sending transaction notification', err))
|
||||
|
|
@ -134,7 +133,6 @@ function updateCassettes (t, tx) {
|
|||
values.push(tx.deviceId)
|
||||
|
||||
return t.one(sql, values)
|
||||
.then(r => socket.emit(_.assign(r, {op: 'cassetteUpdate', deviceId: tx.deviceId})))
|
||||
}
|
||||
|
||||
function wasJustAuthorized (oldTx, newTx, isZeroConf) {
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ const reflect = p => p.then(value => ({ value, status: 'fulfilled' }), error =>
|
|||
|
||||
function getFunding () {
|
||||
return settingsLoader.loadLatest().then(settings => {
|
||||
const cryptoCodes = _.filter(code => coinUtils.getExternalCryptoCode(code) === code, configManager.getAllCryptoCurrencies(settings.config))
|
||||
const cryptoCodes = configManager.getAllCryptoCurrencies(settings.config)
|
||||
const fiatCode = configManager.getGlobalLocale(settings.config).fiatCurrency
|
||||
const pareCoins = c => _.includes(c.cryptoCode, cryptoCodes)
|
||||
const cryptoCurrencies = coinUtils.cryptoCurrencies()
|
||||
|
|
|
|||
|
|
@ -140,8 +140,9 @@ const buildTransactionMessage = (tx, rec, highValueTx, machineName, customer) =>
|
|||
}, highValueTx]
|
||||
}
|
||||
|
||||
function formatCurrency (num, code) {
|
||||
return numeral(num).format('0,0.00') + ' ' + code
|
||||
function formatCurrency (num = 0, code) {
|
||||
const formattedNumber = Number(num).toLocaleString(undefined, {maximumFractionDigits:2, minimumFractionDigits:2})
|
||||
return `${formattedNumber} ${code}`
|
||||
}
|
||||
|
||||
function formatAge (age, settings) {
|
||||
|
|
|
|||
|
|
@ -28,16 +28,15 @@ const ALL = {
|
|||
}
|
||||
|
||||
function buildMarket (fiatCode, cryptoCode, serviceName) {
|
||||
const externalCryptoCode = coinUtils.getExternalCryptoCode(cryptoCode)
|
||||
if (!_.includes(externalCryptoCode, ALL[serviceName].CRYPTO)) {
|
||||
throw new Error('Unsupported crypto: ' + externalCryptoCode)
|
||||
if (!_.includes(cryptoCode, ALL[serviceName].CRYPTO)) {
|
||||
throw new Error('Unsupported crypto: ' + cryptoCode)
|
||||
}
|
||||
const fiatSupported = ALL[serviceName].FIAT
|
||||
if (fiatSupported !== 'ALL_CURRENCIES' && !_.includes(fiatCode, fiatSupported)) {
|
||||
logger.info('Building a market for an unsupported fiat. Defaulting to EUR market')
|
||||
return cryptoCode + '/' + 'EUR'
|
||||
}
|
||||
return externalCryptoCode + '/' + fiatCode
|
||||
return cryptoCode + '/' + fiatCode
|
||||
}
|
||||
|
||||
function verifyFiatSupport (fiatCode, serviceName) {
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ function sendFundsLN (walletId, invoice, token) {
|
|||
|
||||
function sendCoins (account, tx, settings, operatorId) {
|
||||
const { toAddress, cryptoAtoms, cryptoCode } = tx
|
||||
const externalCryptoCode = coinUtils.getExternalCryptoCode(cryptoCode)
|
||||
const externalCryptoCode = coinUtils.getEquivalentCode(cryptoCode)
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => getGaloyAccount(account.apiKey))
|
||||
.then(galoyAccount => {
|
||||
|
|
@ -215,7 +215,7 @@ function newInvoice (walletId, cryptoAtoms, token) {
|
|||
}
|
||||
|
||||
function balance (account, cryptoCode, settings, operatorId) {
|
||||
const externalCryptoCode = coinUtils.getExternalCryptoCode(cryptoCode)
|
||||
const externalCryptoCode = coinUtils.getEquivalentCode(cryptoCode)
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => getGaloyAccount(account.apiKey))
|
||||
.then(galoyAccount => {
|
||||
|
|
@ -232,7 +232,7 @@ function balance (account, cryptoCode, settings, operatorId) {
|
|||
|
||||
function newAddress (account, info, tx, settings, operatorId) {
|
||||
const { cryptoAtoms, cryptoCode } = tx
|
||||
const externalCryptoCode = coinUtils.getExternalCryptoCode(cryptoCode)
|
||||
const externalCryptoCode = coinUtils.getEquivalentCode(cryptoCode)
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => getGaloyAccount(account.apiKey))
|
||||
.then(galoyAccount => {
|
||||
|
|
@ -260,7 +260,7 @@ function getStatus (account, tx, requested, settings, operatorId) {
|
|||
if (tx.node.status === TX_SUCCESS) return 'confirmed'
|
||||
return 'notSeen'
|
||||
}
|
||||
const externalCryptoCode = coinUtils.getExternalCryptoCode(cryptoCode)
|
||||
const externalCryptoCode = coinUtils.getEquivalentCode(cryptoCode)
|
||||
const address = coinUtils.parseUrl(toAddress)
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => getGaloyAccount(account.apiKey))
|
||||
|
|
@ -283,7 +283,7 @@ function getStatus (account, tx, requested, settings, operatorId) {
|
|||
}
|
||||
|
||||
function newFunding (account, cryptoCode, settings, operatorId) {
|
||||
const externalCryptoCode = coinUtils.getExternalCryptoCode(cryptoCode)
|
||||
const externalCryptoCode = coinUtils.getEquivalentCode(cryptoCode)
|
||||
// Regular BTC address
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => getGaloyAccount(account.apiKey))
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
const { utils: coinUtils } = require('@lamassu/coins')
|
||||
const _ = require('lodash/fp')
|
||||
const mem = require('mem')
|
||||
|
||||
const configManager = require('./new-config-manager')
|
||||
const { utils: coinUtils } = require('@lamassu/coins')
|
||||
const logger = require('./logger')
|
||||
const lastRate = {}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue