forked from jb55/lnurl-commando
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlnurl-commando
executable file
·52 lines (43 loc) · 1.78 KB
/
lnurl-commando
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
#!/usr/bin/env node
require('dotenv').config();
const create_server = require('./');
const DEFAULT_PORT = 8083;
async function main() {
// Legacy args support
const opts = require('minimist')(process.argv.slice(2));
// Overwrite null args with .env versions
opts.nodeid = opts.nodeid || process.env.CLN_NODEID;
opts.host = opts.host || process.env.CLN_HOST;
opts.rune = opts.rune || process.env.CLN_RUNE;
opts.description = opts.description || process.env.LNURL_DESCRIPTION;
opts.callback = opts.callback || process.env.CALLBACK;
opts.longDescription = opts.longDescription || process.env.LNURL_LONGDESCRIPTION;
opts.thumbnail = opts.thumbnail || process.env.LOCAL_THUMBNAIL;
opts.identifier = opts.identifier || process.env.IDENTIFIER;
opts.npub = opts.npub || process.env.NOSTR_PUBKEY;
// Check for mvp settings
if (!opts.nodeid || !opts.host || !opts.rune || !opts.callback || !opts.description)
return usage()
// Create the server
const server = await create_server(opts);
const port = +process.env.PORT || DEFAULT_PORT;
console.log(`lnurl-commando listening on port ${port}`);
server.listen(port);
}
if (!module.parent) {
main();
}
function usage() {
console.log(`
usage: lnurl-commando --nodeid <nodeid>
--host <commando-host>
--rune <rune>
--callback <lnurl-callback>
--description <invoice-description>
--longDescription <invoice-long-description>
--thumbnail <png|jpg path>
--identifier <email, vendor, etc>
--npub <nostr bip340 pubkey>
`);
process.exit(1);
}