1// Asks a relay for a fuel invoice from a signed zap request, to check the2// lightning provider end to end. Usage: npm run dev:zaptest [wss://relay] [direct]3// With `direct`, the provider's LNURL callback is called straight, skipping the relay.4import { finalizeEvent } from "nostr-tools/pure";5const sk = new Uint8Array(32).fill(7);6const relay = process.argv[2] || "wss://demo.bind.ws";7const zr = finalizeEvent({ kind: 9734, created_at: Math.floor(Date.now()/1000), content: "fuel test",8 tags: [["p","6b559c0816c3b9ec03c2f0cedb8a56efe83746f8c56e543e36e1973c04ef0384"],["amount","21000"],["relays",relay]] }, sk);9if (process.argv[3] === "direct") {10 const u = new URL("https://getalby.com/lnurlp/bindws/callback");11 u.searchParams.set("amount","21000"); u.searchParams.set("nostr", JSON.stringify(zr));12 const r = await fetch(u); console.log(r.status, (await r.text()).slice(0,300));13} else {14 const r = await fetch(relay.replace("wss://","https://") + "/fuel/invoice", { method:"POST", headers:{"content-type":"application/json"}, body: JSON.stringify({ zapRequest: zr }) });15 console.log(r.status, (await r.text()).slice(0,300));16}