ADD: /getchaninfo/:chanid
This commit is contained in:
parent
d47f03501d
commit
17e9bd30c8
@ -109,6 +109,17 @@ subscribeInvoicesCall.on('end', function () {
|
||||
// The server has closed the stream.
|
||||
});
|
||||
|
||||
let lightningDescribeGraph = {};
|
||||
function updateDescribeGraph() {
|
||||
console.log('updateDescribeGraph()');
|
||||
lightning.describeGraph({ include_unannounced: true }, function (err, response) {
|
||||
if (!err) lightningDescribeGraph = response;
|
||||
console.log('updated graph');
|
||||
});
|
||||
}
|
||||
updateDescribeGraph();
|
||||
setInterval(updateDescribeGraph, 120000);
|
||||
|
||||
// ######################## ROUTES ########################
|
||||
|
||||
const rateLimit = require('express-rate-limit');
|
||||
@ -489,6 +500,20 @@ router.get('/queryroutes/:source/:dest/:amt', async function (req, res) {
|
||||
});
|
||||
});
|
||||
|
||||
router.get('/getchaninfo/:chanid', async function (req, res) {
|
||||
logger.log('/getchaninfo', [req.id]);
|
||||
|
||||
if (lightningDescribeGraph && lightningDescribeGraph.edges) {
|
||||
for (const edge of lightningDescribeGraph.edges) {
|
||||
console.log('edge.channel_id = ' + edge.channel_id);
|
||||
if (edge.channel_id == req.params.chanid) {
|
||||
return res.send(JSON.stringify(edge, null, 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
res.send('');
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
||||
// ################# HELPERS ###########################
|
||||
|
@ -14,6 +14,7 @@ function updateLightning() {
|
||||
lightning.getInfo({}, function (err, info) {
|
||||
if (err) {
|
||||
console.error('lnd failure:', err);
|
||||
return;
|
||||
}
|
||||
lightningGetInfo = info;
|
||||
});
|
||||
@ -23,6 +24,7 @@ function updateLightning() {
|
||||
console.error('lnd failure:', err);
|
||||
return;
|
||||
}
|
||||
console.log('updated');
|
||||
lightningListChannels = response;
|
||||
let channels = [];
|
||||
let max_chan_capacity = -1;
|
||||
@ -47,7 +49,6 @@ function updateLightning() {
|
||||
} catch (Err) {
|
||||
console.log(Err);
|
||||
}
|
||||
console.log('updated');
|
||||
}
|
||||
updateLightning();
|
||||
setInterval(updateLightning, 60000);
|
||||
|
1049
package-lock.json
generated
1049
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user