Merge branch 'bluewallet-lndhub'

This commit is contained in:
Agustin Kassis
2020-03-20 20:32:07 -03:00
9 changed files with 436 additions and 448 deletions

View File

@@ -25,17 +25,19 @@ bitcoinclient.request('getblockchaininfo', false, function(err, info) {
process.exit(1);
}
} else {
console.error('bitcoind failure');
console.error('bitcoind failure:', err, info);
process.exit(2);
}
});
lightning.getInfo({}, function(err, info) {
if (err) {
console.error('lnd failure');
console.error('lnd failure shuuu');
console.dir(err);
process.exit(3);
}
if (info) {
console.info(info);
if (!info.synced_to_chain) {
console.error('lnd not synced');
process.exit(4);
@@ -56,7 +58,7 @@ redis.info(function(err, info) {
const rateLimit = require('express-rate-limit');
const postLimiter = rateLimit({
windowMs: 30 * 60 * 1000,
max: 50,
max: 100,
});
router.post('/create', postLimiter, async function(req, res) {
@@ -348,6 +350,22 @@ router.get('/getuserinvoices', async function(req, res) {
}
});
router.get('/checkinvoicepaid', async function(req, res) {
logger.log('/checkinvoicepaid', [req.id]);
let u = new User(redis, bitcoinclient, lightning);
if (!(await u.loadByAuthorization(req.headers.authorization))) {
return errorBadAuth(res);
}
try {
let paid = await u.getPaymentHashPaid(req.query.pay_req);
res.send(paid);
} catch (Err) {
logger.log('', [req.id, 'error getting invoice:', Err.message, 'userid:', u.getUserId()]);
res.send(false);
}
});
router.get('/getpending', async function(req, res) {
logger.log('/getpending', [req.id]);
let u = new User(redis, bitcoinclient, lightning);

View File

@@ -19,13 +19,13 @@ function updateLightning() {
lightning.listChannels({}, function(err, response) {
if (err) {
console.error('lnd failure:', err);
console.error('lnd 2 failure:', err);
return;
}
lightningListChannels = response;
let channels = [];
for (let channel of lightningListChannels.channels) {
let divider = 524287;
let divider = 5242870;
let ascii_length1 = channel.local_balance / divider;
let ascii_length2 = channel.remote_balance / divider;
channel.ascii = '[';
@@ -75,7 +75,7 @@ const pubkey2name = {
router.get('/', function(req, res) {
logger.log('/', [req.id]);
if (!lightningGetInfo) {
console.error('lnd failure');
console.error('lnd failurefff');
process.exit(3);
}
res.setHeader('Content-Type', 'text/html');