From 17bdf37f9ba20e7f5e4ab66b83a0f3383cf6bdad Mon Sep 17 00:00:00 2001 From: Overtorment Date: Mon, 13 Jul 2020 13:14:57 +0100 Subject: [PATCH] FIX: clear balance cache when user's invoice was paid (closes #85) --- controllers/api.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/controllers/api.js b/controllers/api.js index c7523a5..2870bd3 100644 --- a/controllers/api.js +++ b/controllers/api.js @@ -72,6 +72,9 @@ subscribeInvoicesCall.on('data', async function (response) { } let invoice = new Invo(redis, bitcoinclient, lightning); await invoice._setIsPaymentHashPaidInDatabase(LightningInvoiceSettledNotification.hash, true); + const user = new User(redis, bitcoinclient, lightning); + user._userid = await user.getUseridByPaymentHash(LightningInvoiceSettledNotification.hash); + await user.clearBalanceCache(); console.log('payment', LightningInvoiceSettledNotification.hash, 'was paid, posting to GroundControl...'); const baseURI = process.env.GROUNDCONTROL; if (!baseURI) return;