diff options
| author | Adam Soltys <[email protected]> | 2019-09-12 15:25:47 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2019-09-12 23:01:06 -0700 |
| commit | 087fdd27f3683a1deb9376b7a72aa608e6fd8e6a (patch) | |
| tree | 68bf0872fcfdc65003ed4642bac09aab64d3a3ac /lib | |
| parent | 7da9aa2406fbd890956dcf89c5756949758911dd (diff) | |
| download | coinos-server-087fdd27f3683a1deb9376b7a72aa608e6fd8e6a.tar.gz coinos-server-087fdd27f3683a1deb9376b7a72aa608e6fd8e6a.zip | |
remove babel and eslint
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/createLnrpc.js | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/lib/createLnrpc.js b/lib/createLnrpc.js index 16a59b3c..661440bb 100644 --- a/lib/createLnrpc.js +++ b/lib/createLnrpc.js @@ -1,13 +1,11 @@ -import fs from 'fs' -import grpc from 'grpc' -import createLnrpc from 'lnrpc' -import {promisify} from 'util' +const fs = require("fs"); +const grpc = require("grpc"); +const createLnrpc = require("lnrpc"); +const { promisify } = require("util"); -export default async ({ server, tls, macaroon, channelpeers }) => { - const lnrpc = await createLnrpc({ server, tls }) - lnrpc.meta = new grpc.Metadata() - lnrpc.meta.add('macaroon', fs.readFileSync(macaroon).toString('hex')) - lnrpc.channelpeers = channelpeers +module.exports = async ({ server, tls, macaroon, channelpeers }) => { + const lnrpc = await createLnrpc({ server, tls, macaroonPath: macaroon }); + lnrpc.channelpeers = channelpeers; // Resolve proxy instance return new Proxy(lnrpc, { @@ -18,26 +16,26 @@ export default async ({ server, tls, macaroon, channelpeers }) => { * @return {Promise} {Any} */ get(target, key) { - const method = target[key] + const method = target[key]; - if (typeof key === 'string' && typeof method === 'function') { - const streaming = key.match(/openChannel$|sendPayment|subscribe.*/) - let fn + if (typeof key === "string" && typeof method === "function") { + const streaming = key.match(/openChannel$|sendPayment|subscribe.*/); + let fn; if (streaming) { - if (key === 'sendPayment') { - fn = params => method.call(lnrpc, target.meta, params) + if (key === "sendPayment") { + fn = params => method.call(lnrpc, target.meta, params); } else { - fn = params => method.call(lnrpc, params, target.meta) - } + fn = params => method.call(lnrpc, params, target.meta); + } } else { - fn = params => promisify(method).call(lnrpc, params, target.meta) - } + fn = params => promisify(method).call(lnrpc, params, target.meta); + } - return fn + return fn; } return target[key]; // forward } }); -} +}; |
