Fix missing validation for NWC receive (#2365)
This commit is contained in:
parent
6aeffa7aff
commit
d175d0e64d
@ -1,4 +1,4 @@
|
|||||||
import { nwcTryRun } from '@/wallets/lib/protocols/nwc'
|
import { nwcTryRun, supportedMethods } from '@/wallets/lib/protocols/nwc'
|
||||||
|
|
||||||
export const name = 'NWC'
|
export const name = 'NWC'
|
||||||
|
|
||||||
@ -12,6 +12,20 @@ export async function createInvoice ({ msats, description, expiry }, { url }, {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function testCreateInvoice ({ url }, { signal }) {
|
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(
|
return await createInvoice(
|
||||||
{ msats: 1000, description: 'SN test invoice', expiry: 1 },
|
{ msats: 1000, description: 'SN test invoice', expiry: 1 },
|
||||||
{ url },
|
{ url },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user