Skip to content

Commit

Permalink
Env vars.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Cardona committed Jun 28, 2018
1 parent c880cb1 commit 2dbb2bf
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 96 deletions.
10 changes: 5 additions & 5 deletions routes/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
}
Expand Down Expand Up @@ -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) => {
Expand All @@ -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) => {
Expand All @@ -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) => {
Expand All @@ -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 = [];
Expand Down
18 changes: 5 additions & 13 deletions routes/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand All @@ -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);
Expand All @@ -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);
Expand Down
14 changes: 3 additions & 11 deletions routes/blockchain.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down
14 changes: 3 additions & 11 deletions routes/control.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down
14 changes: 3 additions & 11 deletions routes/generating.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down
14 changes: 3 additions & 11 deletions routes/mining.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down
14 changes: 3 additions & 11 deletions routes/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down
14 changes: 3 additions & 11 deletions routes/rawtransactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down
2 changes: 1 addition & 1 deletion routes/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 3 additions & 11 deletions routes/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down

0 comments on commit 2dbb2bf

Please sign in to comment.