diff --git a/controllers/api.js b/controllers/api.js index c851f12..487c201 100644 --- a/controllers/api.js +++ b/controllers/api.js @@ -135,6 +135,8 @@ router.post('/create', postLimiter, async function (req, res) { logger.log('/create', [req.id]); if (!(req.body.partnerid && req.body.partnerid === 'bluewallet' && req.body.accounttype)) return errorBadArguments(res); + if (config.sunset) return errorSunset(res); + let u = new User(redis, bitcoinclient, lightning); await u.create(); await u.saveMetadata({ partnerid: req.body.partnerid, accounttype: req.body.accounttype, created_at: new Date().toISOString() }); @@ -172,6 +174,8 @@ router.post('/addinvoice', postLimiter, async function (req, res) { if (!req.body.amt || /*stupid NaN*/ !(req.body.amt > 0)) return errorBadArguments(res); + if (config.sunset) return errorSunsetAddInvoice(res); + const invoice = new Invo(redis, bitcoinclient, lightning); const r_preimage = invoice.makePreimageHex(); lightning.addInvoice( @@ -337,6 +341,8 @@ router.get('/getbtc', async function (req, res) { return errorBadAuth(res); } + if (config.sunset) return errorSunsetAddInvoice(res); + let address = await u.getAddress(); if (!address) { await u.generateAddress(); @@ -584,3 +590,19 @@ function errorPaymentFailed(res) { message: 'Payment failed. Does the receiver have enough inbound capacity?', }); } + +function errorSunset(res) { + return res.send({ + error: true, + code: 11, + message: 'This LNDHub instance is not accepting any more users', + }); +} + +function errorSunsetAddInvoice(res) { + return res.send({ + error: true, + code: 11, + message: 'This LNDHub instance is scheduled to shut down. Withdraw any remaining funds', + }); +}