How to use the ln-service.authenticatedLndGrpc function in ln-service

To help you get started, we’ve selected a few ln-service examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Tierion / boltwall / src / routes / parseEnv.ts View on Github external
export default function parseEnv(
  req: LndRequest,
  _res: Response,
  next: NextFunction
): void {
  try {
    testEnvVars()
    let { OPEN_NODE_KEY, LND_TLS_CERT, LND_MACAROON, LND_SOCKET } = getEnvVars()
    // if the tests pass above and we don't have a
    // OPEN_NODE_KEY then we need to setup the lnd service
    if (!OPEN_NODE_KEY) {
      const { lnd } = lnService.authenticatedLndGrpc({
        cert: LND_TLS_CERT,
        macaroon: LND_MACAROON,
        socket: LND_SOCKET,
      })
      req.lnd = lnd
    } else {
      const env = process.env.ENVIRONMENT || 'dev'
      const opennode = require('opennode')
      opennode.setCredentials(OPEN_NODE_KEY, env)
      req.opennode = opennode
    }
    next()
  } catch (e) {
    console.error(
      'Problem with configs for connecting to lightning node:',
      e.message
github submarineswaps / swaps-service / lightning / lightning_daemon.js View on Github external
const socket = process.env[`SSS_LND_${networkName}_GRPC_HOST`];

  if (!cert) {
    throw new Error('ExpectedDaemonCert');
  }

  if (!macaroon) {
    throw new Error('ExpectedDaemonMacaroon');
  }

  if (!socket) {
    throw new Error('ExpectedDaemonHost');
  }

  try {
    lnd = authenticatedLndGrpc({cert, macaroon, socket}).lnd;
  } catch (err) {
    throw new Error('FailedToInstantiateDaemon');
  }

  const sub = subscribeToInvoices({lnd});

  daemons[network] = {lnd, sub};

  // Clear daemon cache on errors or end of subscription
  // This subscription allows opportunistic reconnecting on remote restarts.
  daemons[network].sub.on('invoice_updated', () => {});
  daemons[network].sub.on('end', () => daemons[network] = null);
  daemons[network].sub.on('error', ({}) => daemons[network] = null);
  daemons[network].sub.on('status', () => {});

  return lnd;
github submarineswaps / swaps-service / test / macros / spawn_lnd.js View on Github external
lnd: ['wallet', ({wallet}, cbk) => {
      try {
        return cbk(null, authenticatedLndGrpc({
          cert: wallet.cert,
          macaroon: wallet.macaroon,
          socket: wallet.host,
        }).lnd);
      } catch (err) {
        return cbk([503, 'FailedToInstantiateWalletLnd', err]);
      }
    }],
github alexbosworth / balanceofsatoshis / chain / split_utxos.js View on Github external
lnd: ['credentials', ({credentials}, cbk) => {
      return cbk(null, authenticatedLndGrpc({
        cert: credentials.cert,
        macaroon: credentials.macaroon,
        socket: credentials.socket,
      }).lnd);
    }],
github alexbosworth / balanceofsatoshis / nodes / get_saved_nodes.js View on Github external
return asyncMap(getNodeCredentials, ({credentials, node}, cbk) => {
          if (!credentials) {
            return cbk([400, 'InvalidCredentialsForNode', {node}]);
          }

          if (!credentials.macaroon) {
            return cbk(null, {
              node_name: node,
              locked_to_keys: credentials.encrypted_to,
            });
          }

          const {lnd} = authenticatedLndGrpc(credentials);

          return getWalletInfo({lnd}, (err, res) => {
            if (!!err) {
              return cbk(null, {node_name: node});
            }

            return cbk(null, {
              node_name: node,
              is_online: res.is_synced_to_chain,
            });
          });
        },
        cbk);
github alexbosworth / balanceofsatoshis / wallets / unlock_wallet.js View on Github external
lnd: ['credentials', ({credentials}, cbk) => {
      return cbk(null, authenticatedLndGrpc({
        cert: credentials.cert,
        macaroon: credentials.macaroon,
        socket: credentials.socket,
      }).lnd);
    }],
github alexbosworth / balanceofsatoshis / lnd / authenticated_lnd.js View on Github external
lnd: ['credentials', ({credentials}, cbk) => {
        return cbk(null, authenticatedLndGrpc({
          cert: credentials.cert,
          macaroon: credentials.macaroon,
          socket: credentials.socket,
        }));
      }],
    },
github alexbosworth / balanceofsatoshis / network / hidden_pay.js View on Github external
lnd: ['credentials', ({credentials}, cbk) => {
      return cbk(null, authenticatedLndGrpc({
        cert: credentials.cert,
        macaroon: credentials.macaroon,
        socket: credentials.socket,
      }).lnd);
    }],