aboutsummaryrefslogtreecommitdiffstats
path: root/lib/nostr.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-09-17 06:50:06 +0000
committerAdam Soltys <[email protected]>2024-09-17 06:50:06 +0000
commit3a493d30daa964b8dcb0bf1c74df995d8dc9fa32 (patch)
tree1431eb8a8ee85791a189fe578b87a1b0fb0073a0 /lib/nostr.ts
parentf1cd8904fb7231d43f16b7bc27f45b8b31a03fde (diff)
downloadcoinos-server-3a493d30daa964b8dcb0bf1c74df995d8dc9fa32.tar.gz
coinos-server-3a493d30daa964b8dcb0bf1c74df995d8dc9fa32.zip
pass invoice for internal
Diffstat (limited to 'lib/nostr.ts')
-rw-r--r--lib/nostr.ts16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/nostr.ts b/lib/nostr.ts
index 35a864d0..bb47696b 100644
--- a/lib/nostr.ts
+++ b/lib/nostr.ts
@@ -1,8 +1,8 @@
import config from "$config";
-import { l } from "$lib/logging";
+import { l, err } from "$lib/logging";
import { Relay, RelayPool, calculateId, signId, getPublicKey } from "nostr";
import { g, s, db } from "$lib/db";
-import { fail, sleep, wait } from "$lib/utils";
+import { fail, getInvoice, sleep, wait } from "$lib/utils";
import { nip04, nip19, finalizeEvent } from "nostr-tools";
import type { UnsignedEvent } from "nostr-tools";
import { emit } from "$lib/sockets";
@@ -297,14 +297,16 @@ r.on("event", async (sub, ev) => {
if (method === "pay_invoice") {
let { invoice: pr } = params;
let { amount_msat, payee } = await ln.decode(pr);
- let { id } = await ln.getInfo();
+ let { id } = await ln.getinfo();
let amount = Math.round(amount_msat / 1000);
if (payee === id) {
- let inv = await g(pr);
- let recipient = await g(`user:${inv.uid}`);
+ let invoice = await getInvoice(pr);
+ let recipient = await g(`user:${invoice.uid}`);
+
await sendInternal({
amount,
+ invoice,
recipient,
sender: user,
});
@@ -333,7 +335,7 @@ r.on("event", async (sub, ev) => {
ret.error = { code: "INTERNAL", message: "Payment timed out" };
}
} else if (method === "get_info") {
- let { alias, blockheight, color } = await ln.getInfo();
+ let { alias, blockheight, color } = await ln.getinfo();
ret.result = {
alias,
color,
@@ -364,6 +366,6 @@ r.on("event", async (sub, ev) => {
response = await finalizeEvent(response, sk);
r.send(["EVENT", response]);
} catch (e) {
- console.log("problem with nwc", e);
+ err("problem with nwc", e.message);
}
});