fix: ln merge issues and deprecate some libs

This commit is contained in:
Rafael Taranto 2023-10-05 22:55:02 +01:00
parent c9e3fcd9ca
commit 546ba7b780
11 changed files with 4384 additions and 4814 deletions

View file

@ -1,5 +0,0 @@
#!/usr/bin/env node
const adminServer = require('../lib/admin/admin-server')
adminServer.run()

View file

@ -1,32 +0,0 @@
#!/usr/bin/env node
require('../lib/environment-helper')
const login = require('../lib/admin/login')
const name = process.argv[2]
const domain = process.env.HOSTNAME
if (!domain) {
console.error('No hostname configured in the environment')
process.exit(1)
}
if (!name) {
console.log('Usage: lamassu-register <username>')
process.exit(2)
}
login.generateOTP(name)
.then(otp => {
if (domain === 'localhost') {
console.log(`https://${domain}:8070?otp=${otp}`)
} else {
console.log(`https://${domain}?otp=${otp}`)
}
process.exit(0)
})
.catch(err => {
console.log('Error: %s', err)
process.exit(3)
})

View file

@ -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')

View file

@ -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) {

View file

@ -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()

View file

@ -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) {

View file

@ -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) {

View file

@ -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))

View file

@ -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 = {}

9111
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -2,14 +2,14 @@
"name": "lamassu-server",
"description": "bitcoin atm client server protocol module",
"keywords": [],
"version": "8.1.5-1",
"license": "Unlicense",
"version": "9.0.0-beta.0",
"license": "./LICENSE",
"author": "Lamassu (https://lamassu.is)",
"dependencies": {
"@ethereumjs/common": "^2.6.4",
"@ethereumjs/tx": "^3.5.1",
"@graphql-tools/merge": "^6.2.5",
"@lamassu/coins": "v1.3.3",
"@lamassu/coins": "v1.4.0-beta.1",
"@node-lightning/invoice": "0.28.0",
"@simplewebauthn/server": "^3.0.0",
"@vonage/auth": "^1.5.0",
@ -23,9 +23,8 @@
"bchaddrjs": "^0.3.0",
"bignumber.js": "9.0.1",
"bip39": "^2.3.1",
"bitcoind-rpc": "^0.7.0",
"bitgo": "11.18.0",
"ccxt": "lamassu/ccxt#1.82.31",
"ccxt": "2.9.16",
"compression": "^1.7.4",
"connect-pg-simple": "^6.2.1",
"console-log-level": "^1.4.0",
@ -39,10 +38,7 @@
"ethereumjs-util": "^5.2.0",
"ethereumjs-wallet": "^0.6.3",
"express": "4.17.1",
"express-limiter": "^1.6.0",
"express-rate-limit": "^2.9.0",
"express-session": "^1.17.1",
"express-ws": "^3.0.0",
"futoin-hkdf": "^1.0.2",
"got": "^7.1.0",
"graphql": "^15.5.0",
@ -65,7 +61,6 @@
"ndjson": "^1.5.0",
"nocache": "^2.1.0",
"node-cache": "^5.1.2",
"numeral": "^2.0.3",
"otplib": "^12.0.1",
"p-each-series": "^1.0.0",
"p-queue": "^6.6.2",
@ -79,8 +74,6 @@
"request-promise": "^4.2.6",
"semver": "^7.1.3",
"serve-static": "^1.12.4",
"socket.io": "^2.0.3",
"socket.io-client": "^2.0.3",
"talisman": "^0.20.0",
"telnyx": "^1.25.5",
"tronweb": "^5.3.0",
@ -89,7 +82,6 @@
"web3": "1.7.1",
"winston": "^2.4.2",
"winston-transport": "^4.3.0",
"ws": "^3.1.0",
"xml-stream": "^0.4.5",
"xmlrpc": "^1.3.2",
"yup": "^0.31.1"