How to use the ln-service.lightningDaemon 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 Jasonhcwong / lnswaps / service / lnd.js View on Github external
const { lightningDaemon } = require('ln-service');

const { LNSWAP_LND_GRPC_HOST } = process.env;

let lnd;
try {
  lnd = lightningDaemon({
    host: LNSWAP_LND_GRPC_HOST,
  });
} catch (e) {
  console.log('Error initialize connection with lnd:', e);
  throw new Error('FailedToInitializedLightningGrpcApi');
}

/** Get the Lightning Network Daemon connection

  {}

  @throws
   when daemon credentials are not available

  @returns
github Jasonhcwong / lnswaps / lnd_task.js View on Github external
const { lightningDaemon, getRoutes, pay } = require('ln-service');
const log4js = require('log4js');

const { redisClient, redisSub, updateRedisOrderAndPublish } = require('./service/redis_client.js');
const orderState = require('./service/order_state.js');

const logger = log4js.getLogger();
logger.level = 'all';

let lnd;
try {
  const { LNSWAP_LND_SOCKET, LNSWAP_LND_CERT, LNSWAP_LND_MACAROON } = process.env;
  lnd = lightningDaemon({
    socket: LNSWAP_LND_SOCKET,
    cert: LNSWAP_LND_CERT,
    macaroon: LNSWAP_LND_MACAROON,
  });
} catch (e) {
  logger.fatal('Error initialize connection with lnd:', e);
  process.exit();
}

redisSub.on('subscribe', (channel, count) => {
  logger.info(`[subcribe]channel: ${channel}, count: ${count}`);
});

redisSub.on('message', (channel, msg) => {
  logger.debug(`[message]${channel}: ${msg}`);
  if (channel !== orderState.channel) return;
github submarineswaps / swaps-service / lightning / pay_invoice.js View on Github external
module.exports = ({invoice}, cbk) => {
  if (!invoice) {
    return cbk([400, 'ExpectedInvoice']);
  }

  const lnd = lightningDaemon({
    cert: OCW_LND_TLS_CERT,
    host: OCW_LND_GRPC_HOST,
    macaroon: OCW_LND_MACAROON,
  });

  return payInvoice({invoice, lnd, wss: []}, (err, res) => {
    if (!!err) {
      return cbk([503, 'FailedToPayInvoice', err]);
    }

    return cbk(null, {payment_secret: res.payment_secret});
  });
};