aboutsummaryrefslogtreecommitdiffstats
path: root/lib/payments.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2025-03-05 13:35:31 -0800
committerAdam Soltys <[email protected]>2025-03-05 15:06:48 -0800
commitbbdae13248476e9ff49fcefc64cf8c8e97b5f679 (patch)
treecb3696e680f7417f5988375043341e495b7cad3d /lib/payments.ts
parent118386e0691a0c80a0d8c19ab40bd3abf6859b84 (diff)
downloadcoinos-server-bbdae13248476e9ff49fcefc64cf8c8e97b5f679.tar.gz
coinos-server-bbdae13248476e9ff49fcefc64cf8c8e97b5f679.zip
use getInvoice helper
Diffstat (limited to 'lib/payments.ts')
-rw-r--r--lib/payments.ts22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/payments.ts b/lib/payments.ts
index 342b9641..07004fa2 100644
--- a/lib/payments.ts
+++ b/lib/payments.ts
@@ -111,9 +111,11 @@ export const debit = async ({
let creditType = type;
if (creditType === PaymentType.bolt12) creditType = PaymentType.lightning;
- let ourfee: any = [PaymentType.bitcoin, PaymentType.liquid, PaymentType.lightning].includes(
- type,
- )
+ let ourfee: any = [
+ PaymentType.bitcoin,
+ PaymentType.liquid,
+ PaymentType.lightning,
+ ].includes(type)
? Math.round((amount + fee + tip) * config.fee)
: 0;
@@ -161,7 +163,8 @@ export const debit = async ({
l(user.username, "sent", type, amount);
//emit(user.id, "payment", p);
- if (![PaymentType.lightning, PaymentType.bolt12].includes(type)) nwcNotify(p, user);
+ if (![PaymentType.lightning, PaymentType.bolt12].includes(type))
+ nwcNotify(p, user);
return p;
};
@@ -237,7 +240,8 @@ export const credit = async ({
items: undefined,
};
- if ([PaymentType.bitcoin, PaymentType.liquid].includes(type)) inv.pending += amount;
+ if ([PaymentType.bitcoin, PaymentType.liquid].includes(type))
+ inv.pending += amount;
else {
inv.received += amount;
inv.preimage = ref;
@@ -258,7 +262,11 @@ export const credit = async ({
let creditType = type;
if (creditType === PaymentType.bolt12) creditType = PaymentType.lightning;
- if ([PaymentType.bitcoin, PaymentType.liquid, PaymentType.lightning].includes(creditType))
+ if (
+ [PaymentType.bitcoin, PaymentType.liquid, PaymentType.lightning].includes(
+ creditType,
+ )
+ )
m.incrBy(`credit:${creditType}:${uid}`, Math.round(amount * config.fee));
m.set(`invoice:${inv.id}`, JSON.stringify(inv))
@@ -430,7 +438,7 @@ export const sendOnchain = async (params) => {
value,
} of tx.vout) {
total += sats(value);
- const invoice = await g(`invoice:${address}`);
+ const invoice = await getInvoice(address);
if (invoice?.aid === aid) fail("Cannot send to internal address");
if ((await node.getAddressInfo(address)).ismine) {