aboutsummaryrefslogtreecommitdiffstats
path: root/static/icons/heart.svg
blob: f3a5f757c02d2d7f9235a25eb188404e444267f0 (plain) (blame)
1
2
3
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4.31802 6.31802C2.56066 8.07538 2.56066 10.9246 4.31802 12.682L12.0001 20.364L19.682 12.682C21.4393 10.9246 21.4393 8.07538 19.682 6.31802C17.9246 4.56066 15.0754 4.56066 13.318 6.31802L12.0001 7.63609L10.682 6.31802C8.92462 4.56066 6.07538 4.56066 4.31802 6.31802Z" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
ghlight">
const fs = require("fs");
const grpc = require("grpc");
const createLnrpc = require("lnrpc");
const { promisify } = require("util");

module.exports = async ({ server, tls, macaroon }) => {
  const lnrpc = await createLnrpc({ server, tls, macaroonPath: macaroon  });

  // Resolve proxy instance
  return new Proxy(lnrpc, {
    /**
     * Promisify each lightning RPC method
     * @param  {lnrpc.Lightning} target
     * @param  {String}          key
     * @return {Promise} {Any}
     */
    get(target, key) {
      const method = target[key];

      if (typeof key === "string" && typeof method === "function") {
        const streaming = key.match(/openChannel$|sendPayment|subscribe.*/);
        let fn;

        if (streaming) {
          if (key === "sendPayment" || key === "sendToRoute") {
            fn = params => method.call(lnrpc, target.meta, params);
          } else {
            fn = params => method.call(lnrpc, params, target.meta);
          }
        } else {
          fn = params => promisify(method).call(lnrpc, params, target.meta);
        }

        return fn;
      }

      return target[key]; // forward
    }
  });
};