List Transactions and some lookup APIs

pull/47/head
ShahanaFarooqui 5 years ago
parent 477c6295e7
commit 533465fc8b

@ -23,6 +23,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@angular/router
MIT
hammerjs
MIT
The MIT License (MIT)
@ -316,9 +319,6 @@ Apache-2.0
@angular/router
MIT
@angular/common
MIT

@ -8,5 +8,5 @@
<link rel="stylesheet" href="styles.6acb6bfec10bb1e126bd.css"></head>
<body>
<rtl-app></rtl-app>
<script type="text/javascript" src="runtime.ec2944dd8b20ec099bf3.js"></script><script type="text/javascript" src="polyfills.418928a701f2040ada02.js"></script><script type="text/javascript" src="main.4b4a2461a4e57ba1f393.js"></script></body>
<script type="text/javascript" src="runtime.ec2944dd8b20ec099bf3.js"></script><script type="text/javascript" src="polyfills.418928a701f2040ada02.js"></script><script type="text/javascript" src="main.2a2dfd93fb3a453f3c70.js"></script></body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,5 +1,5 @@
var request = require("request-promise");
var options = require("../connect");
var request = require('request-promise');
var options = require('../connect');
var common = require('../common');
getAliasForChannel = (channel, channelType) => {
@ -61,7 +61,7 @@ exports.getChannels = (req, res, next) => {
})
.catch(function (err) {
return res.status(500).json({
message: "Fetching channels failed!",
message: 'Fetching Channels Failed!',
error: err.error
});
});
@ -79,7 +79,7 @@ exports.postChannel = (req, res, next) => {
console.log(body);
if(undefined === body || body.error) {
res.status(500).json({
message: "Open Channel Failed!",
message: 'Open Channel Failed!',
error: (undefined === body) ? 'Error From Server!' : body.error
});
} else {
@ -88,7 +88,7 @@ exports.postChannel = (req, res, next) => {
})
.catch(function (err) {
return res.status(500).json({
message: "Open Channel failed!",
message: 'Open Channel Failed!',
error: err.error
});
});
@ -114,12 +114,12 @@ exports.postTransactions = (req, res, next) => {
console.log(body);
if(undefined === body || body.error) {
res.status(500).json({
message: "Send Payment Failed!",
message: 'Send Payment Failed!',
error: (undefined === body) ? 'Error From Server!' : body.error
});
} else if (body.payment_error) {
res.status(500).json({
message: "Send Payment Failed!",
message: 'Send Payment Failed!',
error: (undefined === body) ? 'Error From Server!' : body.payment_error
});
} else {
@ -128,14 +128,14 @@ exports.postTransactions = (req, res, next) => {
})
.catch(function (err) {
return res.status(500).json({
message: "Send Payment Failed!",
message: 'Send Payment Failed!',
error: err.error
});
});
};
exports.closeChannel = (req, res, next) => {
let channelpoint = req.params.channelPoint.replace(":", "/");
let channelpoint = req.params.channelPoint.replace(':', '/');
options.url = common.lnd_server_url + '/channels/' + channelpoint + '?force=' + req.query.force;
console.log('\nClosing Channel URL: ');
console.log(options.url);
@ -144,7 +144,7 @@ exports.closeChannel = (req, res, next) => {
console.log(body);
if(undefined === body || body.error) {
res.status(500).json({
message: "Close Channel Failed!",
message: 'Close Channel Failed!',
error: (undefined === body) ? 'Error From Server!' : body.error
});
} else {
@ -153,7 +153,7 @@ exports.closeChannel = (req, res, next) => {
})
.catch(function (err) {
return res.status(500).json({
message: "Close Channel failed!",
message: 'Close Channel Failed!',
error: err.error
});
});

@ -73,3 +73,22 @@ exports.getGraphNode = (req, res, next) => {
});
};
exports.getGraphEdge = (req, res, next) => {
options.url = common.lnd_server_url + '/graph/edge/' + req.params.chanid;
request(options).then((body) => {
console.log(`Edge Information 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
});
}
res.status(200).json(body);
})
.catch((err) => {
return res.status(500).json({
message: "Fetching Edge Info Failed!",
error: err.error
});
});
};

@ -2,6 +2,26 @@ var request = require('request-promise');
var options = require("../connect");
var common = require('../common');
exports.getInvoice = (req, res, next) => {
options.url = common.lnd_server_url + '/invoice/' + req.params.rHashStr;
request(options).then((body) => {
console.log(`Invoice Information Received: ${JSON.stringify(body)}`);
if(undefined === body || body.error) {
res.status(500).json({
message: "Fetching Invoice Info Failed!",
error: (undefined === body) ? 'Error From Server!' : body.error
});
}
res.status(200).json(body);
})
.catch((err) => {
return res.status(500).json({
message: "Fetching Invoice Info Failed!",
error: err.error
});
});
};
exports.listInvoices = (req, res, next) => {
options.url = common.lnd_server_url + '/invoices';
request(options).then((body) => {

@ -2,6 +2,34 @@ var request = require('request-promise');
var options = require("../connect");
var common = require('../common');
exports.getTransactions = (req, res, next) => {
options.url = common.lnd_server_url + '/transactions';
request(options).then((body) => {
const body_str = (undefined === body) ? '' : JSON.stringify(body);
const search_idx = (undefined === body) ? -1 : body_str.search('Not Found');
console.log('Transactions Received: ' + body_str);
if(undefined === body || search_idx > -1 || body.error) {
res.status(500).json({
message: "Fetching Transactions Failed!",
error: (undefined === body || search_idx > -1) ? 'Error From Server!' : body.error
});
} else {
if (undefined !== body.transactions) {
body.transactions.forEach(transaction => {
transaction.time_stamp_str = (undefined === transaction.time_stamp) ? '' : common.convertTimestampToDate(transaction.time_stamp);
});
}
res.status(200).json(body.transactions);
}
})
.catch(function (err) {
return res.status(500).json({
message: "Fetching Transactions Failed!",
error: err.error
});
});
};
exports.postTransactions = (req, res, next) => {
options.url = common.lnd_server_url + '/transactions';
options.form = JSON.stringify({

@ -6,5 +6,6 @@ const authCheck = require("./authCheck");
router.get("/", authCheck, graphController.getDescribeGraph);
router.get("/info", authCheck, graphController.getGraphInfo);
router.get("/node/:pubKey", authCheck, graphController.getGraphNode);
router.get("/edge/:chanid", authCheck, graphController.getGraphNode);
module.exports = router;

@ -4,6 +4,7 @@ const router = express.Router();
const authCheck = require("./authCheck");
router.get("/", authCheck, invoicesController.listInvoices);
router.get("/:rHashStr", authCheck, invoicesController.getInvoice);
router.post("/", authCheck, invoicesController.addInvoice);
module.exports = router;

@ -3,6 +3,7 @@ const express = require("express");
const router = express.Router();
const authCheck = require("./authCheck");
router.get("/", authCheck, TransactionsController.getTransactions);
router.post("/", authCheck, TransactionsController.postTransactions);
module.exports = router;

Loading…
Cancel
Save