diff --git a/backend/controllers/cln/channels.js b/backend/controllers/cln/channels.js index c62276b8..efff40e3 100644 --- a/backend/controllers/cln/channels.js +++ b/backend/controllers/cln/channels.js @@ -12,12 +12,11 @@ export const listPeerChannels = (req, res, next) => { return res.status(options.statusCode).json({ message: options.message, error: options.error }); } options.url = req.session.selectedNode.ln_server_url + '/v1/listpeerchannels'; - request.post(options).then((body) => { + return request.post(options).then((body) => { body.channels.forEach((channel) => { const local = channel.to_us_msat || 0; const remote = (channel.total_msat - local) || 0; const total = channel.total_msat || 0; - // return getAliasForChannel(channel).then(channelAlias => { channel = { peer_id: channel.peer_id, peer_connected: channel.peer_connected, @@ -40,13 +39,13 @@ export const listPeerChannels = (req, res, next) => { dust_limit_msat: channel.dust_limit_msat, htlcs: channel.htlcs, features: channel.features, - alias: new Promise(getAlias(req.session.selectedNode, channel.peer_id)), + alias: getAlias(req.session.selectedNode, channel.peer_id).then((callRes) => callRes), to_them_msat: remote, balancedness: (total === 0) ? 1 : (1 - Math.abs((local - remote) / total)).toFixed(3) }; }); logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'Channels', msg: 'Peer Channels List Received', data: body.channels }); - res.status(200).json(body.channels); + return res.status(200).json(body.channels); }).catch((errRes) => { const err = common.handleError(errRes, 'Channels', 'List Peer Channels Error', req.session.selectedNode); return res.status(err.statusCode).json({ message: err.message, error: err.error }); diff --git a/backend/controllers/cln/network.js b/backend/controllers/cln/network.js index 34acaa04..a27fb577 100644 --- a/backend/controllers/cln/network.js +++ b/backend/controllers/cln/network.js @@ -87,11 +87,13 @@ export const getAlias = (selNode, id) => { return Promise.resolve(''); } options.body = { id }; - return request.post(options).then((body) => { - logger.log({ selectedNode: selNode, level: 'DEBUG', fileName: 'Network', msg: 'Peer Alias Finished', data: body }); - return body.nodes[0] ? body.nodes[0].alias : id.substring(0, 20); - }).catch((errRes) => { - common.handleError(errRes, 'Network', 'Peer Alias Error', selNode); - return id.substring(0, 20); + return new Promise((resolve, reject) => { + request.post(options).then((body) => { + logger.log({ selectedNode: selNode, level: 'DEBUG', fileName: 'Network', msg: 'Peer Alias Finished', data: body }); + resolve(body.nodes[0] ? body.nodes[0].alias : id.substring(0, 20)); + }).catch((errRes) => { + common.handleError(errRes, 'Network', 'Peer Alias Error', selNode); + resolve(id.substring(0, 20)); + }); }); }; diff --git a/frontend/index.html b/frontend/index.html index 452b2066..33073983 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -15,5 +15,5 @@