Issue Fix #36 compatible with LND head, Forwarding History

This commit is contained in:
ShahanaFarooqui 2019-01-22 22:28:45 -05:00
parent 98ec638bd9
commit 5c7374d5c1
9 changed files with 75 additions and 4 deletions

View File

@ -331,6 +331,9 @@ MIT
@ngrx/effects
MIT
angular-user-idle
MIT
@angular/material/dialog
@angular/material

View File

@ -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.fc7a7c60f2fdb2372e25.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.bd2d87556411474e7757.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

2
app.js
View File

@ -18,6 +18,7 @@ const payReqRoutes = require("./routes/payReq");
const paymentsRoutes = require("./routes/payments");
const RTLConfRoutes = require("./routes/RTLConf");
const invoiceRoutes = require("./routes/invoices");
const switchRoutes = require("./routes/switch");
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
@ -53,6 +54,7 @@ app.use("/api/payreq", payReqRoutes);
app.use("/api/payments", paymentsRoutes);
app.use("/api/conf", RTLConfRoutes);
app.use("/api/invoices", invoiceRoutes);
app.use("/api/switch", switchRoutes);
// sending angular application when route doesn't match
app.use((req, res, next) => {

49
controllers/switch.js Normal file
View File

@ -0,0 +1,49 @@
var request = require('request-promise');
var options = require("../connect");
var common = require('../common');
var logger = require('./logger');
exports.forwardingHistory = (req, res, next) => {
options.url = common.lnd_server_url + '/switch';
options.form = {};
if (undefined !== req.body.num_max_events) {
options.form.num_max_events = req.body.num_max_events;
}
if (undefined !== req.body.index_offset) {
options.form.index_offset = req.body.index_offset;
}
if (undefined !== req.body.end_time) {
options.form.end_time = req.body.end_time;
}
if (undefined !== req.body.start_time) {
options.form.start_time = req.body.start_time;
}
options.form = JSON.stringify(options.form);
logger.info('\r\nSwitch: 14: ' + JSON.stringify(Date.now()) + ': INFO: Switch Post Options: ' + JSON.stringify(options));
request.post(options).then((body) => {
logger.info('\r\nSwitch: 16: ' + JSON.stringify(Date.now()) + ': INFO: Switch Post Response: ' + JSON.stringify(body));
if(undefined === body || body.error) {
logger.error('\r\nSwitch: 18: ' + JSON.stringify(Date.now()) + ': ERROR: Switch Post Erroe: ' + JSON.stringify((undefined === body) ? 'Error From Server!' : body.error));
res.status(500).json({
message: "Switch post failed!",
error: (undefined === body) ? 'Error From Server!' : body.error
});
} else {
if (undefined !== body.forwarding_events) {
body.forwarding_events.forEach(event => {
event.timestamp_str = (undefined === event.timestamp) ? '' : common.convertTimestampToDate(event.timestamp);
});
body.forwarding_events = common.sortDescByKey(body.forwarding_events, 'timestamp');
}
logger.info('\r\nSwitch: 38: ' + JSON.stringify(Date.now()) + ': INFO: Forwarding History Received: ' + JSON.stringify(body));
res.status(201).json(body);
}
})
.catch(function (err) {
logger.error('\r\nSwitch: 28: ' + JSON.stringify(Date.now()) + ': ERROR: Switch Post Error: ' + JSON.stringify(err));
return res.status(500).json({
message: "Switch post failed!",
error: err.error
});
});
};

10
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "rtl",
"version": "0.1.12-alpha",
"version": "0.1.13-alpha",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -1385,6 +1385,14 @@
"resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz",
"integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU="
},
"angular-user-idle": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/angular-user-idle/-/angular-user-idle-2.0.0.tgz",
"integrity": "sha512-VWVoiSelnXuA1vn9iLbCw09+yKPKAbXr8Rd5gNf93M7yxTKHG4wbUqtEhKo3rA0DhJfzBM7yGbHsZmAEOS4ODw==",
"requires": {
"tslib": "^1.9.0"
}
},
"angular2-qrcode": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/angular2-qrcode/-/angular2-qrcode-2.0.1.tgz",

View File

@ -1,6 +1,6 @@
{
"name": "rtl",
"version": "0.1.12-alpha",
"version": "0.1.13-alpha",
"license": "MIT",
"scripts": {
"ng": "ng",
@ -31,6 +31,7 @@
"@ngrx/store": "^7.0.0",
"@ngrx/store-devtools": "^7.0.0",
"@swimlane/ngx-charts": "^10.0.0",
"angular-user-idle": "^2.0.0",
"angular2-qrcode": "^2.0.1",
"atob": "^2.1.2",
"core-js": "^2.5.4",

8
routes/switch.js Normal file
View File

@ -0,0 +1,8 @@
const SwitchController = require("../controllers/switch");
const express = require("express");
const router = express.Router();
const authCheck = require("./authCheck");
router.post("/", authCheck, SwitchController.forwardingHistory);
module.exports = router;