Peer and Channel Enhancements

Connect Peer: Remove host, add with pubkey only.
Peers List: Add Alias.
Channel select: Replace peer pubkey in select with Alias.
Channel Close.
pull/47/head
ShahanaFarooqui 6 years ago
parent 162e85e20b
commit d87f75d3ef

@ -9,5 +9,5 @@
<link rel="stylesheet" href="styles.dafc16bc57f826ca1c6c.css"></head>
<body>
<rtl-app></rtl-app>
<script type="text/javascript" src="runtime.ec2944dd8b20ec099bf3.js"></script><script type="text/javascript" src="polyfills.b2575713cefb95077d85.js"></script><script type="text/javascript" src="main.47da1d5880a45532e449.js"></script></body>
<script type="text/javascript" src="runtime.ec2944dd8b20ec099bf3.js"></script><script type="text/javascript" src="polyfills.b2575713cefb95077d85.js"></script><script type="text/javascript" src="main.02fab6887dacbfc6abf7.js"></script></body>
</html>

File diff suppressed because one or more lines are too long

@ -10,7 +10,7 @@ const peersRoutes = require("./routes/peers");
const feesRoutes = require("./routes/fees");
const balanceRoutes = require("./routes/balance");
const walletRoutes = require("./routes/wallet");
const graphInfoRoutes = require("./routes/graphInfo");
const graphRoutes = require("./routes/graph");
const newAddressRoutes = require("./routes/newAddress");
const transactionsRoutes = require("./routes/transactions");
const payReqRoutes = require("./routes/payReq");
@ -44,7 +44,7 @@ app.use("/api/peers", peersRoutes);
app.use("/api/fees", feesRoutes);
app.use("/api/balance", balanceRoutes);
app.use("/api/wallet", walletRoutes);
app.use("/api/network", graphInfoRoutes);
app.use("/api/network", graphRoutes);
app.use("/api/newaddress", newAddressRoutes);
app.use("/api/transactions", transactionsRoutes);
app.use("/api/payreq", payReqRoutes);

@ -62,3 +62,20 @@ exports.postTransactions = (req, res, next) => {
}
});
};
exports.closeChannel = (req, res, next) => {
let channelpoint = req.params.channelPoint.replace(":", "/");
options.url = common.lnd_server_url + '/channels/' + channelpoint;
request.delete(options, (error, response, body) => {
console.log('Close Channel Response: ');
console.log(body);
if(undefined === body || body.error) {
res.status(500).json({
message: "Close Channel Failed!",
error: (undefined === body) ? 'Error From Server!' : body.error
});
} else {
res.status(204).json({message: 'Channel Closed!'});
}
});
}

@ -0,0 +1,42 @@
var request = require('request');
var options = require("../connect");
var common = require('../common');
exports.getGraphInfo = (req, res, next) => {
options.url = common.lnd_server_url + '/graph/info';
request.get(options, (error, response, body) => {
const body_str = (undefined === body) ? '' : JSON.stringify(body);
const search_idx = (undefined === body) ? -1 : body_str.search('Not Found');
console.log('Network Information Received: ' + body_str);
if(undefined === body || search_idx > -1 || body.error) {
res.status(500).json({
message: "Fetching network Info failed!",
error: (undefined === body || search_idx > -1) ? 'Error From Server!' : body.error
});
} else {
body.btc_total_network_capacity = (undefined === body.total_network_capacity) ? 0 : common.convertToBTC(body.total_network_capacity);
body.btc_avg_channel_size = (undefined === body.avg_channel_size) ? 0 : common.convertToBTC(body.avg_channel_size);
body.btc_min_channel_size = (undefined === body.min_channel_size) ? 0 : common.convertToBTC(body.min_channel_size);
body.btc_max_channel_size = (undefined === body.max_channel_size) ? 0 : common.convertToBTC(body.max_channel_size);
console.log('Network Information After Rounding and Conversion: ' + body_str);
res.status(200).json(body);
}
});
};
exports.getGraphNode = (req, res, next) => {
options.url = common.lnd_server_url + '/graph/node/' + req.params.pubKey;
request.get(options, (error, response, body) => {
const body_str = (undefined === body) ? '' : JSON.stringify(body);
const search_idx = (undefined === body) ? -1 : body_str.search('Not Found');
console.log('Node Information Received: ' + body_str);
if(undefined === body || search_idx > -1 || body.error) {
res.status(500).json({
message: "Fetching node Info failed!",
error: (undefined === body || search_idx > -1) ? 'Error From Server!' : body.error
});
} else {
res.status(200).json(body);
}
});
};

@ -4,9 +4,6 @@ var common = require('../common');
exports.getNewAddress = (req, res, next) => {
options.url = common.lnd_server_url + '/newaddress?type=' + req.query.type;
console.log('\n-------------------------------------------------');
console.log('Get New Address');
console.log('-------------------------------------------------');
console.log('Request Query Params: ' + JSON.stringify(req.query));
console.log('Options URL: ' + JSON.stringify(options.url));
request.get(options, (error, response, body) => {

@ -6,5 +6,6 @@ router.get("/", ChannelsController.getChannels);
router.get("/:channelType", ChannelsController.getChannels);
router.post("/", ChannelsController.postChannel);
router.post("/transactions", ChannelsController.postTransactions);
router.delete("/:channelPoint", ChannelsController.closeChannel);
module.exports = router;

@ -0,0 +1,8 @@
const graphController = require("../controllers/graph");
const express = require("express");
const router = express.Router();
router.get("/info", graphController.getGraphInfo);
router.get("/node/:pubKey", graphController.getGraphNode);
module.exports = router;
Loading…
Cancel
Save