aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ln.js
blob: 91a704e9a7d1b04a1e30a2ed16344b8d977f430b (plain) (blame)
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
import config from "../config/index.js";
let ln;

if (config.lna.clightning) {
  ln = (await import("clightning-client"))(config.lna.dir);
} else {
  let lnd = await import("../lib/lnd");
  ln = [
    "addInvoice",
    "channelBalance",
    "connectPeer",
    "decodePayReq",
    "getInfo",
    "listInvoices",
    "listPayments",
    "sendPaymentSync",
    "walletBalance"
  ].reduce(
    (a, b) =>
      (a[b] = args => new Promise(r => lnd[b](args, (e, v) => r(v)))) && a,
    {}
  );
}

export default ln;