How to use the ln-service.createInvoice 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 / helpers.ts View on Github external
let _description

  if (boltwallConfig && boltwallConfig.getInvoiceDescription)
    _description = await boltwallConfig.getInvoiceDescription(req)

  let invoice: InvoiceResponse

  if (lnd) {
    const {
      request: payreq,
      id,
      description = _description,
      created_at: createdAt,
      tokens: amount,
    } = await lnService.createInvoice({
      lnd: lnd,
      description: _description,
      expires_at: expiresAt,
      tokens,
    })
    invoice = { payreq, id, description, createdAt, amount }
  } else if (opennode) {
    const {
      lightning_invoice: { payreq },
      id,
      description,
      created_at: createdAt,
      amount,
    } = await opennode.createCharge({
      description: _description,
      amount: tokens,
github alexbosworth / balanceofsatoshis / network / send_gift.js View on Github external
      createInvoice: ['getChannel', ({l}, cbk) => createInvoice({lnd}, cbk)],
github alexbosworth / balanceofsatoshis / swaps / swap_in.js View on Github external
if (args.tokens > getLimits.max_tokens) {
        return cbk([400, 'AmountTooHighToSwap', {max: getLimits.max_tokens}]);
      }

      if (args.tokens < getLimits.min_tokens) {
        return cbk([400, 'AmountTooLowToSwap', {min: getLimits.min_tokens}]);
      }

      const {fee} = getQuote;

      if (!!args.max_fee && fee > args.max_fee) {
        return cbk([400, 'MaxFeeExceededForSwap', {required_fee: fee}]);
      }

      return createInvoice({
        description: `Submarine swap. Service fee: ${fee}`,
        expires_at: new Date(now() + msPerYear).toISOString(),
        is_including_private_channels: true,
        lnd: getLnd.lnd,
        tokens: args.tokens - fee,
      },
      cbk);
    }],
github submarineswaps / swaps-service / service / complete_swap_transaction.js View on Github external
({parsedInvoice, lnd}, cbk) =>
    {
      const {id} = parsedInvoice;

      return createInvoice({
        lnd,
        expires_at: new Date(Date.now() + paymentTimeoutMs).toISOString(),
        secret: id,
        tokens: dummyLockingInvoiceValue,
      },
      cbk);
    }],
github alexbosworth / balanceofsatoshis / swaps / rebalance.js View on Github external
invoice: ['channels', 'findRoute', 'lnd', ({findRoute, lnd}, cbk) => {
        return createInvoice({
          lnd,
          cltv_delta: cltvDelta,
          description: 'Rebalance',
          tokens: min(maxRebalanceTokens, findRoute.route_maximum),
        },
        cbk);
      }],