diff options
| author | Adam Soltys <[email protected]> | 2024-10-31 09:03:23 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-10-31 09:03:23 -0700 |
| commit | 2ff6a289f142636beee1846132049cae7cfd82ea (patch) | |
| tree | a23313129b1aa54c8e7925471fc3e9f873192a86 /routes | |
| parent | b3203b848a25b5aadebfe8fff3e0f01dda1919fa (diff) | |
| download | coinos-server-2ff6a289f142636beee1846132049cae7cfd82ea.tar.gz coinos-server-2ff6a289f142636beee1846132049cae7cfd82ea.zip | |
detect internal payments
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/payments.ts | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/routes/payments.ts b/routes/payments.ts index 4573ac4f..618e9195 100644 --- a/routes/payments.ts +++ b/routes/payments.ts @@ -55,7 +55,15 @@ export default { let p; if (payreq) { - p = await sendLightning({ user, pr: payreq, amount, maxfee, memo }); + const iid = await g(`invoice:${payreq}`); + if (iid) { + const invoice = await g(`invoice:${iid}`); + if (invoice.aid === user.id) fail("Cannot send to self"); + hash = payreq; + if (!amount) ({ amount } = invoice); + } else { + p = await sendLightning({ user, pr: payreq, amount, maxfee, memo }); + } } if (!p) { |
