From 8b6ec4f9770b5270c729105724aeb5b012221ee2 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 17 Sep 2024 01:04:58 +0000 Subject: encode pubkey --- lib/nostr.ts | 7 ++++++- lib/payments.ts | 1 - 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/nostr.ts b/lib/nostr.ts index d5bb3ed3..d9ba790c 100644 --- a/lib/nostr.ts +++ b/lib/nostr.ts @@ -7,6 +7,7 @@ import { nip04, nip19 } from "nostr-tools"; import { emit } from "$lib/sockets"; import { sendLightning } from "$lib/payments"; import ln from "$lib/ln"; +import { hex } from "@scure/base"; export const COINOS_PUBKEY = getPublicKey(nip19.decode(config.nostrKey).data); export let coinos; @@ -273,10 +274,11 @@ export async function handleZap(invoice) { let r = new Relay("ws://strfry:7777"); r.on("open", (_) => { - r.subscribe("nwc", { kinds: [23194], "#p": [COINOS_PUBKEY] }); + r.subscribe("nwc", { kinds: [23194], "#p": [hex.encode(COINOS_PUBKEY)] }); }); r.on("event", async (sub, ev) => { + try { if (sub !== "nwc") return; let { content, pubkey } = ev; let sk = nip19.decode(config.nostrKey).data as Uint8Array; @@ -326,4 +328,7 @@ r.on("event", async (sub, ev) => { r.send(["EVENT", rev]); } + } catch(e) { + console.log("problem with nwc", e) + } }); diff --git a/lib/payments.ts b/lib/payments.ts index 3f5cd152..bcb567c4 100644 --- a/lib/payments.ts +++ b/lib/payments.ts @@ -84,7 +84,6 @@ export let debit = async ({ let tip = parseInt(invoice?.tip) || null; if (tip < 0) fail("Invalid tip"); - console.log("AMT", amount); if (!amount || amount < 0) fail("Amount must be greater than zero"); let ourfee: any = [types.bitcoin, types.liquid, types.lightning].includes( -- cgit v1.2.3