diff --git a/config/daemon/parse-zcash-conf.js b/config/daemon/parse-zcash-conf.js index 2625c20..de8036e 100644 --- a/config/daemon/parse-zcash-conf.js +++ b/config/daemon/parse-zcash-conf.js @@ -4,7 +4,6 @@ import fs from 'fs'; import { locateZcashConf } from './locate-zcash-conf'; import { filterObjectNullKeys } from '../../app/utils/filter-object-null-keys'; -import store from '../electron-store'; type ZcashConfFile = { testnet: ?string, @@ -32,14 +31,15 @@ type ZcashConfFile = { paytxfee: ?string, }; -export const parseZcashConf = (): Promise> => new Promise((resolve, reject) => { +export const parseZcashConf = (): Promise => new Promise((resolve, reject) => { fs.readFile(locateZcashConf(), (err, file) => { if (err) return reject(err); const fileString = file.toString(); + /* eslint-disable no-unused-vars */ // $FlowFixMe - const { rpcuser, rpcpassword, ...payload }: ZcashConfFile = filterObjectNullKeys( + const payload: ZcashConfFile = filterObjectNullKeys( fileString.split('\n').reduce((acc, cur) => { if (!cur) return acc; @@ -52,14 +52,18 @@ export const parseZcashConf = (): Promise> => new Promise((resolve }, {}), ); - store.set('rpcuser', rpcuser || ''); - store.set('rpcpassword', rpcpassword || ''); - - // $FlowFixMe - resolve(Object.keys(payload).reduce((acc, key) => acc.concat(`-${key}=${payload[key]}`), [])); + resolve(payload); }); }); +/* eslint-disable-next-line max-len */ +export const generateArgsFromConf = (obj: ZcashConfFile): Array => Object.keys(obj).reduce((acc, key) => { + // We can omit the credentials for the command line + if (key === 'rpcuser' || key === 'rpcpassword') return acc; + + return acc.concat(`-${key}=${String(obj[key])}`); +}, []); + export const parseCmdArgs = (cmd: string): { user: string, password: string } => { const rpcUserInArgs = cmd.split(' ').find(x => x.startsWith('-rpcuser')); const rpcPasswordInArgs = cmd.split(' ').find(x => x.startsWith('-rpcpassword'));