diff options
| author | Adam Soltys <[email protected]> | 2025-02-11 20:07:21 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-02-11 20:07:21 -0800 |
| commit | eb3c2aad4cef9b86294bc9a13a36da4918529209 (patch) | |
| tree | 33c58529ee50bf875620a5a33d97e8ab57b673ae /lib/nwc.ts | |
| parent | 004ac3ccbfb6a12227a81d6e0dc0beaf9a740827 (diff) | |
| download | coinos-server-eb3c2aad4cef9b86294bc9a13a36da4918529209.tar.gz coinos-server-eb3c2aad4cef9b86294bc9a13a36da4918529209.zip | |
nwc notifications
Diffstat (limited to 'lib/nwc.ts')
| -rw-r--r-- | lib/nwc.ts | 26 |
1 files changed, 15 insertions, 11 deletions
@@ -22,6 +22,7 @@ const methods = [ "make_invoice", "lookup_invoice", "list_transactions", + "notifications", ]; const week = 7 * 24 * 60 * 60; @@ -31,14 +32,19 @@ export default () => { r.on("open", async (_) => { r.subscribe("nwc", { kinds: [23194], "#p": [serverPubkey] }); - let info: UnsignedEvent = { - created_at: Math.floor(Date.now() / 1000), - kind: 13194, - tags: [["p", serverPubkey]], - pubkey: serverPubkey, - content: methods.join(" "), - }; - info = await finalizeEvent(info, sk); + const info = await finalizeEvent( + { + created_at: Math.floor(Date.now() / 1000), + kind: 13194, + tags: [ + ["p", serverPubkey], + ["notifications", "payment_received payment_sent"], + ], + pubkey: serverPubkey, + content: methods.join(" "), + }, + sk, + ); r.send(["EVENT", info]); }); @@ -314,9 +320,7 @@ const handle = (method, params, ev, app, user) => async list_transactions() { const { from, until, limit = 10, offset = 0, type } = params; - const { pubkey } = app; - const k = pubkey === user.pubkey ? user.id : pubkey; - const payments = await db.lRange(`${k}:payments`, 0, -1); + const payments = await db.lRange(`${user.id}:payments`, 0, -1); let transactions = []; for (const pid of payments) { |
