aboutsummaryrefslogtreecommitdiffstats
path: root/src/nostr.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-08-02 22:03:50 -0700
committerAdam Soltys <[email protected]>2026-08-02 22:03:50 -0700
commit5a16f87c3ba44c9c5231b37cf626db06b63ce351 (patch)
tree80330f929ce5108c388cc5dbbea4c0b9cddd0cb1 /src/nostr.js
parentc68a29852ee90d5955e84371ad28d8258a5c8b47 (diff)
downloadcoinosv3-5a16f87c3ba44c9c5231b37cf626db06b63ce351.tar.gz
coinosv3-5a16f87c3ba44c9c5231b37cf626db06b63ce351.zip
Sync just works: NIP-65 relays, no card; gift-locking leftovers gone
The Device sync card and toggle are gone — sync is always on, riding the user's own NIP-65 (kind 10002) write relays: the login npub's first, else the wallet key's, coinos relay as the fallback and always included. A fresh wallet identity with no NIP-65 publishes one (default relay) so other clients can find its events. The npub-locked-gift remnants go with it: the per-wallet nostr address card that pitched gift-locking, the how-it-works sentence, the dead NostrSync.sendDM/sendNostrDM path, and the orphaned claim-code field. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Wvj4aoeMZwA7VUGdJP9Swi
Diffstat (limited to 'src/nostr.js')
-rw-r--r--src/nostr.js25
1 files changed, 3 insertions, 22 deletions
diff --git a/src/nostr.js b/src/nostr.js
index 1a4a0c5..c644ef5 100644
--- a/src/nostr.js
+++ b/src/nostr.js
@@ -12,7 +12,6 @@
import * as nip06 from 'nostr-tools/nip06';
import * as nip44 from 'nostr-tools/nip44';
import * as nip04 from 'nostr-tools/nip04';
-import { wrapEvent as nip17WrapEvent } from 'nostr-tools/nip17';
import { getPublicKey, finalizeEvent, generateSecretKey } from 'nostr-tools/pure';
import { decode as nip19decode, npubEncode } from 'nostr-tools/nip19';
import { SimplePool } from 'nostr-tools/pool';
@@ -164,10 +163,9 @@ export function getSyncConfig() {
if (raw) {
const c = JSON.parse(raw);
const relays = Array.isArray(c.relays) ? c.relays : [];
- return {
- enabled: c.enabled !== false,
- relays: relays.length ? relays : DEFAULT_SYNC_RELAYS,
- };
+ // Always on — the toggle is gone; relays follow the user's NIP-65
+ // (adoptSyncRelays in the sync feature), coinos relay as the default.
+ return { enabled: true, relays: relays.length ? relays : DEFAULT_SYNC_RELAYS };
}
} catch {}
return { enabled: true, relays: DEFAULT_SYNC_RELAYS }; // default: on, coinos relay
@@ -223,23 +221,6 @@ export class NostrSync {
return results.some((r) => r.status === 'fulfilled');
}
- // Deliver an encrypted DM (a locked gift's claim code) as a NIP-17 gift wrap
- // (kind 1059) — the modern standard every current client supports. Goes to the
- // recipient's published inbox relays (NIP-17/65) plus a broad fallback. Returns
- // true if ≥1 relay accepted it.
- async sendDM(recipientPkHex, text, relays = null) {
- if (!this.sk) return false;
- let evt;
- try { evt = nip17WrapEvent(this.sk, { publicKey: recipientPkHex }, text); } catch { return false; }
- let targets = relays;
- if (!targets) {
- const inbox = await fetchInboxRelays(recipientPkHex);
- targets = [...new Set([...inbox, ...PROFILE_RELAYS])].slice(0, 8); // recipient's inbox + safety net
- }
- const res = await Promise.allSettled(pool.publish(targets, evt));
- return res.some((x) => x.status === 'fulfilled');
- }
-
// Publish an arbitrary event (finalized here with our key) to the relays.
// Used by features that speak their own event kinds (e.g. ark zaps).
async publishEvent(partial) {