Skip to content

Commit

Permalink
FIX: groundcontrol post notification
Browse files Browse the repository at this point in the history
  • Loading branch information
Overtorment committed Nov 5, 2024
1 parent 0cf7387 commit 0311e56
Show file tree
Hide file tree
Showing 4 changed files with 4,010 additions and 2,102 deletions.
29 changes: 12 additions & 17 deletions controllers/api.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { User, Lock, Paym, Invo } from '../class/';
import Frisbee from 'frisbee';
import fetch from 'node-fetch';
const config = require('../config');
let express = require('express');
let router = express.Router();
Expand Down Expand Up @@ -92,21 +92,16 @@ const subscribeInvoicesCallCallback = async function (response) {
console.log('payment', LightningInvoiceSettledNotification.hash, 'was paid, posting to GroundControl...');
const baseURI = process.env.GROUNDCONTROL;
if (!baseURI) return;
const _api = new Frisbee({ baseURI: baseURI });
const apiResponse = await _api.post(
'/lightningInvoiceGotSettled',
Object.assign(
{},
{
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json',
},
body: LightningInvoiceSettledNotification,
},
),
);
console.log('GroundControl:', apiResponse.originalResponse.status);

const apiResponse = await fetch(`${baseURI}/lightningInvoiceGotSettled`, {
method: 'POST',
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json',
},
body: JSON.stringify(LightningInvoiceSettledNotification),
});
console.log('Groundcontrol apiResponse=', apiResponse);
}
};
let subscribeInvoicesCall = lightning.subscribeInvoices({});
Expand Down Expand Up @@ -146,7 +141,7 @@ router.post('/create', postLimiter, async function (req, res) {
(!req.body.partnerid || (typeof req.body.partnerid === 'string' || req.body.partnerid instanceof String))
&& (!req.body.accounttype || (typeof req.body.accounttype === 'string' || req.body.accounttype instanceof String))
) ) return errorBadArguments(res);

if (config.sunset) return errorSunset(res);

let u = new User(redis, bitcoinclient, lightning);
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ const bindPort = process.env.PORT || 3000;

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

0 comments on commit 0311e56

Please sign in to comment.