diff options
| author | Adam Soltys <[email protected]> | 2024-08-16 14:27:56 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-08-16 14:27:56 -0700 |
| commit | f8cfd7e189c62c6325a126df1dda3b24cb1bbc36 (patch) | |
| tree | 08d12f40589b3675ddb0453d586b83a79ac68691 /lib/payments.js | |
| parent | e17a531ce983a3e2fcc233a606b9b3678e22266a (diff) | |
| download | coinos-server-f8cfd7e189c62c6325a126df1dda3b24cb1bbc36.tar.gz coinos-server-f8cfd7e189c62c6325a126df1dda3b24cb1bbc36.zip | |
transfer ecash
Diffstat (limited to 'lib/payments.js')
| -rw-r--r-- | lib/payments.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/payments.js b/lib/payments.js index d3250778..c7fd41b0 100644 --- a/lib/payments.js +++ b/lib/payments.js @@ -12,6 +12,7 @@ import { fail, fiat, getInvoice, + getUser, sleep, wait, SATS, @@ -27,9 +28,15 @@ import api from "$lib/api"; import lq from "$lib/liquid"; import bc from "$lib/bitcoin"; import ln from "$lib/ln"; +import { balance, melt, mint } from "$lib/ecash"; let { URL } = process.env; +setTimeout( + async () => console.log("bob", await balance(await getUser("bob"))), + 1000, +); + export let types = { internal: "internal", bitcoin: "bitcoin", @@ -83,6 +90,7 @@ export let debit = async ({ ? Math.round((amount + fee + tip) * config.fee) : 0; + await melt(user, amount + fee + tip + ourfee); ourfee = await db.debit( `balance:${uid}`, `credit:${type}:${uid}`, @@ -180,6 +188,8 @@ export let credit = async (hash, amount, memo, ref, type = types.internal) => { inv.preimage = ref; } + await mint(user, amount); + let balanceKey = "balance"; if ([types.bitcoin, types.liquid].includes(type)) { let [txid, vout] = ref.split(":").slice(-2); |
