diff --git a/package.json b/package.json index 609ffd4..3ffbf6f 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ ], "main": "src/bch-js.js", "scripts": { - "test": "c8 mocha --trace-warnings --unhandled-rejections=strict --timeout 30000 test/unit/", + "test": "export RESTURL=http://localhost:5942/v6/ && c8 mocha --trace-warnings --unhandled-rejections=strict --timeout 30000 test/unit/", "test:integration": "npm run test:integration:local:noauth", "test:integration:nft": "export RESTURL=https://bchn.fullstack.cash/v6/ && export IS_USING_FREE_TIER=true && mocha --timeout 30000 -g '#nft1' test/integration/slp.js", "test:integration:bchn": "export RESTURL=https://bchn.fullstack.cash/v6/ && export IS_USING_FREE_TIER=true && mocha --timeout 30000 test/integration/", diff --git a/src/bch-js.js b/src/bch-js.js index 8df5fb0..3d3a057 100644 --- a/src/bch-js.js +++ b/src/bch-js.js @@ -45,7 +45,6 @@ import Ecash from './ecash.js' // Indexers import Electrumx from './electrumx.js' import PsfSlpIndexer from './psf-slp-indexer.js' -const DEFAULT_REST_API = 'https://api.fullstack.cash/v6/' class BCHJS { constructor (config) { @@ -54,7 +53,11 @@ class BCHJS { this.restURL = config.restURL } else if (process.env.RESTURL && process.env.RESTURL !== '') { this.restURL = process.env.RESTURL - } else this.restURL = DEFAULT_REST_API + } else { + throw new Error( + 'REST API URL is required. Provide config.restURL or set the RESTURL environment variable.' + ) + } // Retrieve the Bearer token for simple token authentication. this.bearerToken = '' // default value. diff --git a/src/electrumx.js b/src/electrumx.js index e6a876d..df37dfb 100644 --- a/src/electrumx.js +++ b/src/electrumx.js @@ -534,6 +534,8 @@ class ElectrumX { */ async txData (txid) { try { + console.log('bch-js txData() restURL: ', this.restURL) + // Handle single transaction. if (typeof txid === 'string') { const response = await this.axios.get(