-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathexample.js
25 lines (19 loc) · 964 Bytes
/
example.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
'use strict';
const LightningClient = require('lightning-client');
// const LightningClient = require('./index');
// This should point to your lightning-dir, by default in ~/.lightning.
// The debug mode is enabled (second parameter) but this decreases performances (see PR #10)
const client = new LightningClient('/home/bitcoind/.lightning', true);
// Every call returns a Promise
// "Show information about this node"
client.getinfo()
.then(info => console.log(info))
.catch(err => console.log(err));
// "Create an invoice for {msatoshi} with {label} and {description} with optional {expiry} seconds (default 1 hour)" }
client.invoice(100, 'my-label-4', 'my-description-4', 3600)
.then(result => console.log(result))
.catch(err => console.log(err));
// "Show addresses list up to derivation {index} (default is the last bip32 index)"
client.devListaddrs ()
.then(listaddrs => console.log(JSON.stringify (listaddrs)))
.catch(err => console.log(err));