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

@ -7,24 +7,11 @@ const BN = require('../../../bn')
const E = require('../../../error')
const cryptoRec = coinUtils.getCryptoCurrency('DASH')
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) {