aboutsummaryrefslogtreecommitdiffstats
path: root/src/nostr.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-08-01 12:45:01 -0700
committerAdam Soltys <[email protected]>2026-08-01 12:45:01 -0700
commitef7f5aa8d713bf0e754607f9fcc0527c5a10e737 (patch)
tree227d1d63ec6a3ddf70f362ece1db42579556e0d2 /src/nostr.js
parent37989576d91d21b4f727a67470eef9e07e85dd07 (diff)
downloadcoinosv3-ef7f5aa8d713bf0e754607f9fcc0527c5a10e737.tar.gz
coinosv3-ef7f5aa8d713bf0e754607f9fcc0527c5a10e737.zip
Surface refused relay publishes; publish NWC info once per session
relay.coinos.io's write policy was rejecting every 23195/13194 hal sent (kinds were whitelisted to coinos server pubkeys — incompatible with hal's per-connection service keys) and the rejections temp-banned the IP. publishOn swallowed all of it, which disguised a relay-side policy problem as a client bug. The relay policy is fixed separately; here, refused publishes now log the relay and reason, and the 13194 info event goes out once per connection per session instead of on every listen() so replies keep their share of the relay's per-IP rate budget. Co-Authored-By: Claude Fable 5 <[email protected]>
Diffstat (limited to 'src/nostr.js')
-rw-r--r--src/nostr.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/nostr.js b/src/nostr.js
index e1f1c14..006a74c 100644
--- a/src/nostr.js
+++ b/src/nostr.js
@@ -37,7 +37,18 @@ export function subscribeOn(relays, filter, onEvent, extra = {}) {
} catch { return () => {}; }
}
export async function publishOn(relays, evt) {
- try { await Promise.allSettled(pool.publish(relays, evt)); return true; } catch { return false; }
+ try {
+ const results = await Promise.allSettled(pool.publish(relays, evt));
+ // A rejected publish is a relay refusing the event (policy, rate limit,
+ // ban). Swallowing that silently once hid a relay-side rejection behind
+ // what looked like a client bug — always say which relay refused and why.
+ results.forEach((r, i) => {
+ if (r.status === 'rejected') {
+ console.warn(`nostr: publish kind ${evt.kind} refused by ${relays[i]}:`, r.reason?.message || r.reason);
+ }
+ });
+ return results.some((r) => r.status === 'fulfilled');
+ } catch { return false; }
}
// --- locking a gift to a recipient's Nostr key ---------------------------