Ported from the upstream PR (lnbits/nostrclient#74, idea from #68).
Nothing will ever serve a subscription when nostrclient has no relay
at all, so refuse it per NIP-01 instead of registering it silently.
Keyed on "no relay configured" rather than "none connected": a
configured relay that is merely reconnecting gets the cached
subscription replayed, so refusing the REQ there would be a regression.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Tbyw6FwjhEJg3gHfPHxWt
nostrclient never answered a client's EVENT with the NIP-01
`["OK", <id>, <accepted>, <message>]` command result. Clients built on
nostr-tools and similar libraries wait for that reply before treating a
publish as successful, so NWC wallet apps paired through the public
endpoint reported "publish failed" even though the request had been
fanned out and answered.
Relay OKs now flow through the message pool like events and notices.
The router tracks each EVENT a client publishes and replies exactly
once: `true` as soon as any relay accepts, `false` once every relay
connected at publish time has rejected it, after a 10 s timeout, or
immediately when no relay is connected. OKs nobody is waiting on are
dropped at the pump so the shared result map cannot grow unbounded.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Tbyw6FwjhEJg3gHfPHxWt
* Build EVENT message with json.dumps instead of string interpolation
Ensures outbound Nostr messages are valid JSON and safely escaped by
constructing the payload as Python objects and serializing with
json.dumps
* improve logs
* remove log causing check failure
* fix: increase the wait time for re-connecting to a relay
* fix: blocking sleep
* fix: remove blocking sleep
* fix: allow multiple filters per request