How to use the ln-service.getInvoice 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
export async function checkInvoiceStatus(
  lnd: any,
  opennode: any,
  invoiceId: string
): Promise {
  if (!invoiceId) throw new Error('Missing invoice id.')

  let status, amount, payreq, createdAt
  if (lnd) {
    const invoiceDetails = await lnService.getInvoice({
      id: invoiceId,
      lnd: lnd,
    })

    // for hodl invoices, status might be "is_held"
    status = invoiceDetails['is_confirmed']
      ? 'paid'
      : invoiceDetails['is_held']
      ? 'held'
      : 'unpaid'
    amount = invoiceDetails.tokens
    payreq = invoiceDetails.request
    createdAt = invoiceDetails.created_at
  } else if (opennode) {
    const data = await opennode.chargeInfo(invoiceId)
    amount = data.amount
github alexbosworth / balanceofsatoshis / swaps / swap_in.js View on Github external
return (async () => {
          try {
            const {id} = await decodeSwapRecovery({recovery: args.recovery});

            return getInvoice({id, lnd: getLnd.lnd}, cbk);
          } catch (err) {
            return cbk([400, 'FailedToDecodeSwapRecovery', {err}]);
          }
        })();
      }