Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LAM-801 fix: backport USDT ratchet fix #1482

Merged
merged 3 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/cash-in/cash-in-low.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const E = require('../error')

const PENDING_INTERVAL_MS = 60 * T.minutes

const massageFields = ['direction', 'cryptoNetwork', 'bills', 'blacklisted', 'addressReuse', 'promoCodeApplied', 'validWalletScore']
const massageFields = ['direction', 'cryptoNetwork', 'bills', 'blacklisted', 'addressReuse', 'promoCodeApplied', 'validWalletScore', 'cashInFeeCrypto']
const massageUpdateFields = _.concat(massageFields, 'cryptoAtoms')

const massage = _.flow(_.omit(massageFields),
Expand All @@ -35,7 +35,7 @@ function toObj (row) {

keys.forEach(key => {
const objKey = _.camelCase(key)
if (_.includes(key, ['crypto_atoms', 'fiat', 'cash_in_fee', 'cash_in_fee_crypto', 'commission_percentage', 'raw_ticker_price'])) {
if (_.includes(key, ['crypto_atoms', 'fiat', 'cash_in_fee', 'commission_percentage', 'raw_ticker_price'])) {
newObj[objKey] = new BN(row[key])
return
}
Expand Down Expand Up @@ -102,7 +102,7 @@ function diff (oldTx, newTx) {
}

function ensureRatchet (oldField, newField, fieldKey) {
const monotonic = ['cryptoAtoms', 'fiat', 'cashInFeeCrypto', 'send', 'sendConfirmed', 'operatorCompleted', 'timedout', 'txVersion', 'batched']
const monotonic = ['cryptoAtoms', 'fiat', 'send', 'sendConfirmed', 'operatorCompleted', 'timedout', 'txVersion', 'batched']
const free = ['sendPending', 'error', 'errorCode', 'customerId']

if (_.isNil(oldField)) return true
Expand Down
1 change: 0 additions & 1 deletion lib/new-admin/graphql/types/transaction.type.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const typeDef = gql`
operatorCompleted: Boolean
sendPending: Boolean
cashInFee: String
cashInFeeCrypto: String
minimumTx: Float
customerId: ID
isAnonymous: Boolean
Expand Down
1 change: 0 additions & 1 deletion lib/notifier/test/notifier.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ const tx = {
operatorCompleted: false,
sendPending: true,
cashInFee: new BN(2),
cashInFeeCrypto: new BN(9500),
minimumTx: 5,
customerId: '47ac1184-8102-11e7-9079-8f13a7117867',
txVersion: 6,
Expand Down
2 changes: 1 addition & 1 deletion lib/tx-batching.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function getOpenBatchCryptoValue (cryptoCode) {
if (_.isNil(batch)) return Promise.resolve([])
return db.any(`SELECT * FROM cash_in_txs WHERE batch_id=$1`, [batch.id])
})
.then(txs => _.reduce((acc, tx) => acc.plus(tx.cash_in_fee_crypto).plus(tx.crypto_atoms), BN(0), txs))
.then(txs => _.reduce((acc, tx) => acc.plus(tx.crypto_atoms), BN(0), txs))
}

module.exports = {
Expand Down
1 change: 0 additions & 1 deletion lib/tx.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ function massage (tx, pi) {
cryptoAtoms: new BN(r.cryptoAtoms),
fiat: new BN(r.fiat),
cashInFee: new BN(r.cashInFee),
cashInFeeCrypto: new BN(r.cashInFeeCrypto),
commissionPercentage: new BN(r.commissionPercentage),
rawTickerPrice: r.rawTickerPrice ? new BN(r.rawTickerPrice) : null,
minimumTx: new BN(r.minimumTx)
Expand Down
13 changes: 13 additions & 0 deletions migrations/1670425142650-deprecate-cash-in-fee-crypto.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const db = require('./db')

exports.up = function (next) {
var sql = [
'ALTER TABLE cash_in_txs DROP COLUMN cash_in_fee_crypto'
]

db.multi(sql, next)
}

exports.down = function (next) {
next()
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "lamassu-server",
"description": "bitcoin atm client server protocol module",
"keywords": [],
"version": "8.0.5",
"version": "8.0.6",
"license": "Unlicense",
"author": "Lamassu (https://lamassu.is)",
"dependencies": {
Expand Down