Skip to content

tools for adding lnurl support in a wallet

License

Notifications You must be signed in to change notification settings

nbd-wtf/js-lnurl

Repository files navigation

js-lnurl

Tools for adding lnurl support in JavaScript wallet interfaces.

Example

import { getParams } from 'js-lnurl'

getParams("LNURL1...")
  .then(params => {
    switch (params.tag) {
      case 'withdrawRequest':
        // tag: string
        // k1: string
        // callback: string
        // domain: string
        // minWithdrawable: number
        // maxWithdrawable: number
        // defaultDescription: string
        break
      case 'payRequest':
        // tag: string
        // callback: string
        // domain: string
        // minSendable: number
        // maxSendable: number
        // metadata: string
        // decodedMetadata: string[][]
        // commentAllowed?: number
        break
      case 'login':
        // tag: string
        // k1: string
        // callback: string
        // domain: string
        break
      case 'channelRequest':
        // params.tag: string
        // params.callback: string
        // params.domain: string
        // params.k1: string
        // params.uri: string
        break
    }
  })

Other included helpers

import {
  findlnurl,
  decodelnurl,
  decipherAES,
  getDomain
} from 'js-lnurl/lib/helpers'
// or
import {findlnurl} from 'js-lnurl/lib/helpers/findlnurl'
import {decodelnurl} from 'js-lnurl/lib/helpers/decodelnurl'
import {decipherAES} from 'js-lnurl/lib/helpers/decipherAES'
import {getDomain} from 'js-lnurl/lib/helpers/getDomain'

// see src/helpers/*.ts

How to build

Do this before publishing to npm:

yarn
make