aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-10-01 08:53:30 -0700
committerAdam Soltys <[email protected]>2024-10-01 09:24:46 -0700
commit8097f7e6e23c393a6df7c8e62ab036af31eea554 (patch)
treef97fd397b5f6d7b09c1728208699ea795d701c04 /lib
parent1bba25c3952a5160d1a2ec977e18dff05baad442 (diff)
downloadcoinos-server-8097f7e6e23c393a6df7c8e62ab036af31eea554.tar.gz
coinos-server-8097f7e6e23c393a6df7c8e62ab036af31eea554.zip
handle zaps on nwc payments
Diffstat (limited to 'lib')
-rw-r--r--lib/nwc.ts12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/nwc.ts b/lib/nwc.ts
index 973d7263..e889dfdf 100644
--- a/lib/nwc.ts
+++ b/lib/nwc.ts
@@ -4,7 +4,7 @@ import { g } from "$lib/db";
import { Relay } from "nostr";
import { getInvoice, sleep } from "$lib/utils";
import { sendInternal, sendLightning } from "$lib/payments";
-import { serverPubkey } from "$lib/nostr";
+import { handleZap, serverPubkey } from "$lib/nostr";
import { nip04, nip19, finalizeEvent } from "nostr-tools";
import type { UnsignedEvent } from "nostr-tools";
import { generate } from "$lib/invoices";
@@ -13,7 +13,7 @@ import ln from "$lib/ln";
let result = (result) => ({ result });
let error = (error) => ({ error });
-let methods= ["pay_invoice", "get_balance", "get_info", "make_invoice"];
+let methods = ["pay_invoice", "get_balance", "get_info", "make_invoice"];
export default () => {
let r = new Relay("ws://strfry:7777");
@@ -71,6 +71,12 @@ let handle = (method, params, user) =>
let invoice = await getInvoice(pr);
let recipient = await g(`user:${invoice.uid}`);
+ if (invoice.memo.includes("9734")) {
+ try {
+ await handleZap(invoice);
+ } catch (e) {}
+ }
+
let { id: preimage } = await sendInternal({
amount,
invoice,
@@ -109,7 +115,7 @@ let handle = (method, params, user) =>
pubkey: serverPubkey,
network: "mainnet",
block_height: blockheight,
- methods
+ methods,
});
},