aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-14 00:09:07 -0800
committerAdam Soltys <[email protected]>2026-02-14 00:09:07 -0800
commit843c343db567cd224dadf347ac16736bdc8b24a8 (patch)
tree6c3f819c62334265fac97b8e9e005178153bf31d /lib
parentddbe2e8afa46f3c8906b0abe0683998f85ab2e68 (diff)
downloadcoinos-server-843c343db567cd224dadf347ac16736bdc8b24a8.tar.gz
coinos-server-843c343db567cd224dadf347ac16736bdc8b24a8.zip
check for local sends
Diffstat (limited to 'lib')
-rw-r--r--lib/payments.ts16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/payments.ts b/lib/payments.ts
index d5819e30..f6a6bd23 100644
--- a/lib/payments.ts
+++ b/lib/payments.ts
@@ -545,6 +545,16 @@ const pay = async ({ aid = undefined, amount, to, user }) => {
return p;
}
+ // Check for local invoice before applying external fees
+ if (to.startsWith("ln") && !to.startsWith("lnurl") && !to.startsWith("lno")) {
+ const localInv = await getInvoice(to).catch(() => null);
+ if (localInv) {
+ const recipient = await getUser(localInv.uid);
+ if (recipient)
+ return sendInternal({ amount, invoice: localInv, recipient, sender: user });
+ }
+ }
+
let fee;
const ourfee = Math.round(amount * (config.fee.lightning || 0));
if (lnurl) {
@@ -572,9 +582,9 @@ const pay = async ({ aid = undefined, amount, to, user }) => {
pr = to;
}
- return pr
- ? await sendLightning({ user, pr, amount, fee })
- : await sendOnchain({ aid, amount, address: to, user, subtract: true });
+ if (pr) return sendLightning({ user, pr, amount, fee });
+
+ return sendOnchain({ aid, amount, address: to, user, subtract: true });
};
export const decode = async (hex) => {