aboutsummaryrefslogtreecommitdiffstats
path: root/lib/nostr.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-24 13:18:42 -0800
committerAdam Soltys <[email protected]>2026-02-24 13:18:42 -0800
commitad7b09b43323d0ffc0a8ddabb43e4838a184c697 (patch)
treefbf2a59f81771b2938f474c8e7b35a497d2960e4 /lib/nostr.ts
parent9e97e040617bfa0b40150c0eba298bf186bbeeaf (diff)
downloadcoinos-server-ad7b09b43323d0ffc0a8ddabb43e4838a184c697.tar.gz
coinos-server-ad7b09b43323d0ffc0a8ddabb43e4838a184c697.zip
formatting
Diffstat (limited to 'lib/nostr.ts')
-rw-r--r--lib/nostr.ts27
1 files changed, 7 insertions, 20 deletions
diff --git a/lib/nostr.ts b/lib/nostr.ts
index 354f928b..bcb20ea1 100644
--- a/lib/nostr.ts
+++ b/lib/nostr.ts
@@ -12,13 +12,9 @@ import { Relay } from "nostr-tools/relay";
export const EX = 60 * 60 * 24;
const coinos = await Relay.connect(config.nostr);
-export const serverSecret = bytesToHex(
- nip19.decode(config.nostrKey).data as Uint8Array,
-);
+export const serverSecret = bytesToHex(nip19.decode(config.nostrKey).data as Uint8Array);
-export const serverSecret2 = bytesToHex(
- nip19.decode(config.nostrKey2).data as Uint8Array,
-);
+export const serverSecret2 = bytesToHex(nip19.decode(config.nostrKey2).data as Uint8Array);
export const serverPubkey = getPublicKey(hexToBytes(serverSecret));
export const serverPubkey2 = getPublicKey(hexToBytes(serverSecret2));
@@ -54,29 +50,21 @@ export async function handleZap(invoice, sender = undefined) {
fail("No tags found");
}
- const ptags = zapreq.tags.filter(
- (t) => t?.length && t.length >= 2 && t[0] === "p",
- );
+ const ptags = zapreq.tags.filter((t) => t?.length && t.length >= 2 && t[0] === "p");
if (ptags.length !== 1) {
fail("None or multiple p tags found");
}
- const etags = zapreq.tags.filter(
- (t) => t?.length && t.length >= 2 && t[0] === "e",
- );
+ const etags = zapreq.tags.filter((t) => t?.length && t.length >= 2 && t[0] === "e");
if (!(etags.length === 0 || etags.length === 1)) {
fail("Expected none or 1 e tags");
}
- const atags = zapreq.tags.filter(
- (t) => t?.length && t.length >= 2 && t[0] === "a",
- );
+ const atags = zapreq.tags.filter((t) => t?.length && t.length >= 2 && t[0] === "a");
- const relays_tag = zapreq.tags.find(
- (t) => t?.length && t.length >= 2 && t[0] === "relays",
- );
+ const relays_tag = zapreq.tags.find((t) => t?.length && t.length >= 2 && t[0] === "relays");
if (!relays_tag) {
fail("No relays tag found");
@@ -168,8 +156,7 @@ export const getCount = async (pubkey) => {
if (follows === null) {
const result = await get({ authors: [pubkey], kinds: [3] });
follows = result ? result.tags.filter((t) => t[0] === "p").length : 0;
- if (follows?.length)
- await db.set(`${pubkey}:follows:n`, JSON.stringify(follows), { EX });
+ if (follows?.length) await db.set(`${pubkey}:follows:n`, JSON.stringify(follows), { EX });
}
const k = `${pubkey}:followers:n`;