From 8cb1882111c079cfac9870054d9917fa5f94de76 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 6 Jun 2026 09:10:16 -0700 Subject: nwc: fix pay_invoice reply reliability, rate-limit drops, notifications MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three issues reported by an NWC client integrator (refs #80): (a) pay_invoice sync reply: the handler polled listpays for ~20s then returned a misleading "Payment timed out" error on slow routes even though the payment settled — client never got the preimage. sendLightning already runs xpay to completion and finalize() sets p.ref = preimage, so return that directly; keep a longer listpays loop only as a fallback, and on still-in-flight return an explicit "check with lookup_invoice" rather than implying failure. (b) rate limiting: raised per-pubkey cap 5/min -> 60/min (normal usage — a balance check + payment + a few lookup_invoice reconciles — trivially exceeded 5), and over-limit requests now get a NIP-47 RATE_LIMITED error reply instead of a silent drop that looked exactly like a lost reply. Also: every request path now always sends a 23195 reply (success, error, or handler-returned- nothing) so a client never hangs waiting. (c) notifications: payment_received/payment_sent are advertised in the info event but app.notify defaulted to false unless the client sent notify:"true" (only ~1% of apps had it on), so they never fired. Default notify ON; only disable when explicitly "false". (Existing apps still false — backfill TBD.) Co-Authored-By: Claude Opus 4.8 (1M context) --- routes/users.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'routes') diff --git a/routes/users.ts b/routes/users.ts index 128a2b72..e6f7f625 100644 --- a/routes/users.ts +++ b/routes/users.ts @@ -989,7 +989,12 @@ export default { if (app && uid !== app.uid) fail("Unauthorized"); if (secret) pubkey = getPublicKey(hexToBytes(secret)); - notify = String(notify) === "true"; + // Default notifications ON. The info event advertises payment_received/ + // payment_sent, but notify previously defaulted to false unless the client + // sent notify:"true" — which most don't — so the advertised notifications + // never fired (only ~1% of apps had it on). Only disable when explicitly + // set to "false". + notify = String(notify) !== "false"; app = { ...app, -- cgit v1.2.3