* ndk * fix: remove duplicated zap note event template * don't init Nip07 signer by default * Update wallets/nwc/server.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * nwc protocol parsing workaround * WebSocket polyfill for worker * increase nwc timeout * remove NDKNip46Signer type * fix type annotation * move eslint-disable camelcase to the top * pass event args to the constructor * fix error handling * Update wallets/nwc/index.js Co-authored-by: ekzyis <ek@stacker.news> * Fix type annotation --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: ekzyis <ek@stacker.news> Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
18 lines
556 B
JavaScript
18 lines
556 B
JavaScript
import { getNwc, supportedMethods, nwcTryRun } from '@/wallets/nwc'
|
|
export * from '@/wallets/nwc'
|
|
|
|
export async function testSendPayment ({ nwcUrl }, { logger }) {
|
|
const timeout = 15_000
|
|
|
|
const supported = await supportedMethods(nwcUrl, { logger, timeout })
|
|
if (!supported.includes('pay_invoice')) {
|
|
throw new Error('pay_invoice not supported')
|
|
}
|
|
}
|
|
|
|
export async function sendPayment (bolt11, { nwcUrl }, { logger }) {
|
|
const nwc = await getNwc(nwcUrl)
|
|
const result = await nwcTryRun(() => nwc.payInvoice(bolt11))
|
|
return result.preimage
|
|
}
|