From 52ae38b92b8791c2e8b710d5b78174a95b57ee3d Mon Sep 17 00:00:00 2001 From: Dan Janosik Date: Fri, 29 Jun 2018 15:43:18 +0200 Subject: [PATCH] support for passing rpc credentials in with environment variables --- app.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index 39b6cac..b5ac1ad 100755 --- a/app.js +++ b/app.js @@ -87,14 +87,27 @@ app.runOnStartup = function() { console.log("Running RPC Explorer for coin: " + global.coinConfig.name); + var rpcCredentials = null; if (config.credentials.rpc) { + rpcCredentials = config.credentials.rpc; + + } else if (process.env.RPC_HOST) { + rpcCredentials = { + host: process.env.RPC_HOST, + port: process.env.RPC_PORT, + username: process.env.RPC_USERNAME, + password: process.env.RPC_PASSWORD + }; + } + + if (rpcCredentials) { console.log("Connecting via RPC to node at " + config.credentials.rpc.host + ":" + config.credentials.rpc.port); global.client = new bitcoinCore({ - host: config.credentials.rpc.host, - port: config.credentials.rpc.port, - username: config.credentials.rpc.username, - password: config.credentials.rpc.password, + host: rpcCredentials.host, + port: rpcCredentials.port, + username: rpcCredentials.username, + password: rpcCredentials.password, timeout: 5000 }); }