From dd7430503da08b43c6ef26ae4b658899e398876b Mon Sep 17 00:00:00 2001 From: Overtorment Date: Wed, 9 Jan 2019 01:56:09 +0000 Subject: [PATCH] FIX: able to pay same internal invoice twice (closes #5) --- controllers/api.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/controllers/api.js b/controllers/api.js index dff5eca..1e0a7a5 100644 --- a/controllers/api.js +++ b/controllers/api.js @@ -145,6 +145,12 @@ router.post('/payinvoice', async function(req, res) { return errorGeneralServerError(res); } + if (await u.getPaymentHashPaid(info.payment_hash)) { + // this internal invoice was paid, no sense paying it again + await lock.releaseLock(); + return errorLnd(res); + } + let UserPayee = new User(redis); UserPayee._userid = userid_payee; // hacky, fixme let payee_balance = await UserPayee.getBalance();