chore: remove unused files

This commit is contained in:
Rafael Taranto 2024-06-07 10:53:57 +01:00
parent 9ce126aee3
commit 7cdc56cfdd
303 changed files with 40 additions and 81654 deletions

View file

@ -1,53 +0,0 @@
#!/usr/bin/env node
var pgp = require('pg-promise')()
require('../lib/environment-helper')
const { PSQL_URL } = require('../lib/constants')
var db = pgp(PSQL_URL)
db.manyOrNone(`select * from transactions where incoming=false
and stage='final_request' and authority='machine'`)
.then(rs =>
db.tx(t =>
t.batch(rs.map(r => db.none(`insert into cash_in_txs (session_id,
device_fingerprint, to_address, crypto_atoms, crypto_code, fiat,
currency_code, fee, tx_hash, error, created) values ($1, $2, $3, $4, $5,
$6, $7, $8, $9, $10, $11)`, [r.session_id, r.device_fingerprint,
r.to_address, r.satoshis, r.crypto_code, r.fiat, r.currency_code, r.fee,
r.tx_hash, r.error, r.created]))
)
)
)
.then(() => db.manyOrNone(`select * from transactions where incoming=true
and stage='initial_request' and authority='pending'`))
.then(rs =>
db.tx(t =>
t.batch(rs.map(r => db.none(`insert into cash_out_txs (session_id,
device_fingerprint, to_address, crypto_atoms, crypto_code, fiat,
currency_code, tx_hash, phone, error, created) values ($1, $2, $3, $4, $5,
$6, $7, $8, $9, $10, $11)`, [r.session_id, r.device_fingerprint,
r.to_address, r.satoshis, r.crypto_code, r.fiat, r.currency_code,
r.tx_hash, r.phone, r.error, r.created]))
)
)
)
.then(() => db.manyOrNone(`select * from transactions where incoming=true
and stage='dispense' and authority='authorized'`))
.then(rs =>
db.tx(t =>
t.batch(rs.map(r =>
db.none(`update cash_out_txs set dispensed=true where session_id=$1`, [r.session_id])
.then(() => db.none(`insert into cash_out_actions (session_id, action,
created) values ($1, $2, $3)`, [r.session_id, 'dispensed', r.created]))
))
)
)
.then(() => pgp.end())
.then(() => console.log('Success.'))
.catch(e => {
console.log(e)
pgp.end()
})

View file

@ -1,3 +0,0 @@
#!/bin/bash
node bin/new-lamassu-admin-server --dev & node bin/new-graphql-dev-insecure

View file

@ -1,14 +0,0 @@
require('../lib/environment-helper')
const settingsLoader = require('../lib/new-settings-loader')
const pp = require('../lib/pp')
settingsLoader.loadLatest()
.then(r => {
pp('config')(r)
process.exit(0)
})
.catch(e => {
console.log(e.stack)
process.exit(1)
})

View file

@ -1,75 +0,0 @@
require('../lib/environment-helper')
const hdkey = require('ethereumjs-wallet/hdkey')
const _ = require('lodash/fp')
const hkdf = require('futoin-hkdf')
const pify = require('pify')
const fs = pify(require('fs'))
const Web3 = require('web3')
const web3 = new Web3()
const db = require('../lib/db')
const configManager = require('../lib/new-config-manager')
const { loadLatest } = require('../lib/new-settings-loader')
const mnemonicHelpers = require('../lib/mnemonic-helpers')
const { sweep } = require('../lib/wallet')
const ph = require('../lib/plugin-helper')
const MNEMONIC_PATH = process.env.MNEMONIC_PATH
function fetchWallet (settings, cryptoCode) {
return fs.readFile(MNEMONIC_PATH, 'utf8')
.then(mnemonic => {
const masterSeed = mnemonicHelpers.toEntropyBuffer(mnemonic)
const plugin = configManager.getWalletSettings(cryptoCode, settings.config).wallet
const wallet = ph.load(ph.WALLET, plugin)
const rawAccount = settings.accounts[plugin]
const account = _.set('seed', computeSeed(masterSeed), rawAccount)
if (_.isFunction(wallet.run)) wallet.run(account)
return { wallet, account }
})
}
function computeSeed (masterSeed) {
return hkdf(masterSeed, 32, { salt: 'lamassu-server-salt', info: 'wallet-seed' })
}
function paymentHdNode (account) {
const masterSeed = account.seed
if (!masterSeed) throw new Error('No master seed!')
const key = hdkey.fromMasterSeed(masterSeed)
return key.derivePath("m/44'/60'/0'/0'")
}
const getHdIndices = db => {
const sql = `SELECT id, crypto_code, hd_index FROM cash_out_txs WHERE hd_index IS NOT NULL AND status IN ('confirmed', 'instant') AND crypto_code = 'ETH'`
return db.any(sql)
}
const getCashoutAddresses = (settings, indices) => {
return Promise.all(_.map(it => {
return fetchWallet(settings, it.crypto_code)
.then(({ wallet, account }) => Promise.all([wallet, paymentHdNode(account).deriveChild(it.hd_index).getWallet().getChecksumAddressString()]))
.then(([wallet, address]) => Promise.all([address, wallet._balance(false, address, 'ETH')]))
.then(([address, balance]) => ({ address, balance: balance.toNumber(), cryptoCode: it.crypto_code, index: it.hd_index, txId: it.id }))
}, indices))
}
Promise.all([getHdIndices(db), loadLatest()])
.then(([indices, settings]) => Promise.all([settings, getCashoutAddresses(settings, indices)]))
.then(([settings, addresses]) => {
console.log('Found these cash-out addresses for ETH:')
console.log(addresses)
return Promise.all(_.map(it => {
// If the address only has dust in it, don't bother sweeping
if (web3.utils.fromWei(it.balance.toString()) > 0.00001) {
console.log(`Address ${it.address} found to have ${web3.utils.fromWei(it.balance.toString())} ETH in it. Sweeping...`)
return sweep(settings, it.txId, it.cryptoCode, it.index)
}
console.log(`Address ${it.address} contains no significant balance (${web3.utils.fromWei(it.balance.toString())}). Skipping the sweep process...`)
return Promise.resolve()
}, addresses))
})
.then(() => console.log('Process finished!'))

View file

@ -1,47 +0,0 @@
#!/usr/bin/env node
'use strict'
const pgp = require('pg-promise')()
require('../lib/environment-helper')
const { PSQL_URL } = require('../lib/constants')
const db = pgp(PSQL_URL)
db.many('select data from user_config', 'exchanges')
.then(rows => {
const config = rows.filter(r => r.type === 'exchanges')[0].data
const brain = rows.filter(r => r.type === 'unit')[0].data
const settings = config.exchanges.settings
const compliance = settings.compliance
const newConfig = {
global: {
cashInTransactionLimit: compliance.maximum.limit,
cashOutTransactionLimit: settings.fiatTxLimit,
cashInCommission: settings.commission,
cashOutCommission: settings.fiatCommission || settings.commission,
idVerificationEnabled: compliance.idVerificationEnabled,
idVerificationLimit: compliance.idVerificationLimit,
lowBalanceMargin: settings.lowBalanceMargin,
zeroConfLimit: settings.zeroConfLimit,
fiatCurrency: settings.currency,
topCashOutDenomination: settings.cartridges[0],
bottomCashOutDenomination: settings.cartridges[1],
virtualCashOutDenomination: settings.virtualCartridges[0],
machineLanguages: brain.locale.localeInfo.primaryLocales,
coins: settings.coins
},
accounts: settings.plugins.settings
}
db.none('insert into user_config (type, data) values ($1, $2)', ['global', newConfig])
.then(() => {
console.log('Success.')
process.exit(0)
})
.catch(err => {
console.error('Error: %s', err)
process.exit(1)
})
})