Add lightning invoice payments

This commit is contained in:
Jon Staab
2025-11-12 16:20:38 -08:00
parent c05d7e99e2
commit 9cae4da9f4
11 changed files with 198 additions and 12 deletions
+5 -2
View File
@@ -592,7 +592,7 @@ export const publishLeaveRequest = (params: LeaveRequestParams) =>
export const getWebLn = () => (window as any).webln
export const payInvoice = async (invoice: string) => {
export const payInvoice = async (invoice: string, msats?: number) => {
const $session = session.get()
if (!$session?.wallet) {
@@ -600,8 +600,11 @@ export const payInvoice = async (invoice: string) => {
}
if ($session.wallet.type === "nwc") {
return new nwc.NWCClient($session.wallet.info).payInvoice({invoice})
const params: {invoice: string; amount?: number} = {invoice}
if (msats) params.amount = msats
return new nwc.NWCClient($session.wallet.info).payInvoice(params)
} else if ($session.wallet.type === "webln") {
if (msats) throw new Error("Unable to pay zero invoices with webln")
return getWebLn()
.enable()
.then(() => getWebLn().sendPayment(invoice))
+2 -2
View File
@@ -1,6 +1,6 @@
import {reject, call, identity} from "@welshman/lib"
import {call} from "@welshman/lib"
import {Preferences} from "@capacitor/preferences"
import {Encoding, Filesystem, Directory} from "@capacitor/filesystem"
import {Filesystem, Directory} from "@capacitor/filesystem"
import {IDB} from "@lib/indexeddb"
export const kv = call(() => {