diff --git a/lib/coin-utils.js b/lib/coin-utils.js index 2fdbd45b..c19384d1 100644 --- a/lib/coin-utils.js +++ b/lib/coin-utils.js @@ -92,7 +92,7 @@ function buildUrl (cryptoCode, address) { } function blockchainDir () { - return options.blockchainDir + return '/mnt/blockchains' } function cryptoDir (cryptoRec) { diff --git a/lib/plugins.js b/lib/plugins.js index b86f76b5..b79f2cd5 100644 --- a/lib/plugins.js +++ b/lib/plugins.js @@ -31,7 +31,7 @@ const mapValuesWithKey = _.mapValues.convert({ const TRADE_TTL = 2 * T.minutes const STALE_TICKER = 3 * T.minutes -const STALE_BALANCE = 3 * T.minutes +const STALE_BALANCE = 15 * T.seconds const PONG_TTL = '1 week' const tradesQueues = {} diff --git a/lib/plugins/common/json-rpc.js b/lib/plugins/common/json-rpc.js index 7d29cd66..03cad38f 100644 --- a/lib/plugins/common/json-rpc.js +++ b/lib/plugins/common/json-rpc.js @@ -48,21 +48,18 @@ function split (str) { } function parseConf (confPath) { - try { - const conf = fs.readFileSync(confPath) - const lines = conf.toString().split('\n') + const conf = fs.readFileSync(confPath) + const lines = conf.toString().split('\n') - const res = {} - for (let i = 0; i < lines.length; i++) { - const keyVal = split(lines[i]) + const res = {} + for (let i = 0; i < lines.length; i++) { + const keyVal = split(lines[i]) - // skip when value is empty - if (!keyVal[1]) continue + // skip when value is empty + if (!keyVal[1]) continue - res[keyVal[0]] = keyVal[1] - } - return res - } catch (e) { - throw new Error('wallet is currently not installed') + res[keyVal[0]] = keyVal[1] } + + return res } diff --git a/lib/plugins/wallet/bitcoincashd/bitcoincashd.js b/lib/plugins/wallet/bitcoincashd/bitcoincashd.js index fd141ede..418af0a2 100644 --- a/lib/plugins/wallet/bitcoincashd/bitcoincashd.js +++ b/lib/plugins/wallet/bitcoincashd/bitcoincashd.js @@ -8,16 +8,22 @@ const coinUtils = require('../../../coin-utils') const cryptoRec = coinUtils.getCryptoCurrency('BCH') const configPath = coinUtils.configPath(cryptoRec) const unitScale = cryptoRec.unitScale -const config = jsonRpc.parseConf(configPath) -const rpcConfig = { - username: config.rpcuser, - password: config.rpcpassword, - port: config.rpcport || cryptoRec.defaultPort +function rpcConfig () { + try { + const config = jsonRpc.parseConf(configPath) + return { + username: config.rpcuser, + password: config.rpcpassword, + port: config.rpcport || cryptoRec.defaultPort + } + } catch (err) { + throw new Error('wallet is currently not installed') + } } function fetch (method, params) { - return jsonRpc.fetch(rpcConfig, method, params) + return jsonRpc.fetch(rpcConfig(), method, params) } function checkCryptoCode (cryptoCode) { diff --git a/lib/plugins/wallet/bitcoind/bitcoind.js b/lib/plugins/wallet/bitcoind/bitcoind.js index e424eeef..238fcca1 100644 --- a/lib/plugins/wallet/bitcoind/bitcoind.js +++ b/lib/plugins/wallet/bitcoind/bitcoind.js @@ -8,16 +8,22 @@ const coinUtils = require('../../../coin-utils') const cryptoRec = coinUtils.getCryptoCurrency('BTC') const configPath = coinUtils.configPath(cryptoRec) const unitScale = cryptoRec.unitScale -const config = jsonRpc.parseConf(configPath) -const rpcConfig = { - username: config.rpcuser, - password: config.rpcpassword, - port: config.rpcport || cryptoRec.defaultPort +function rpcConfig () { + try { + const config = jsonRpc.parseConf(configPath) + return { + username: config.rpcuser, + password: config.rpcpassword, + port: config.rpcport || cryptoRec.defaultPort + } + } catch (err) { + throw new Error('wallet is currently not installed') + } } function fetch (method, params) { - return jsonRpc.fetch(rpcConfig, method, params) + return jsonRpc.fetch(rpcConfig(), method, params) } function checkCryptoCode (cryptoCode) { diff --git a/lib/plugins/wallet/dashd/dashd.js b/lib/plugins/wallet/dashd/dashd.js index 33c86c13..1ef6ee66 100644 --- a/lib/plugins/wallet/dashd/dashd.js +++ b/lib/plugins/wallet/dashd/dashd.js @@ -9,16 +9,22 @@ const E = require('../../../error') const cryptoRec = coinUtils.getCryptoCurrency('DASH') const configPath = coinUtils.configPath(cryptoRec) const unitScale = cryptoRec.unitScale -const config = jsonRpc.parseConf(configPath) -const rpcConfig = { - username: config.rpcuser, - password: config.rpcpassword, - port: config.rpcport || cryptoRec.defaultPort +function rpcConfig () { + try { + const config = jsonRpc.parseConf(configPath) + return { + username: config.rpcuser, + password: config.rpcpassword, + port: config.rpcport || cryptoRec.defaultPort + } + } catch (err) { + throw new Error('wallet is currently not installed') + } } function fetch (method, params) { - return jsonRpc.fetch(rpcConfig, method, params) + return jsonRpc.fetch(rpcConfig(), method, params) } function checkCryptoCode (cryptoCode) { diff --git a/lib/plugins/wallet/litecoind/litecoind.js b/lib/plugins/wallet/litecoind/litecoind.js index 234b816e..5601c6e4 100644 --- a/lib/plugins/wallet/litecoind/litecoind.js +++ b/lib/plugins/wallet/litecoind/litecoind.js @@ -9,16 +9,21 @@ const E = require('../../../error') const cryptoRec = coinUtils.getCryptoCurrency('LTC') const configPath = coinUtils.configPath(cryptoRec) const unitScale = cryptoRec.unitScale -const config = jsonRpc.parseConf(configPath) -const rpcConfig = { - username: config.rpcuser, - password: config.rpcpassword, - port: config.rpcport || cryptoRec.defaultPort +function rpcConfig () { + try { + const config = jsonRpc.parseConf(configPath) + return { + username: config.rpcuser, + password: config.rpcpassword, + port: config.rpcport || cryptoRec.defaultPort + } + } catch (err) { + throw new Error('wallet is currently not installed') + } } - function fetch (method, params) { - return jsonRpc.fetch(rpcConfig, method, params) + return jsonRpc.fetch(rpcConfig(), method, params) } function checkCryptoCode (cryptoCode) { diff --git a/lib/plugins/wallet/zcashd/zcashd.js b/lib/plugins/wallet/zcashd/zcashd.js index a594612b..c2749e3e 100644 --- a/lib/plugins/wallet/zcashd/zcashd.js +++ b/lib/plugins/wallet/zcashd/zcashd.js @@ -19,7 +19,7 @@ function rpcConfig () { port: config.rpcport || cryptoRec.defaultPort } } catch (err) { - throw err + throw new Error('wallet is currently not installed') } }