fix(startup): Ensuring REST URL is passed correctly to bch-js on startup

This commit is contained in:
Chris Troutner
2025-11-26 11:00:08 -08:00
parent 39144116a9
commit 98576e5ff2
6 changed files with 127 additions and 63 deletions
@@ -4,8 +4,9 @@
import wlogger from '../../../adapters/wlogger.js'
import BCHJS from '@psf/bch-js'
import config from '../../../config/index.js'
const bchjs = new BCHJS()
const bchjs = new BCHJS({ restURL: config.restURL })
class FulcrumRESTController {
constructor (localConfig = {}) {
+3 -1
View File
@@ -4,8 +4,9 @@
import wlogger from '../../../adapters/wlogger.js'
import BCHJS from '@psf/bch-js'
import config from '../../../config/index.js'
const bchjs = new BCHJS()
const bchjs = new BCHJS({ restURL: config.restURL })
class SlpRESTController {
constructor (localConfig = {}) {
@@ -201,6 +202,7 @@ class SlpRESTController {
const result = await this.slpUseCases.getTokenData({ tokenId, withTxHistory })
return res.status(200).json(result)
} catch (err) {
console.log('Error in /v6/slp/token/data getTokenData(): ', err)
return this.handleError(err, res)
}
}
+10 -2
View File
@@ -4,8 +4,9 @@
import wlogger from '../adapters/wlogger.js'
import BCHJS from '@psf/bch-js'
import config from '../config/index.js'
const bchjs = new BCHJS()
const bchjs = new BCHJS({ restURL: config.restURL })
class FulcrumUseCases {
constructor (localConfig = {}) {
@@ -53,7 +54,14 @@ class FulcrumUseCases {
}
async getTransactionDetails ({ txid }) {
return this.fulcrum.get(`electrumx/tx/data/${txid}`)
try {
const response = await this.fulcrum.get(`electrumx/tx/data/${txid}`)
console.log(`getTransactionDetails() TXID ${txid}: ${JSON.stringify(response, null, 2)}`)
return response
} catch (err) {
wlogger.error('Error in FulcrumUseCases.getTransactionDetails()', err)
throw err
}
}
async getTransactionDetailsBulk ({ txids, verbose }) {
+5 -1
View File
@@ -9,7 +9,7 @@ import SlpTokenMedia from 'slp-token-media'
import axios from 'axios'
import config from '../config/index.js'
const bchjs = new BCHJS()
const bchjs = new BCHJS({ restURL: config.restURL })
class SlpUseCases {
constructor (localConfig = {}) {
@@ -259,6 +259,7 @@ class SlpUseCases {
return mutableCid
} catch (err) {
console.log('Error in SlpUseCases.getMutableCid()', err)
wlogger.error('Error in SlpUseCases.getMutableCid()', err)
return false
}
@@ -271,7 +272,9 @@ class SlpUseCases {
}
// Get transaction data
console.log('Decoding OP_RETURN for TXID: ', txid)
const txData = await this.bchjs.Electrumx.txData(txid)
console.log(`TXID ${txid}: ${JSON.stringify(txData, null, 2)}`)
let data = false
// Map the vout of the transaction in search of an OP_RETURN
@@ -291,6 +294,7 @@ class SlpUseCases {
return data
} catch (error) {
console.log('Error in SlpUseCases.decodeOpReturn()', error)
wlogger.error('Error in SlpUseCases.decodeOpReturn()', error)
throw error
}