aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ln.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-09-02 14:47:08 -0700
committerAdam Soltys <[email protected]>2022-09-02 14:47:14 -0700
commit3161dd7ee95b6c7d70f8341298dd4fab84cda8b0 (patch)
tree16cd6c55d5dc481331b1e8b640d179f193e7ea13 /lib/ln.js
parent7a8d64833de8873afb92982b3f5bfff59b30c542 (diff)
downloadcoinos-server-3161dd7ee95b6c7d70f8341298dd4fab84cda8b0.tar.gz
coinos-server-3161dd7ee95b6c7d70f8341298dd4fab84cda8b0.zip
es6 migration
Diffstat (limited to 'lib/ln.js')
-rw-r--r--lib/ln.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/ln.js b/lib/ln.js
new file mode 100644
index 00000000..91a704e9
--- /dev/null
+++ b/lib/ln.js
@@ -0,0 +1,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;