From 8c6c3b258a0b67b9f1464f5459df355891d999c0 Mon Sep 17 00:00:00 2001 From: Rafael Taranto Date: Mon, 28 Apr 2025 07:34:41 +0100 Subject: [PATCH 1/6] chore: version bump --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index fce7fc39..15fa11a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "lamassu-server", - "version": "10.2.0-rc.2", + "version": "10.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 91672bb1..9eedefdc 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "lamassu-server", "description": "bitcoin atm client server protocol module", "keywords": [], - "version": "10.2.0-rc.2", + "version": "10.2.0", "license": "./LICENSE", "author": "Lamassu (https://lamassu.is)", "dependencies": { From 297a3d76fb48ddd59793c176fc3388d7c28ca14f Mon Sep 17 00:00:00 2001 From: Rafael Taranto Date: Tue, 6 May 2025 09:45:39 +0100 Subject: [PATCH 2/6] fix: forex on EUR default exchanges --- lib/forex.js | 12 ++++++------ lib/plugins/ticker/ccxt.js | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/forex.js b/lib/forex.js index 011eb2e4..ddee4008 100644 --- a/lib/forex.js +++ b/lib/forex.js @@ -11,19 +11,19 @@ const API_QUEUE = [ { api: getCoinCapFxRate, name: 'coincap', fiatCodeProperty: 'symbol', rateProperty: 'rateUsd' } ] -function getBitPayFxRate (fiatCode, fiatCodeProperty, rateProperty) { +function getBitPayFxRate (fiatCode, defaultFiatMarket, fiatCodeProperty, rateProperty) { return axios.get('https://bitpay.com/rates') .then(response => { const fxRates = response.data.data - const usdRate = findCurrencyRates(fxRates, 'USD', fiatCodeProperty, rateProperty) - const fxRate = findCurrencyRates(fxRates, fiatCode, fiatCodeProperty, rateProperty).div(usdRate) + const defaultFiatRate = findCurrencyRates(fxRates, defaultFiatMarket, fiatCodeProperty, rateProperty) + const fxRate = findCurrencyRates(fxRates, fiatCode, fiatCodeProperty, rateProperty).div(defaultFiatRate) return { fxRate } }) } -function getCoinCapFxRate (fiatCode, fiatCodeProperty, rateProperty) { +function getCoinCapFxRate (fiatCode, defaultFiatMarket, fiatCodeProperty, rateProperty) { return axios.get('https://api.coincap.io/v2/rates') .then(response => { const fxRates = response.data.data @@ -40,7 +40,7 @@ function findCurrencyRates (fxRates, fiatCode, fiatCodeProperty, rateProperty) { return new BN(rates[rateProperty].toString()) } -const getRate = (retries = 1, fiatCode) => { +const getRate = (retries = 1, fiatCode, defaultFiatMarket) => { const selected = _.first(API_QUEUE).name const activeAPI = _.first(API_QUEUE).api const fiatCodeProperty = _.first(API_QUEUE).fiatCodeProperty @@ -48,7 +48,7 @@ const getRate = (retries = 1, fiatCode) => { if (!activeAPI) throw new Error(`FOREX api ${selected} does not exist.`) - return activeAPI(fiatCode, fiatCodeProperty, rateProperty) + return activeAPI(fiatCode, defaultFiatMarket, fiatCodeProperty, rateProperty) .catch(() => { // Switch service const erroredService = API_QUEUE.shift() diff --git a/lib/plugins/ticker/ccxt.js b/lib/plugins/ticker/ccxt.js index 1f63ff3d..881085d1 100644 --- a/lib/plugins/ticker/ccxt.js +++ b/lib/plugins/ticker/ccxt.js @@ -30,7 +30,7 @@ function ticker (fiatCode, cryptoCode, tickerName) { return getCurrencyRates(ticker, fiatCode, cryptoCode) } - return getRate(RETRIES, fiatCode) + return getRate(RETRIES, tickerName, defaultFiatMarket(tickerName)) .then(({ fxRate }) => { try { return getCurrencyRates(ticker, defaultFiatMarket(tickerName), cryptoCode) From a84c82de92a5b8e4ee8b1d445150a8c59626144b Mon Sep 17 00:00:00 2001 From: Rafael Taranto Date: Tue, 6 May 2025 10:00:29 +0100 Subject: [PATCH 3/6] chore: remove deprecated forex --- lib/forex.js | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/lib/forex.js b/lib/forex.js index ddee4008..aeb4f514 100644 --- a/lib/forex.js +++ b/lib/forex.js @@ -7,8 +7,7 @@ const MAX_ROTATIONS = 5 const getFiatRates = () => axios.get('https://bitpay.com/api/rates').then(response => response.data) const API_QUEUE = [ - { api: getBitPayFxRate, name: 'bitpay', fiatCodeProperty: 'code', rateProperty: 'rate' }, - { api: getCoinCapFxRate, name: 'coincap', fiatCodeProperty: 'symbol', rateProperty: 'rateUsd' } + { api: getBitPayFxRate, name: 'bitpay', fiatCodeProperty: 'code', rateProperty: 'rate' } ] function getBitPayFxRate (fiatCode, defaultFiatMarket, fiatCodeProperty, rateProperty) { @@ -23,17 +22,6 @@ function getBitPayFxRate (fiatCode, defaultFiatMarket, fiatCodeProperty, ratePro }) } -function getCoinCapFxRate (fiatCode, defaultFiatMarket, fiatCodeProperty, rateProperty) { - return axios.get('https://api.coincap.io/v2/rates') - .then(response => { - const fxRates = response.data.data - const fxRate = new BN(1).div(findCurrencyRates(fxRates, fiatCode, fiatCodeProperty, rateProperty)) - return { - fxRate - } - }) -} - function findCurrencyRates (fxRates, fiatCode, fiatCodeProperty, rateProperty) { const rates = _.find(_.matchesProperty(fiatCodeProperty, fiatCode), fxRates) if (!rates || !rates[rateProperty]) throw new Error(`Unsupported currency: ${fiatCode}`) From 482b606177688d5aa711e4848ec9b1743e58595f Mon Sep 17 00:00:00 2001 From: CrypticaScriptura <7396812+CrypticaScriptura@users.noreply.github.com> Date: Tue, 6 May 2025 08:57:11 -0400 Subject: [PATCH 4/6] chore: v10.2.1 (#1835) --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 15fa11a7..40c422a6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "lamassu-server", - "version": "10.2.0", + "version": "10.2.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 9eedefdc..8af7afa8 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "lamassu-server", "description": "bitcoin atm client server protocol module", "keywords": [], - "version": "10.2.0", + "version": "10.2.1", "license": "./LICENSE", "author": "Lamassu (https://lamassu.is)", "dependencies": { From a477fa2393404069619de199083a5f43401d52f0 Mon Sep 17 00:00:00 2001 From: siiky Date: Thu, 8 May 2025 15:25:23 +0100 Subject: [PATCH 5/6] feat: cache Forex responses --- lib/forex.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/forex.js b/lib/forex.js index aeb4f514..6c5ea781 100644 --- a/lib/forex.js +++ b/lib/forex.js @@ -1,19 +1,29 @@ const _ = require('lodash/fp') const axios = require('axios') +const mem = require('mem') + const BN = require('./bn') +const T = require('./time') const MAX_ROTATIONS = 5 -const getFiatRates = () => axios.get('https://bitpay.com/api/rates').then(response => response.data) +const _getFiatRates = () => ( + axios.get('https://bitpay.com/api/rates') + .then(response => response.data) +) + +const getFiatRates = mem(_getFiatRates, { + maxAge: 6 * T.hours, + cacheKey: () => '' +}) const API_QUEUE = [ { api: getBitPayFxRate, name: 'bitpay', fiatCodeProperty: 'code', rateProperty: 'rate' } ] function getBitPayFxRate (fiatCode, defaultFiatMarket, fiatCodeProperty, rateProperty) { - return axios.get('https://bitpay.com/rates') - .then(response => { - const fxRates = response.data.data + return getFiatRates() + .then(({ data: fxRates }) => { const defaultFiatRate = findCurrencyRates(fxRates, defaultFiatMarket, fiatCodeProperty, rateProperty) const fxRate = findCurrencyRates(fxRates, fiatCode, fiatCodeProperty, rateProperty).div(defaultFiatRate) return { From e9640d7913c140b90cec32294e1e7f27105080fa Mon Sep 17 00:00:00 2001 From: Rafael Taranto Date: Mon, 12 May 2025 08:38:06 +0100 Subject: [PATCH 6/6] fix: advanced batch params --- lib/new-admin/graphql/resolvers/transaction.resolver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/new-admin/graphql/resolvers/transaction.resolver.js b/lib/new-admin/graphql/resolvers/transaction.resolver.js index f262517a..12e7e2b6 100644 --- a/lib/new-admin/graphql/resolvers/transaction.resolver.js +++ b/lib/new-admin/graphql/resolvers/transaction.resolver.js @@ -22,7 +22,7 @@ const resolvers = { transactions: (...[, { from, until, limit, offset, txClass, deviceId, customerName, fiatCode, cryptoCode, toAddress, status, swept, excludeTestingCustomers }]) => transactions.batch(from, until, limit, offset, txClass, deviceId, customerName, fiatCode, cryptoCode, toAddress, status, swept, excludeTestingCustomers), transactionsCsv: (...[, { from, until, limit, offset, txClass, deviceId, customerName, fiatCode, cryptoCode, toAddress, status, swept, timezone, excludeTestingCustomers, simplified }]) => - transactions.batch(from, until, limit, offset, null, txClass, deviceId, customerName, fiatCode, cryptoCode, toAddress, status, swept, excludeTestingCustomers, simplified) + transactions.batch(from, until, limit, offset, txClass, deviceId, customerName, fiatCode, cryptoCode, toAddress, status, swept, excludeTestingCustomers, simplified) .then(data => parseAsync(logDateFormat(timezone, data, ['created', 'sendTime', 'publishedAt']))), transactionCsv: (...[, { id, txClass, timezone }]) => transactions.getTx(id, txClass).then(data =>