diff options
| author | Adam Soltys <[email protected]> | 2023-01-13 23:50:30 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-01-13 23:50:30 -0800 |
| commit | 6bafea9bffe24d2227d269812a73a9a513d92ddf (patch) | |
| tree | 6dd463ffa410f4b7eebc870b24db305785414aa0 /routes/lightning | |
| parent | 8a114c50efaac41767042766f05390aa906da157 (diff) | |
| download | coinos-server-6bafea9bffe24d2227d269812a73a9a513d92ddf.tar.gz coinos-server-6bafea9bffe24d2227d269812a73a9a513d92ddf.zip | |
internal payments
Diffstat (limited to 'routes/lightning')
| -rw-r--r-- | routes/lightning/receive.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/routes/lightning/receive.js b/routes/lightning/receive.js index a37dc716..ffb0ad95 100644 --- a/routes/lightning/receive.js +++ b/routes/lightning/receive.js @@ -1,3 +1,4 @@ +import { v4 } from "uuid"; import store from "$lib/store"; import { emit } from "$lib/sockets"; import config from "$config"; @@ -35,7 +36,9 @@ let handle = async () => { let amount = parseInt(received) - tip; if (amount < 0) throw new Error("amount out of range"); + let id = v4(); let payment = { + id, user_id, hash, memo, @@ -44,7 +47,8 @@ let handle = async () => { secret, rate, tip, - invoice_id: invoice.id + invoice_id: invoice.id, + created_at: Date.now() }; total = amount + tip; @@ -64,6 +68,10 @@ let handle = async () => { await t(); payment.invoice = invoice; + + await s(`payment:${id}`, payment); + await rd.lPush(`${user.id}:payments`, id); + callWebhook(invoice, payment); emit(user.username, "payment", payment); |
