aboutsummaryrefslogtreecommitdiffstats
path: root/lib/nwc.ts
Commit message (Collapse)AuthorAgeFilesLines
* nwc: fix pay_invoice reply reliability, rate-limit drops, always replyAdam Soltys2026-06-171-42/+84
| | | | | | | | | | | | | | | | | | | | | | Port of master 8cb18821 (refs #80), adapted to staging's nwc event loop. (a) pay_invoice: sendLightning runs xpay to completion and finalize() sets p.ref = preimage, so return that directly instead of polling listpays and racing a 20s timeout that returned a misleading "Payment timed out" even when the payment settled. Keep a longer listpays loop as a fallback; on still-in-flight return an explicit "check with lookup_invoice". (b) rate limiting: raised per-pubkey cap 5 -> 60/min, and over-limit requests now get a NIP-47 RATE_LIMITED reply instead of a silent drop that looked like a lost reply. Every request path now always sends a 23195 reply (success, error, or handler-returned-nothing) so a client never hangs. Pulled the reply/encrypt logic into a reply() helper. The notify default-on part of 8cb18821 is intentionally NOT ported: master 10284aa1 reverted it to opt-in, which is already staging's behavior (notify = String(notify) === "true"). Co-Authored-By: Claude Opus 4.8 <[email protected]>
* nwc: publish 13194 info event only when missing, recheck hourlyAdam Soltys2026-06-171-26/+65
| | | | | | | | | | | | | | Port of master 6372d918, adapted to staging's nwc relay loop (no heartbeat here). NWC clients fetch the kind 13194 info event before they talk to the wallet; without it they show "no info event" and an unknown balance. 13194 is replaceable and meant to persist, so instead of blindly republishing on every connect, query the relay (ensureInfo) and publish only the server pubkeys whose event is actually missing. Re-check hourly so a relay restart that leaves our socket intact self-heals; interval is cleared on close/reconnect. Verified [email protected] Relay exposes ws/ readyState, on("eose") and unsubscribe. Co-Authored-By: Claude Opus 4.8 <[email protected]>
* nwc: pay_invoice honors request amount for amountless bolt11Adam Soltys2026-06-171-2/+14
| | | | | | | | | | | Port of master ce9616f6. pay_invoice derived the amount solely from the decoded invoice, so an amountless bolt11 yielded amount = round(undefined/ 1000) = NaN and sendLightning rejected it with "Invalid amount". NIP-47 lets the client specify the amount (msat) in the request; fall back to it when the invoice carries none, with a clear error if still missing. Fixes #83. Co-Authored-By: Claude Opus 4.8 <[email protected]>
* nwc: fix make_invoice timestamps (ms -> seconds) breaking NWC clientsAdam Soltys2026-06-171-1/+8
| | | | | | | | | | | Port of master 0154bb06. generate() stores `created` in milliseconds, but NWC make_invoice returned it directly as created_at and computed expires_at = created_at + expiry. NWC timestamps are Unix SECONDS (NIP-47), so clients parsed a ~1.78e12 expires_at that overflowed their date types (ptcpay's .NET DateTimeOffset, issue #84). Convert created to seconds. Fixes #84. Co-Authored-By: Claude Opus 4.8 <[email protected]>
* nwc: handle stale user record and skip reverted-duplicate recordsAdam Soltys2026-05-171-0/+2
| | | | | | | | | | - fail loudly when an NWC request references an app whose user record no longer exists (migrated/deleted account); previously crashed inside handle() on `user.id` - filter `revertedDuplicate` payments out of list_transactions so clients never see the doubled records that were later reverted Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
* stop republishing external events and add NWC rate limitingAdam Soltys2026-03-181-1/+14
| | | | Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
* fix typescript issuesAdam Soltys2026-02-281-3/+3
|
* formattingAdam Soltys2026-02-241-74/+52
|
* upgrade dependenciesAdam Soltys2026-02-061-1/+1
| | | | | | | | | | | | | - Fastify 4→5 with all plugins - @noble/hashes 1→2, @scure/base 1→2, @scure/bip32 1→2 - redis 4→5, pino 8→10, got 13→14, uuid 8→13, ws 7→8 - nostr-tools 2.16→2.23 (fix getPublicKey to pass Uint8Array) - Remove unused deps: date-fns, buffer-crc32, readable-stream-clone - Fix @noble/hashes import paths for v2 (.js extensions) - Fix Fastify maxParamLength deprecation (use routerOptions) - Convert sharp require() to ES import Co-Authored-By: Claude Opus 4.6 <[email protected]>
* tigerbeetleAdam Soltys2026-02-061-1/+2
|
* consult archive for older paymentsAdam Soltys2026-01-301-4/+8
|
* relay reconnect logicAdam Soltys2026-01-301-31/+45
|
* purge old nwc eventsAdam Soltys2026-01-281-2/+12
|
* quiet nwc failuresAdam Soltys2026-01-211-8/+8
|
* loggingAdam Soltys2026-01-211-8/+8
|
* Fix incorrect extratlvs format in pay_keysendEric P2025-11-091-1/+11
|
* rm logAdam Soltys2025-10-011-3/+0
|
* rotate server keyAdam Soltys2025-09-291-5/+36
|
* catch errors in pay_invoiceAdam Soltys2025-09-291-19/+23
|
* add missing make_invoice fields (fixes #78)Adam Soltys2025-07-261-2/+8
|
* put metadata in payment memoAdam Soltys2025-04-131-1/+2
|
* rm logAdam Soltys2025-03-081-1/+0
|
* fix get_infoAdam Soltys2025-03-081-1/+1
|
* nwc date comparison in secondsAdam Soltys2025-03-071-4/+3
|
* nwc max feeAdam Soltys2025-03-051-1/+2
|
* fix payment_hash lookupAdam Soltys2025-03-051-4/+7
|
* get payment_hash if possibleAdam Soltys2025-03-051-2/+2
|
* add importsAdam Soltys2025-03-051-0/+2
|
* add blockhash to get info responseAdam Soltys2025-03-051-7/+24
|
* record payment_hashAdam Soltys2025-03-051-5/+15
|
* handle no budgetAdam Soltys2025-02-201-1/+1
|
* check createdAdam Soltys2025-02-191-3/+4
|
* return quota exceeded errorAdam Soltys2025-02-171-1/+1
|
* fix nwc periodsAdam Soltys2025-02-181-7/+11
|
* nwc app prefixAdam Soltys2025-02-131-2/+2
|
* add uid to default appAdam Soltys2025-02-131-1/+2
|
* catch nwc errorsAdam Soltys2025-02-121-8/+8
|
* catch payment errorsAdam Soltys2025-02-121-7/+10
|
* nwc refactorAdam Soltys2025-02-121-9/+10
|
* nwc error loggingAdam Soltys2025-02-121-6/+6
|
* nwc notificationsAdam Soltys2025-02-111-11/+15
|
* default app on registerAdam Soltys2025-02-111-1/+2
|
* remove importsAdam Soltys2025-02-101-2/+0
|
* rm logsAdam Soltys2025-02-101-5/+0
|
* budgetAdam Soltys2025-02-101-8/+27
|
* check nwc budgetAdam Soltys2025-02-091-2/+19
|
* nwc apps endpointsAdam Soltys2025-02-071-9/+19
|
* use real lightning payments for mint paymentsAdam Soltys2025-02-051-17/+19
|
* log login failuresAdam Soltys2025-02-041-1/+2
|
* pass user pubkeyAdam Soltys2025-01-241-1/+1
|