|
1 | 1 | import { User, Lock, Paym, Invo } from '../class/';
|
2 |
| -import Frisbee from 'frisbee'; |
| 2 | +import fetch from 'node-fetch'; |
3 | 3 | const config = require('../config');
|
4 | 4 | let express = require('express');
|
5 | 5 | let router = express.Router();
|
@@ -92,21 +92,16 @@ const subscribeInvoicesCallCallback = async function (response) {
|
92 | 92 | console.log('payment', LightningInvoiceSettledNotification.hash, 'was paid, posting to GroundControl...');
|
93 | 93 | const baseURI = process.env.GROUNDCONTROL;
|
94 | 94 | 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); |
110 | 105 | }
|
111 | 106 | };
|
112 | 107 | let subscribeInvoicesCall = lightning.subscribeInvoices({});
|
@@ -146,7 +141,7 @@ router.post('/create', postLimiter, async function (req, res) {
|
146 | 141 | (!req.body.partnerid || (typeof req.body.partnerid === 'string' || req.body.partnerid instanceof String))
|
147 | 142 | && (!req.body.accounttype || (typeof req.body.accounttype === 'string' || req.body.accounttype instanceof String))
|
148 | 143 | ) ) return errorBadArguments(res);
|
149 |
| - |
| 144 | + |
150 | 145 | if (config.sunset) return errorSunset(res);
|
151 | 146 |
|
152 | 147 | let u = new User(redis, bitcoinclient, lightning);
|
|
0 commit comments