diff --git a/js/payments/nwcClient.js b/js/payments/nwcClient.js index 435c317c..1df36acc 100644 --- a/js/payments/nwcClient.js +++ b/js/payments/nwcClient.js @@ -1083,7 +1083,7 @@ function sanitizeAmount(amount) { return Math.max(0, rounded); } -function buildPayInvoiceParams({ invoice, amountSats, zapRequest }) { +function buildPayInvoiceParams({ invoice, amountSats, zapRequest, lnurl }) { const params = { invoice }; const amount = sanitizeAmount(amountSats); @@ -1095,13 +1095,23 @@ function buildPayInvoiceParams({ invoice, amountSats, zapRequest }) { params.zap_request = zapRequest; } + if (typeof lnurl === "string") { + const trimmed = lnurl.trim(); + if (trimmed) { + params.lnurl = trimmed; + } + } + return params; } -export async function sendPayment(bolt11, { settings, amountSats, zapRequest, timeoutMs } = {}) { +export async function sendPayment( + bolt11, + { settings, amountSats, zapRequest, lnurl, timeoutMs } = {} +) { const context = await ensureWallet({ settings }); const invoice = sanitizeInvoice(bolt11); - const params = buildPayInvoiceParams({ invoice, amountSats, zapRequest }); + const params = buildPayInvoiceParams({ invoice, amountSats, zapRequest, lnurl }); const payload = { id: `req-${Date.now()}-${++requestCounter}`, method: "pay_invoice", diff --git a/js/payments/zapSplit.js b/js/payments/zapSplit.js index 21e7bddb..302d42ed 100644 --- a/js/payments/zapSplit.js +++ b/js/payments/zapSplit.js @@ -370,6 +370,7 @@ async function processShare({ const payment = await deps.wallet.sendPayment(invoice.invoice, { amountSats, zapRequest, + lnurl: resolved.url, }); return { diff --git a/tests/nwc-client.test.mjs b/tests/nwc-client.test.mjs index 3e7cec80..a4c5ef50 100644 --- a/tests/nwc-client.test.mjs +++ b/tests/nwc-client.test.mjs @@ -13,11 +13,13 @@ await (async () => { invoice: "bolt11-invoice", amountSats: 123, zapRequest: "zap-request-json", + lnurl: " https://pay.example/lnurlp/test ", }); assert.equal(params.invoice, "bolt11-invoice"); assert.equal(params.amount, 123_000); assert.equal(params.zap_request, "zap-request-json"); + assert.equal(params.lnurl, "https://pay.example/lnurlp/test"); })(); await (async () => {