refactor: error handling on unconfigred wallet

This commit is contained in:
José Oliveira 2021-09-06 12:10:44 +01:00 committed by Josh Harvey
parent e5846a92e0
commit 7f49684b67
5 changed files with 24 additions and 60 deletions

View file

@ -6,24 +6,11 @@ const E = require('../../../error')
const coinUtils = require('../../../coin-utils')
const cryptoRec = coinUtils.getCryptoCurrency('BTC')
const configPath = coinUtils.configPath(cryptoRec)
const unitScale = cryptoRec.unitScale
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')
}
}
const rpcConfig = jsonRpc.rpcConfig(cryptoRec)
function fetch (method, params) {
return jsonRpc.fetch(rpcConfig(), method, params)
return jsonRpc.fetch(rpcConfig, method, params)
}
function checkCryptoCode (cryptoCode) {