diff options
| author | Adam Soltys <[email protected]> | 2025-04-16 20:53:47 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-04-16 21:28:51 -0700 |
| commit | d18ad032bc2e97bbf0aa2903dca0734dc32e2093 (patch) | |
| tree | dc23e74c264c7643eb160a59d2c7480d861a2407 | |
| parent | 19d0997d10d4ed9054cf63328ea148c9367ef40e (diff) | |
| download | coinos-server-d18ad032bc2e97bbf0aa2903dca0734dc32e2093.tar.gz coinos-server-d18ad032bc2e97bbf0aa2903dca0734dc32e2093.zip | |
per-type fees
| -rw-r--r-- | lib/payments.ts | 11 | ||||
| -rw-r--r-- | routes/payments.ts | 5 |
2 files changed, 8 insertions, 8 deletions
diff --git a/lib/payments.ts b/lib/payments.ts index 24eed057..2a2176e6 100644 --- a/lib/payments.ts +++ b/lib/payments.ts @@ -116,7 +116,7 @@ export const debit = async ({ PaymentType.liquid, PaymentType.lightning, ].includes(type) - ? Math.round((amount + fee + tip) * config.fee) + ? Math.round((amount + fee + tip) * config.fee[creditType]) : 0; if (aid) ourfee = 0; @@ -267,7 +267,10 @@ export const credit = async ({ creditType, ) ) - m.incrBy(`credit:${creditType}:${uid}`, Math.round(amount * config.fee)); + m.incrBy( + `credit:${creditType}:${uid}`, + Math.round(amount * config.fee[creditType]), + ); m.set(`invoice:${inv.id}`, JSON.stringify(inv)) .set(`payment:${p.id}`, JSON.stringify(p)) @@ -688,7 +691,7 @@ export const build = async ({ } const balance = await g(`balance:${aid}`); - let ourfee = Math.round(amount * config.fee); + let ourfee = Math.round(amount * config.fee[type]); const credit = await g(`credit:${type}:${aid}`); const covered = Math.min(credit, ourfee); ourfee -= covered; @@ -879,7 +882,7 @@ const reverse = async (p) => { const total = Math.abs(p.amount) + p.fee + p.ourfee; const ourfee = p.ourfee || 0; - const credit = Math.round(total * config.fee) - ourfee; + const credit = Math.round(total * config.fee[PaymentType.lightning]) - ourfee; l("reversing", p.id, p.amount, p.fee, total, ourfee, credit); diff --git a/routes/payments.ts b/routes/payments.ts index dd41b730..71f29da4 100644 --- a/routes/payments.ts +++ b/routes/payments.ts @@ -28,11 +28,8 @@ import { import rpc from "@coinos/rpc"; import got from "got"; import { v4 } from "uuid"; - import { PaymentType } from "$lib/types"; - import ln from "$lib/ln"; -const { URL } = process.env; export default { async info(_, res) { @@ -212,7 +209,7 @@ export default { const alias = node ? node.alias : payee.substr(0, 12); const amount = Math.round(amount_msat / 1000); - let ourfee = Math.round(amount * config.fee); + let ourfee = Math.round(amount * config.fee[PaymentType.lightning]); const credit = await g(`credit:lightning:${user.id}`); const covered = Math.min(credit, ourfee) || 0; ourfee -= covered; |
