-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathboostagram.js
65 lines (57 loc) · 2.04 KB
/
boostagram.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
import { auth, Client } from "../dist/index.module.js";
const rl = readline.createInterface({ input, output });
const authClient = new auth.OAuth2User({
client_id: process.env.CLIENT_ID,
client_secret: process.env.CLIENT_SECRET,
callback: "http://localhost:8080/callback",
scopes: [
"invoices:read",
"account:read",
"balance:read",
"invoices:create",
"invoices:read",
"payments:send",
],
token: {
access_token: undefined,
refresh_token: undefined,
expires_at: undefined,
}, // initialize with existing token
});
console.log(`Open the following URL and authenticate the app:`);
console.log(await authClient.generateAuthURL());
console.log("----\n");
const code = await rl.question("Code: (localhost:8080?code=[THIS CODE]: ");
rl.close();
await authClient.requestAccessToken(code);
console.log(authClient.token);
const client = new Client(authClient);
// use an array if you want to send multiple boostagrams with one call
const response = await client.sendBoostagram([
{
recipient: {
address:
"030a58b8653d32b99200a2334cfe913e51dc7d155aa0116c176657a4f1722677a3",
customKey: "696969",
customValue: "bNVHj0WZ0aLPPAesnn9M",
},
amount: 10,
// spec: https://github.com/lightning/blips/blob/master/blip-0010.md
boostagram: {
app_name: "Alby SDK Demo",
value_msat_total: 49960, // TOTAL Number of millisats for the payment (all splits together, before fees. The actual number someone entered in their player, for numerology purposes.)
value_msat: 2121, // Number of millisats for this split payment
url: "https://feeds.buzzsprout.com/xxx.rss",
podcast: "Podcast title",
action: "boost",
episode: "The episode title",
episode_guid: "Buzzsprout-xxx",
ts: 574,
name: "Podcaster - the recipient name",
sender_name: "Satoshi - the sender/listener name",
},
},
]);
console.log(JSON.stringify(response));