Skip to content

Commit d175d0e

Browse files
authored
Fix missing validation for NWC receive (#2365)
1 parent 6aeffa7 commit d175d0e

File tree

1 file changed

+15
-1
lines changed
  • wallets/server/protocols

1 file changed

+15
-1
lines changed

wallets/server/protocols/nwc.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { nwcTryRun } from '@/wallets/lib/protocols/nwc'
1+
import { nwcTryRun, supportedMethods } from '@/wallets/lib/protocols/nwc'
22

33
export const name = 'NWC'
44

@@ -12,6 +12,20 @@ export async function createInvoice ({ msats, description, expiry }, { url }, {
1212
}
1313

1414
export async function testCreateInvoice ({ url }, { signal }) {
15+
const supported = await supportedMethods(url, { signal })
16+
const supports = (method) => supported.includes(method)
17+
18+
if (!supports('make_invoice')) {
19+
throw new Error('make_invoice not supported')
20+
}
21+
22+
const mustNotSupport = ['pay_invoice', 'multi_pay_invoice', 'pay_keysend', 'multi_pay_keysend']
23+
for (const method of mustNotSupport) {
24+
if (supports(method)) {
25+
throw new Error(`${method} must not be supported`)
26+
}
27+
}
28+
1529
return await createInvoice(
1630
{ msats: 1000, description: 'SN test invoice', expiry: 1 },
1731
{ url },

0 commit comments

Comments
 (0)