feat: decouple l-s entrypoint

This commit is contained in:
Sérgio Salgado 2022-03-29 15:00:52 +01:00
parent 2a2c1fccc8
commit f4d6b5e454
48 changed files with 411 additions and 232 deletions

View file

@ -6,9 +6,7 @@ const _ = require('lodash/fp')
const request = require('request-promise')
const { utils: coinUtils } = require('@lamassu/coins')
const options = require('../../options')
const blockchainDir = options.blockchainDir
const BLOCKCHAIN_DIR = process.env.BLOCKCHAIN_DIR
module.exports = {
fetch, fetchDigest, parseConf, rpcConfig
@ -108,7 +106,7 @@ function parseConf (confPath) {
function rpcConfig (cryptoRec) {
try {
const configPath = coinUtils.configPath(cryptoRec, blockchainDir)
const configPath = coinUtils.configPath(cryptoRec, BLOCKCHAIN_DIR)
const config = parseConf(configPath)
return {
username: config.rpcuser,

View file

@ -1,7 +1,7 @@
const axios = require('axios')
const _ = require('lodash/fp')
const options = require('../../../options')
const STRIKE_BASE_URL = process.env.STRIKE_BASE_URL
module.exports = {
newAddress,
@ -9,7 +9,7 @@ module.exports = {
cryptoNetwork
}
axios.defaults.baseURL = _.get('strike.baseUrl', options)
axios.defaults.baseURL = STRIKE_BASE_URL
if (_.isEmpty(axios.defaults.baseURL)) {
throw new Error('Missing Strike baseUrl!')
}

View file

@ -3,13 +3,14 @@ const lnd = require('lnd-async')
const BN = require('../../../bn')
const E = require('../../../error')
const { utils: coinUtils } = require('@lamassu/coins')
const options = require('../../../options')
const _ = require('lodash/fp')
const cryptoRec = coinUtils.getCryptoCurrency('BTC')
const unitScale = cryptoRec.unitScale
const LND = process.env.LIGHTNING_NETWORK_DAEMON
module.exports = {
balance,
sendCoins,
@ -20,7 +21,7 @@ module.exports = {
}
function connect () {
return lnd.connect(options.lnd || {})
return lnd.connect(LND || {})
}
function cryptoNetwork (account, cryptoCode, settings, operatorId) {

View file

@ -7,14 +7,13 @@ const { default: PQueue } = require('p-queue')
const BN = require('../../../bn')
const E = require('../../../error')
const { logger } = require('../../../blockchain/common')
const options = require('../../../options')
const jsonRpc = require('../../common/json-rpc')
const blockchainDir = options.blockchainDir
const BLOCKCHAIN_DIR = process.env.BLOCKCHAIN_DIR
const cryptoRec = utils.getCryptoCurrency(COINS.XMR)
const configPath = utils.configPath(cryptoRec, blockchainDir)
const walletDir = path.resolve(utils.cryptoDir(cryptoRec, blockchainDir), 'wallets')
const configPath = utils.configPath(cryptoRec, BLOCKCHAIN_DIR)
const walletDir = path.resolve(utils.cryptoDir(cryptoRec, BLOCKCHAIN_DIR), 'wallets')
const DIGEST_QUEUE = new PQueue({
concurrency: 1,

View file

@ -4,11 +4,11 @@ const E = require('../../../error')
const _ = require('lodash/fp')
const ENV = process.env.NODE_ENV === undefined || process.env.NODE_ENV === 'development' ? 'development' : 'production'
const SUPPORTED_COINS = ['BTC', 'ZEC', 'LTC', 'BCH', 'DASH', 'ETH']
const SUPPORTED_COINS = ['BTC']
const axios = require('axios').create({
// TODO: get rejectUnauthorized true to work
baseURL: ENV === 'development' ? 'https://localhost:5555/api/' : process.env.PAZUZ_API_WALLET_URL,
baseURL: `${process.env.WALLET_URL}/api`,
httpsAgent: new https.Agent({
rejectUnauthorized: false
})
@ -22,9 +22,8 @@ function balance (account, cryptoCode, settings, operatorId) {
return checkCryptoCode(cryptoCode)
.then(() => {
return axios.post('/balance', {
account,
cryptoCode,
settings,
config: settings.config,
operatorId
})
})
@ -39,9 +38,8 @@ function sendCoins (account, tx, settings, operatorId) {
return checkCryptoCode(cryptoCode)
.then(() => {
return axios.post('/sendCoins', {
account,
tx,
settings,
config: settings.config,
operatorId
})
})
@ -57,10 +55,9 @@ function sendCoins (account, tx, settings, operatorId) {
function newAddress (account, info, tx, settings, operatorId) {
return checkCryptoCode(info.cryptoCode)
.then(() => axios.post('/newAddress', {
account,
info,
tx,
settings,
config: settings.config,
operatorId
}))
.then(({ data }) => {