diff options
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) { |
