aboutsummaryrefslogtreecommitdiffstats
path: root/lib/nwc.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2025-02-05 15:20:32 -0800
committerAdam Soltys <[email protected]>2025-02-05 15:20:32 -0800
commit084b62733b99bc3caaf4ac177e678929faf3151f (patch)
treea140a843150eda91d4b7fa03e18e57758267bd04 /lib/nwc.ts
parentcf63622c234446c0a385cd792dceeb7e04ef72a0 (diff)
downloadcoinos-server-084b62733b99bc3caaf4ac177e678929faf3151f.tar.gz
coinos-server-084b62733b99bc3caaf4ac177e678929faf3151f.zip
use real lightning payments for mint payments
Diffstat (limited to 'lib/nwc.ts')
-rw-r--r--lib/nwc.ts36
1 files changed, 19 insertions, 17 deletions
diff --git a/lib/nwc.ts b/lib/nwc.ts
index 73b7decd..4055a9f4 100644
--- a/lib/nwc.ts
+++ b/lib/nwc.ts
@@ -101,26 +101,28 @@ const handle = (method, params, user, ev) =>
const invoice = await getInvoice(pr);
const recipient = await g(`user:${invoice.uid}`);
- const { id: preimage } = await sendInternal({
- amount,
- invoice,
- recipient,
- sender: user,
- });
+ if (recipient?.username !== "mint") {
+ const { id: preimage } = await sendInternal({
+ amount,
+ invoice,
+ recipient,
+ sender: user,
+ });
- if (invoice.memo?.includes("9734")) {
- const { invoices } = await ln.listinvoices({ invstring: pr });
- const inv = invoices[0];
- inv.payment_preimage = preimage;
- inv.paid_at = Math.floor(Date.now() / 1000);
- try {
- await handleZap(inv, user.pubkey);
- } catch (e) {
- console.log("zap receipt failed", e);
+ if (invoice.memo?.includes("9734")) {
+ const { invoices } = await ln.listinvoices({ invstring: pr });
+ const inv = invoices[0];
+ inv.payment_preimage = preimage;
+ inv.paid_at = Math.floor(Date.now() / 1000);
+ try {
+ await handleZap(inv, user.pubkey);
+ } catch (e) {
+ console.log("zap receipt failed", e);
+ }
}
- }
- return result({ preimage });
+ return result({ preimage });
+ }
}
await sendLightning({
amount,