diff options
| author | Adam Soltys <[email protected]> | 2024-09-16 23:16:58 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-09-16 23:16:58 -0700 |
| commit | f1cd8904fb7231d43f16b7bc27f45b8b31a03fde (patch) | |
| tree | 5243a0c70dc65e1d36957b41feaa41e6f4352f27 /lib/payments.ts | |
| parent | 50cd51473f8cecc8b6893d9dff3142ca13b249e5 (diff) | |
| download | coinos-server-f1cd8904fb7231d43f16b7bc27f45b8b31a03fde.tar.gz coinos-server-f1cd8904fb7231d43f16b7bc27f45b8b31a03fde.zip | |
internal payments
Diffstat (limited to 'lib/payments.ts')
| -rw-r--r-- | lib/payments.ts | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/payments.ts b/lib/payments.ts index 075cfab8..8f197044 100644 --- a/lib/payments.ts +++ b/lib/payments.ts @@ -1,5 +1,6 @@ import locales from "$lib/locales/index"; import config from "$config"; +import { generate } from "$lib/invoices"; import { emit } from "$lib/sockets"; import { v4 } from "uuid"; import { notify } from "$lib/notifications"; @@ -11,6 +12,7 @@ import { fail, fiat, getInvoice, + getUser, sleep, SATS, sats, @@ -603,6 +605,21 @@ export let sendLightning = async ({ } }; +export let sendInternal = async ({ amount, recipient, sender }) => { + let inv = await generate({ + invoice: { amount, type: "lightning" }, + user: recipient, + sender, + }); + + let { hash } = inv; + let memo; + + let p = await debit({ hash, amount, memo, user: sender }); + await credit({ hash, amount, memo, ref: recipient.id }); + return p; +}; + let getAddressType = async (a) => { try { await bc.getAddressInfo(a); @@ -627,7 +644,7 @@ export let build = async ({ }) => { let type = await getAddressType(address); if (!account) account = user.id; - let node = + let node = account === user.id ? rpc(config[type]) : rpc({ ...config[type], wallet: account }); |
