From 74692a2102c376f38148b46e7237e3170de02a18 Mon Sep 17 00:00:00 2001 From: Patrick Mulligan Date: Mon, 16 Feb 2026 16:56:44 -0500 Subject: [PATCH] fix: use fresh balance in PayAppUserInvoice notification notifyAppUserPayment was sending the stale cached balance from the entity loaded before PayInvoice decremented it. Update the entity's balance_sats from the PayInvoice response so LiveUserOperation events contain the correct post-payment balance. Co-Authored-By: Claude Opus 4.6 --- src/services/main/applicationManager.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/services/main/applicationManager.ts b/src/services/main/applicationManager.ts index aaafd8a7..f990e7de 100644 --- a/src/services/main/applicationManager.ts +++ b/src/services/main/applicationManager.ts @@ -239,6 +239,8 @@ export default class { const paid = await this.paymentManager.PayInvoice(appUser.user.user_id, req, app, { ack: pendingOp => { this.notifyAppUserPayment(appUser, pendingOp) } }) + // Refresh appUser balance from DB so notification has accurate latest_balance + appUser.user.balance_sats = paid.latest_balance this.notifyAppUserPayment(appUser, paid.operation) getLogger({ appName: app.name })(appUser.identifier, "invoice paid", paid.amount_paid, "sats") return paid