feat: add blockchain status getter to all daemons

This commit is contained in:
Sérgio Salgado 2022-01-21 17:44:53 +00:00
parent 75cb094476
commit 2819b8a519
11 changed files with 107 additions and 16 deletions

View file

@ -205,6 +205,27 @@ function supportsBatching (cryptoCode) {
.then(() => SUPPORTS_BATCHING)
}
function checkBlockchainStatus (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => {
try {
const config = jsonRpc.parseConf(configPath)
// Daemon uses a different connection of the wallet
const rpcConfig = {
username: config['rpc-login'].split(':')[0],
password: config['rpc-login'].split(':')[1],
port: cryptoRec.defaultPort
}
return jsonRpc.fetchDigest(rpcConfig, 'get_info')
.then(res => !!res.synchronized ? 'ready' : 'syncing')
} catch (err) {
throw new Error('XMR daemon is currently not installed')
}
})
}
module.exports = {
balance,
sendCoins,
@ -212,5 +233,6 @@ module.exports = {
getStatus,
newFunding,
cryptoNetwork,
supportsBatching
supportsBatching,
checkBlockchainStatus
}