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 /lib/payments.ts | |
| parent | 19d0997d10d4ed9054cf63328ea148c9367ef40e (diff) | |
| download | coinos-server-d18ad032bc2e97bbf0aa2903dca0734dc32e2093.tar.gz coinos-server-d18ad032bc2e97bbf0aa2903dca0734dc32e2093.zip | |
per-type fees
Diffstat (limited to 'lib/payments.ts')
| -rw-r--r-- | lib/payments.ts | 11 |
1 files changed, 7 insertions, 4 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); |
