# lnurl-server A lightweight LNURL-pay / Lightning Address server that creates invoices via a NIP-47 (NWC / Nostr Wallet Connect) wallet service. ## What it does Serves `/.well-known/lnurlp/` and `/.well-known/lnurlp//callback`. When a wallet requests a payment, the callback asks the NWC wallet service for a `make_invoice` and returns the bolt11 invoice to the payer. ## Configuration (env) - `NWC_URI` (required) - the `nostr+walletconnect://` connection string for the wallet service. - `LNURL_USERNAME` (default `me`) - `LNURL_DOMAIN` (default `mleku.dev`) - `PORT` (default `8096`) ## Why this version The original implementation opened a fresh WebSocket connection to the relay for every single invoice request (`nostr.RelayConnect` per callback), which churned TCP/TLS/WebSocket connections and leaked them into CLOSE-WAIT / FIN-WAIT-2 on the relay under load. This version: - Keeps a single persistent relay connection, reused across requests, with automatic reconnect if it drops. - Serializes request/response exchanges with a mutex so concurrent callbacks cannot cross-talk on the shared connection. - Subscribes on the request event id (`#e`) so only the response to the current request matches. - Bounds every exchange with a timeout so a hung wallet never strands a subscription or goroutine. - Uses explicit HTTP server timeouts and graceful shutdown. ## Build ```sh go build -o lnurl-server . ```