diff options
| author | Adam Soltys <[email protected]> | 2025-01-17 11:28:30 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-01-17 11:28:30 -0800 |
| commit | 06308bb12edff8e51b189b57d9f5a147959d743a (patch) | |
| tree | 2dad64b95eb0976f581783a2a83a5c5d0be69134 /lib/payments.ts | |
| parent | 2e28b65fc3d790d9fece0f3aa22f35b2012d9739 (diff) | |
| download | coinos-server-06308bb12edff8e51b189b57d9f5a147959d743a.tar.gz coinos-server-06308bb12edff8e51b189b57d9f5a147959d743a.zip | |
send zaps for internal payments
Diffstat (limited to 'lib/payments.ts')
| -rw-r--r-- | lib/payments.ts | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/payments.ts b/lib/payments.ts index d88dc6aa..5f818ae4 100644 --- a/lib/payments.ts +++ b/lib/payments.ts @@ -4,6 +4,7 @@ import { db, g, s } from "$lib/db"; import { generate } from "$lib/invoices"; import ln from "$lib/ln"; import { err, l, warn } from "$lib/logging"; +import { handleZap } from "$lib/nostr"; import { notify } from "$lib/notifications"; import { SATS, @@ -547,6 +548,7 @@ export const sendLightning = async ({ export const sendInternal = async ({ amount, invoice = undefined, + memo = undefined, recipient, sender, }) => { @@ -557,10 +559,17 @@ export const sendInternal = async ({ }); const { hash } = invoice; - let memo; - const p = await debit({ hash, amount, memo, user: sender }); await credit({ hash, amount, memo, ref: sender.id }); + + if (invoice.memo?.includes("9734")) { + const { invoices } = await ln.listinvoices({ invstring: hash }); + const inv = invoices[0]; + inv.payment_preimage = p.id; + inv.paid_at = Math.floor(Date.now() / 1000); + handleZap(inv).catch(console.log); + } + return p; }; |
