|
| 1 | +import * as crypto from "node:crypto"; // required in node.js |
| 2 | +global.crypto = crypto; // required in node.js |
| 3 | +import "websocket-polyfill"; // required in node.js |
| 4 | + |
| 5 | +import * as readline from "node:readline/promises"; |
| 6 | +import { stdin as input, stdout as output } from "node:process"; |
| 7 | + |
| 8 | +import { nwc } from "../../../dist/index.module.js"; |
| 9 | + |
| 10 | +const rl = readline.createInterface({ input, output }); |
| 11 | + |
| 12 | +const nwcUrl = |
| 13 | + process.env.NWC_URL || |
| 14 | + (await rl.question("Nostr Wallet Connect URL (nostr+walletconnect://...): ")); |
| 15 | +rl.close(); |
| 16 | + |
| 17 | +const client = new nwc.NWCClient({ |
| 18 | + nostrWalletConnectUrl: nwcUrl, |
| 19 | +}); |
| 20 | + |
| 21 | +const keysends = [ |
| 22 | + { |
| 23 | + pubkey: |
| 24 | + "030a58b8653d32b99200a2334cfe913e51dc7d155aa0116c176657a4f1722677a3", |
| 25 | + amount: 1000, // millisats |
| 26 | + tlv_records: [ |
| 27 | + { |
| 28 | + type: 696969, |
| 29 | + value: "017rsl75kNnSke4mMHYE", // hello@getalby.com |
| 30 | + }, |
| 31 | + { |
| 32 | + type: 34349334, |
| 33 | + value: "first keysend message", |
| 34 | + }, |
| 35 | + ], |
| 36 | + }, |
| 37 | + { |
| 38 | + pubkey: |
| 39 | + "030a58b8653d32b99200a2334cfe913e51dc7d155aa0116c176657a4f1722677a3", |
| 40 | + amount: 1000, // millisats |
| 41 | + tlv_records: [ |
| 42 | + { |
| 43 | + type: 696969, |
| 44 | + value: "1KOZHzhLs2U7JIx3BmEY", // another Alby account |
| 45 | + }, |
| 46 | + { |
| 47 | + type: 34349334, |
| 48 | + value: "second keysend message", |
| 49 | + }, |
| 50 | + ], |
| 51 | + }, |
| 52 | +]; |
| 53 | + |
| 54 | +try { |
| 55 | + const response = await client.multiPayKeysend({ keysends }); |
| 56 | + console.info(JSON.stringify(response)); |
| 57 | +} catch (error) { |
| 58 | + console.error("multi_pay_keysend failed", error); |
| 59 | +} |
| 60 | + |
| 61 | +client.close(); |
0 commit comments