Browse Source

Support reading rpc credentials out of bitcoind's cookie file

fix-133-memory-crash
Nadav Ivgi 6 years ago
parent
commit
edf2748350
  1. 10
      app/config.js
  2. 4
      app/defaultCredentials.js

10
app/config.js

@ -1,3 +1,4 @@
var fs = require('fs');
var coins = require("./coins.js");
var currentCoin = process.env.BTCEXP_COIN || "BTC";
@ -7,6 +8,13 @@ try {
Object.assign(credentials, require("./credentials.js"))
} catch (err) {}
var rpcCred = credentials.rpc;
if (rpcCred.cookie && !rpcCred.username && !rpcCred.password && fs.existsSync(rpcCred.cookie)) {
[ rpcCred.username, rpcCred.password ] = fs.readFileSync(rpcCred.cookie).toString().split(':', 2);
if (!rpcCred.password) throw new Error('Cookie file '+rpcCred.cookie+' in unexpected format');
}
module.exports = {
cookiePassword: process.env.BTCEXP_COOKIE_PASSWORD || "0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
demoSite: !!process.env.BTCEXP_DEMO,
@ -107,7 +115,7 @@ module.exports = {
{name:"RPC Browser", url:"/rpc-browser", desc:"Browse the RPC functionality of this node. See docs and execute commands.", fontawesome:"fas fa-book"},
{name:"RPC Terminal", url:"/rpc-terminal", desc:"Directly execute RPCs against this node.", fontawesome:"fas fa-terminal"},
{name:(coins[currentCoin].name + " Fun"), url:"/fun", desc:"See fun/interesting historical blockchain data.", fontawesome:"fas fa-certificate"}
],

4
app/defaultCredentials.js

@ -1,9 +1,13 @@
var os = require('os');
var path = require('path');
module.exports = {
rpc: {
host: process.env.BTCEXP_BITCOIND_HOST || "127.0.0.1",
port: process.env.BTCEXP_BITCOIND_PORT || 8332,
username: process.env.BTCEXP_BITCOIND_USER,
password: process.env.BTCEXP_BITCOIND_PASS,
cookie: process.env.BTCEXP_BITCOIND_COOKIE || path.join(os.homedir(), '.bitcoin', '.cookie'),
},
influxdb:{

Loading…
Cancel
Save