From d175d0e64dcde3283a2f49254a11f37dff9a48a4 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Wed, 30 Jul 2025 18:37:25 +0200 Subject: [PATCH] Fix missing validation for NWC receive (#2365) --- wallets/server/protocols/nwc.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/wallets/server/protocols/nwc.js b/wallets/server/protocols/nwc.js index d1f9fcfe..a5230024 100644 --- a/wallets/server/protocols/nwc.js +++ b/wallets/server/protocols/nwc.js @@ -1,4 +1,4 @@ -import { nwcTryRun } from '@/wallets/lib/protocols/nwc' +import { nwcTryRun, supportedMethods } from '@/wallets/lib/protocols/nwc' export const name = 'NWC' @@ -12,6 +12,20 @@ export async function createInvoice ({ msats, description, expiry }, { url }, { } export async function testCreateInvoice ({ url }, { signal }) { + const supported = await supportedMethods(url, { signal }) + const supports = (method) => supported.includes(method) + + if (!supports('make_invoice')) { + throw new Error('make_invoice not supported') + } + + const mustNotSupport = ['pay_invoice', 'multi_pay_invoice', 'pay_keysend', 'multi_pay_keysend'] + for (const method of mustNotSupport) { + if (supports(method)) { + throw new Error(`${method} must not be supported`) + } + } + return await createInvoice( { msats: 1000, description: 'SN test invoice', expiry: 1 }, { url },