From 843c343db567cd224dadf347ac16736bdc8b24a8 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 14 Feb 2026 00:09:07 -0800 Subject: check for local sends --- lib/payments.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'lib') 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) => { -- cgit v1.2.3