aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-09-17 01:04:58 +0000
committerAdam Soltys <[email protected]>2024-09-17 01:04:58 +0000
commit8b6ec4f9770b5270c729105724aeb5b012221ee2 (patch)
tree249b7a81d257da54fbe36a7d6fd2e985bbe950d5
parent64ab0990f390bf64335e76ee89f3c96852be6d81 (diff)
downloadcoinos-server-8b6ec4f9770b5270c729105724aeb5b012221ee2.tar.gz
coinos-server-8b6ec4f9770b5270c729105724aeb5b012221ee2.zip
encode pubkey
-rw-r--r--lib/nostr.ts7
-rw-r--r--lib/payments.ts1
2 files changed, 6 insertions, 2 deletions
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(