refactor: error handling on unconfigred wallet
This commit is contained in:
parent
e5846a92e0
commit
7f49684b67
5 changed files with 24 additions and 60 deletions
|
|
@ -3,8 +3,9 @@ const axios = require('axios')
|
|||
const uuid = require('uuid')
|
||||
const fs = require('fs')
|
||||
const _ = require('lodash/fp')
|
||||
const coinUtils = require('../../coin-utils')
|
||||
|
||||
module.exports = {fetch, parseConf}
|
||||
module.exports = { fetch, parseConf, rpcConfig }
|
||||
|
||||
function fetch (account = {}, method, params) {
|
||||
params = _.defaultTo([], params)
|
||||
|
|
@ -63,3 +64,17 @@ function parseConf (confPath) {
|
|||
|
||||
return res
|
||||
}
|
||||
|
||||
function rpcConfig (cryptoRec) {
|
||||
try {
|
||||
const configPath = coinUtils.configPath(cryptoRec)
|
||||
const config = parseConf(configPath)
|
||||
return {
|
||||
username: config.rpcuser,
|
||||
password: config.rpcpassword,
|
||||
port: config.rpcport || cryptoRec.defaultPort
|
||||
}
|
||||
} catch (err) {
|
||||
throw new Error('Wallet is currently not installed')
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue