diff --git a/routes/address.js b/routes/address.js index ae4e4bdc..a0a31be8 100644 --- a/routes/address.js +++ b/routes/address.js @@ -23,7 +23,7 @@ router.get('/details/:address', (req, res, next) => { })); } catch(error) { - let path = `http://194.14.246.69/api/addr/${BITBOX.Address.toLegacyAddress(req.params.address)}`; + let path = `${process.env.BITCOINCOM_BASEURL}addr/${BITBOX.Address.toLegacyAddress(req.params.address)}`; if(req.query.from && req.query.to) { path = `${path}?from=${req.query.from}&to=${req.query.to}`; } @@ -53,7 +53,7 @@ router.get('/utxo/:address', (req, res, next) => { final.push([]) }); - axios.get(`http://194.14.246.69/api/addrs/${addresses}/utxo`) + axios.get(`${process.env.BITCOINCOM_BASEURL}addrs/${addresses}/utxo`) .then((response) => { let parsed = response.data; parsed.forEach((data) => { @@ -73,7 +73,7 @@ router.get('/utxo/:address', (req, res, next) => { }); } catch(error) { - axios.get(`http://194.14.246.69/api/addr/${BITBOX.Address.toLegacyAddress(req.params.address)}/utxo`) + axios.get(`${process.env.BITCOINCOM_BASEURL}addr/${BITBOX.Address.toLegacyAddress(req.params.address)}/utxo`) .then((response) => { let parsed = response.data; parsed.forEach((data) => { @@ -99,7 +99,7 @@ router.get('/unconfirmed/:address', (req, res, next) => { addresses.forEach((address) => { final.push([]) }); - axios.get(`http://194.14.246.69/api/addrs/${addresses}/utxo`) + axios.get(`${process.env.BITCOINCOM_BASEURL}addrs/${addresses}/utxo`) .then((response) => { let parsed = response.data; parsed.forEach((data) => { @@ -121,7 +121,7 @@ router.get('/unconfirmed/:address', (req, res, next) => { }); } catch(error) { - axios.get(`http://194.14.246.69/api/addr/${BITBOX.Address.toLegacyAddress(req.params.address)}/utxo`) + axios.get(`${process.env.BITCOINCOM_BASEURL}addr/${BITBOX.Address.toLegacyAddress(req.params.address)}/utxo`) .then((response) => { let parsed = response.data; let unconfirmed = []; diff --git a/routes/block.js b/routes/block.js index 659e53f1..e0d42345 100644 --- a/routes/block.js +++ b/routes/block.js @@ -5,19 +5,11 @@ let axios = require('axios'); let BITBOXCli = require('bitbox-cli/lib/bitbox-cli').default; let BITBOX = new BITBOXCli(); -//testnet creds -// let BitboxHTTP = axios.create({ -// baseURL: `http://167.99.110.201:18332/` -// }); -// let username = 'bitcoin'; -// let password = 'rD9yw2Y9RkOnYjYnDX'; - -// mainnet creds let BitboxHTTP = axios.create({ - baseURL: `http://138.68.54.100:8332/` + baseURL: process.env.RPC_BASEURL }); -let username = 'bitcoin'; -let password = 'xhFjluMJMyOXcYvF'; +let username = process.env.RPC_USERNAME; +let password = process.env.RPC_PASSWORD; router.get('/', (req, res, next) => { res.json({ status: 'block' }); @@ -41,7 +33,7 @@ router.get('/details/:id', (req, res, next) => { } }) .then((response) => { - axios.get(`http://194.14.246.69/api/block/${response.data.result}`) + axios.get(`${process.env.BITCOINCOM_BASEURL}block/${response.data.result}`) .then((response) => { let parsed = response.data; res.json(parsed); @@ -54,7 +46,7 @@ router.get('/details/:id', (req, res, next) => { res.send(error.response.data.error.message); }); } else { - axios.get(`http://194.14.246.69/api/block/${req.params.id}`) + axios.get(`${process.env.BITCOINCOM_BASEURL}block/${req.params.id}`) .then((response) => { let parsed = response.data; res.json(parsed); diff --git a/routes/blockchain.js b/routes/blockchain.js index f30d29b2..fd6e2610 100644 --- a/routes/blockchain.js +++ b/routes/blockchain.js @@ -5,19 +5,11 @@ let axios = require('axios'); let BITBOXCli = require('bitbox-cli/lib/bitbox-cli').default; let BITBOX = new BITBOXCli(); -//testnet creds -// let BitboxHTTP = axios.create({ -// baseURL: `http://167.99.110.201:18332/` -// }); -// let username = 'bitcoin'; -// let password = 'rD9yw2Y9RkOnYjYnDX'; - -// mainnet creds let BitboxHTTP = axios.create({ - baseURL: `http://138.68.54.100:8332/` + baseURL: process.env.RPC_BASEURL }); -let username = 'bitcoin'; -let password = 'xhFjluMJMyOXcYvF'; +let username = process.env.RPC_USERNAME; +let password = process.env.RPC_PASSWORD; router.get('/', (req, res, next) => { res.json({ status: 'blockchain' }); diff --git a/routes/control.js b/routes/control.js index 45115339..7cb0829c 100644 --- a/routes/control.js +++ b/routes/control.js @@ -5,19 +5,11 @@ let axios = require('axios'); let BITBOXCli = require('bitbox-cli/lib/bitbox-cli').default; let BITBOX = new BITBOXCli(); -//testnet creds -// let BitboxHTTP = axios.create({ -// baseURL: `http://167.99.110.201:18332/` -// }); -// let username = 'bitcoin'; -// let password = 'rD9yw2Y9RkOnYjYnDX'; - -// mainnet creds let BitboxHTTP = axios.create({ - baseURL: `http://138.68.54.100:8332/` + baseURL: process.env.RPC_BASEURL }); -let username = 'bitcoin'; -let password = 'xhFjluMJMyOXcYvF'; +let username = process.env.RPC_USERNAME; +let password = process.env.RPC_PASSWORD; router.get('/', (req, res, next) => { res.json({ status: 'control' }); diff --git a/routes/generating.js b/routes/generating.js index 324866e7..e85d7e95 100644 --- a/routes/generating.js +++ b/routes/generating.js @@ -5,19 +5,11 @@ let axios = require('axios'); let BITBOXCli = require('bitbox-cli/lib/bitbox-cli').default; let BITBOX = new BITBOXCli(); -//testnet creds -// let BitboxHTTP = axios.create({ -// baseURL: `http://167.99.110.201:18332/` -// }); -// let username = 'bitcoin'; -// let password = 'rD9yw2Y9RkOnYjYnDX'; - -// mainnet creds let BitboxHTTP = axios.create({ - baseURL: `http://138.68.54.100:8332/` + baseURL: process.env.RPC_BASEURL }); -let username = 'bitcoin'; -let password = 'xhFjluMJMyOXcYvF'; +let username = process.env.RPC_USERNAME; +let password = process.env.RPC_PASSWORD; router.get('/', (req, res, next) => { res.json({ status: 'generating' }); diff --git a/routes/mining.js b/routes/mining.js index 4f6c7ad5..e772ba9a 100644 --- a/routes/mining.js +++ b/routes/mining.js @@ -5,19 +5,11 @@ let axios = require('axios'); let BITBOXCli = require('bitbox-cli/lib/bitbox-cli').default; let BITBOX = new BITBOXCli(); -//testnet creds -// let BitboxHTTP = axios.create({ -// baseURL: `http://167.99.110.201:18332/` -// }); -// let username = 'bitcoin'; -// let password = 'rD9yw2Y9RkOnYjYnDX'; - -// mainnet creds let BitboxHTTP = axios.create({ - baseURL: `http://138.68.54.100:8332/` + baseURL: process.env.RPC_BASEURL }); -let username = 'bitcoin'; -let password = 'xhFjluMJMyOXcYvF'; +let username = process.env.RPC_USERNAME; +let password = process.env.RPC_PASSWORD; router.get('/', (req, res, next) => { res.json({ status: 'mining' }); diff --git a/routes/network.js b/routes/network.js index 0599014c..e3bd0800 100644 --- a/routes/network.js +++ b/routes/network.js @@ -5,19 +5,11 @@ let axios = require('axios'); let BITBOXCli = require('bitbox-cli/lib/bitbox-cli').default; let BITBOX = new BITBOXCli(); -//testnet creds -// let BitboxHTTP = axios.create({ -// baseURL: `http://167.99.110.201:18332/` -// }); -// let username = 'bitcoin'; -// let password = 'rD9yw2Y9RkOnYjYnDX'; - -// mainnet creds let BitboxHTTP = axios.create({ - baseURL: `http://138.68.54.100:8332/` + baseURL: process.env.RPC_BASEURL }); -let username = 'bitcoin'; -let password = 'xhFjluMJMyOXcYvF'; +let username = process.env.RPC_USERNAME; +let password = process.env.RPC_PASSWORD; router.get('/', (req, res, next) => { res.json({ status: 'network' }); diff --git a/routes/rawtransactions.js b/routes/rawtransactions.js index 8e17a506..f4a4c249 100644 --- a/routes/rawtransactions.js +++ b/routes/rawtransactions.js @@ -5,19 +5,11 @@ let axios = require('axios'); let BITBOXCli = require('bitbox-cli/lib/bitbox-cli').default; let BITBOX = new BITBOXCli(); -//testnet creds -// let BitboxHTTP = axios.create({ -// baseURL: `http://167.99.110.201:18332/` -// }); -// let username = 'bitcoin'; -// let password = 'rD9yw2Y9RkOnYjYnDX'; - -// mainnet creds let BitboxHTTP = axios.create({ - baseURL: `http://138.68.54.100:8332/` + baseURL: process.env.RPC_BASEURL }); -let username = 'bitcoin'; -let password = 'xhFjluMJMyOXcYvF'; +let username = process.env.RPC_USERNAME; +let password = process.env.RPC_PASSWORD; router.get('/', (req, res, next) => { res.json({ status: 'rawtransactions' }); diff --git a/routes/transaction.js b/routes/transaction.js index 00c2971f..0411ee0c 100644 --- a/routes/transaction.js +++ b/routes/transaction.js @@ -23,7 +23,7 @@ router.get('/details/:txid', (req, res, next) => { })); } catch(error) { - axios.get(`http://194.14.246.69/api/tx/${req.params.txid}`) + axios.get(`${process.env.BITCOINCOM_BASEURL}tx/${req.params.txid}`) .then((response) => { let parsed = response.data; if(parsed && parsed.vin) { diff --git a/routes/util.js b/routes/util.js index 93bdb680..87f766a7 100644 --- a/routes/util.js +++ b/routes/util.js @@ -5,19 +5,11 @@ let axios = require('axios'); let BITBOXCli = require('bitbox-cli/lib/bitbox-cli').default; let BITBOX = new BITBOXCli(); -//testnet creds -// let BitboxHTTP = axios.create({ -// baseURL: `http://167.99.110.201:18332/` -// }); -// let username = 'bitcoin'; -// let password = 'rD9yw2Y9RkOnYjYnDX'; - -// mainnet creds let BitboxHTTP = axios.create({ - baseURL: `http://138.68.54.100:8332/` + baseURL: process.env.RPC_BASEURL }); -let username = 'bitcoin'; -let password = 'xhFjluMJMyOXcYvF'; +let username = process.env.RPC_USERNAME; +let password = process.env.RPC_PASSWORD; router.get('/', (req, res, next) => { res.json({ status: 'util' });