-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathmake-invoice.ts
More file actions
33 lines (23 loc) · 863 Bytes
/
make-invoice.ts
File metadata and controls
33 lines (23 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import "websocket-polyfill"; // required in node.js
import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
import { NWCClient } from "@getalby/sdk/nwc";
const rl = readline.createInterface({ input, output });
const nwcUrl =
process.env.NWC_URL ||
(await rl.question("Nostr Wallet Connect URL (nostr+walletconnect://...): "));
const amount =
parseInt((await rl.question("Amount in sats (default 1 sat): ")) || "1") *
1000;
rl.close();
const client = new NWCClient({
nostrWalletConnectUrl: nwcUrl,
});
const response = await client.makeInvoice({
amount, // in millisats
description: "NWC Client example",
// or set a 256-bit description hash:
//description_hash: "a40f2b27a4414044995b26b73eb5aa66688b5f18d6a8a2513827d9a116ad95f1",
});
console.info(response);
client.close();