diff options
| author | Adam Soltys <[email protected]> | 2023-02-01 11:07:37 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-02-01 11:07:37 -0800 |
| commit | 1ae65a5a143d218e21828e297fd7d0ba9ab372bf (patch) | |
| tree | 6e425803038c575f87e14ae3392abae16d7ccf40 /routes/payments.js | |
| parent | 2eb199b8609b0976b4800815edcf73aa3da4b464 (diff) | |
| download | coinos-server-1ae65a5a143d218e21828e297fd7d0ba9ab372bf.tar.gz coinos-server-1ae65a5a143d218e21828e297fd7d0ba9ab372bf.zip | |
classic invoices
Diffstat (limited to 'routes/payments.js')
| -rw-r--r-- | routes/payments.js | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/routes/payments.js b/routes/payments.js index 26708a44..c67e0f9b 100644 --- a/routes/payments.js +++ b/routes/payments.js @@ -7,13 +7,14 @@ import { l, err } from "$lib/logging"; import { fail, btc, sats } from "$lib/utils"; import { requirePin } from "$lib/auth"; import { debit, credit, confirm, types } from "$lib/payments"; +import got from "got"; import bc from "$lib/bitcoin"; import ln from "$lib/ln"; export default { async create({ body, user }, res) { - let { amount, hash, maxfee, name, memo, payreq, tip } = body; + let { amount, hash, maxfee, name, memo, payreq, tip, username } = body; amount = parseInt(amount); maxfee = parseInt(maxfee); @@ -23,7 +24,18 @@ export default { let p; - if (payreq) { + if (username.endsWith("@classic")) { + let { username: source } = user; + username = username.replace("@classic", ""); + p = await debit(hash, amount, 0, memo, user, types.classic); + + await got + .post(`${config.classic}/admin/credit`, { + json: { username, amount, source }, + headers: { authorization: `Bearer ${config.admin}` } + }) + .json(); + } else if (payreq) { p = await debit( hash, amount + maxfee, |
