Skip to content

Commit 0311e56

Browse files
committed
FIX: groundcontrol post notification
1 parent 0cf7387 commit 0311e56

File tree

4 files changed

+4010
-2102
lines changed

4 files changed

+4010
-2102
lines changed

controllers/api.js

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { User, Lock, Paym, Invo } from '../class/';
2-
import Frisbee from 'frisbee';
2+
import fetch from 'node-fetch';
33
const config = require('../config');
44
let express = require('express');
55
let router = express.Router();
@@ -92,21 +92,16 @@ const subscribeInvoicesCallCallback = async function (response) {
9292
console.log('payment', LightningInvoiceSettledNotification.hash, 'was paid, posting to GroundControl...');
9393
const baseURI = process.env.GROUNDCONTROL;
9494
if (!baseURI) return;
95-
const _api = new Frisbee({ baseURI: baseURI });
96-
const apiResponse = await _api.post(
97-
'/lightningInvoiceGotSettled',
98-
Object.assign(
99-
{},
100-
{
101-
headers: {
102-
'Access-Control-Allow-Origin': '*',
103-
'Content-Type': 'application/json',
104-
},
105-
body: LightningInvoiceSettledNotification,
106-
},
107-
),
108-
);
109-
console.log('GroundControl:', apiResponse.originalResponse.status);
95+
96+
const apiResponse = await fetch(`${baseURI}/lightningInvoiceGotSettled`, {
97+
method: 'POST',
98+
headers: {
99+
'Access-Control-Allow-Origin': '*',
100+
'Content-Type': 'application/json',
101+
},
102+
body: JSON.stringify(LightningInvoiceSettledNotification),
103+
});
104+
console.log('Groundcontrol apiResponse=', apiResponse);
110105
}
111106
};
112107
let subscribeInvoicesCall = lightning.subscribeInvoices({});
@@ -146,7 +141,7 @@ router.post('/create', postLimiter, async function (req, res) {
146141
(!req.body.partnerid || (typeof req.body.partnerid === 'string' || req.body.partnerid instanceof String))
147142
&& (!req.body.accounttype || (typeof req.body.accounttype === 'string' || req.body.accounttype instanceof String))
148143
) ) return errorBadArguments(res);
149-
144+
150145
if (config.sunset) return errorSunset(res);
151146

152147
let u = new User(redis, bitcoinclient, lightning);

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,6 @@ const bindPort = process.env.PORT || 3000;
5252

5353
let server = app.listen(bindPort, bindHost, function () {
5454
logger.log('BOOTING UP', 'Listening on ' + bindHost + ':' + bindPort);
55+
logger.log('using GroundControl', process.env.GROUNDCONTROL);
5556
});
5657
module.exports = server;

0 commit comments

Comments
 (0)