api added for fetching remote node fee

pull/260/head
saubyk 4 years ago
parent 8c81964e4d
commit 99fae43a50
No known key found for this signature in database
GPG Key ID: 00C9E2BC2E45666F

@ -157,3 +157,44 @@ exports.getQueryRoutes = (req, res, next) => {
});
});
};
exports.getRemoteFeePolicy = (req, res, next) => {
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/graph/edge/' + req.params.chanid;
request(options).then((body) => {
logger.info({fileName: 'Graph', msg: 'Edge Info Received: ' + JSON.stringify(body)});
if(undefined === body || body.error) {
res.status(500).json({
message: "Fetching Edge Info Failed!",
error: (undefined === body) ? 'Error From Server!' : body.error
});
}
if (undefined !== body) {
body.last_update_str = (undefined === body.last_update) ? '' : common.convertTimestampToDate(body.last_update);
}
remoteNodeFee = {};
if(body.node1_pub === req.params.localPubkey){
remoteNodeFee = {
time_lock_delta: body.node2_policy.time_lock_delta,
fee_base_msat: body.node2_policy.fee_base_msat,
fee_rate_milli_msat: body.node2_policy.fee_rate_milli_msat
};
}
else if(body.node2_pub === req.params.localPubkey) {
remoteNodeFee = {
time_lock_delta: body.node1_policy.time_lock_delta,
fee_base_msat: body.node1_policy.fee_base_msat,
fee_rate_milli_msat: body.node1_policy.fee_rate_milli_msat
};
}
res.status(200).json(remoteNodeFee);
})
.catch((err) => {
return res.status(500).json({
message: "Fetching Edge Info Failed!",
error: err.error
});
});
};

@ -7,6 +7,7 @@ router.get("/", authCheck, graphController.getDescribeGraph);
router.get("/info", authCheck, graphController.getGraphInfo);
router.get("/node/:pubKey", authCheck, graphController.getGraphNode);
router.get("/edge/:chanid", authCheck, graphController.getGraphEdge);
router.get("/edge/:chanid/:localPubkey", authCheck, graphController.getRemoteFeePolicy);
router.get("/routes/:destPubkey/:amount", authCheck, graphController.getQueryRoutes);
module.exports = router;

@ -38,7 +38,7 @@ export const TRANS_TYPES = [
export const NODE_SETTINGS = {
themes: [
{id: 'purple', name: 'Diogo'},
{id: 'teal', name: 'Suheb'},
{id: 'teal', name: 'My2Sats'},
{id: 'indigo', name: 'RTL'},
{id: 'pink', name: 'BK'}
],

Loading…
Cancel
Save