Skip to content

Documentation on using LNbits API to pay lightning addresses and LNURL

Notifications You must be signed in to change notification settings

cdekort/lnbits-lightning-lnurl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 

Repository files navigation

lnbits-lightning-lnurl

Documentation on using LNbits API to pay lightning addresses and LNURL

Link to the relevant part of the LNbits API: https://legend.lnbits.com/docs#/default/api_payments_pay_lnurl_api_v1_payments_lnurl_post

STEPS:

  1. Decode LNURL using LNbits API. Skip this if you're paying a lightning address.

    curl -X 'POST'
    https://your-lnbits-endpoint.com/api/v1/payments/decode
    -H "X-Api-Key: <INVOICE KEY>"
    -H "Content-type: application/json"
    -d '{"data": <LNURL>}'
    

    Sample response:

    {
        "domain": "https://decoded-lnurl-domain.com"
    }
    
  2. Retrieve callback URL and metadata from lightning address or LNURL.

    cURL for lightning address:

    curl 'https://lightning-wallet-domain.com/.well-known/lnurlp/username'

    OR

    cURL for LNURL:

    curl 'https://decoded-lnurl-domain.com'

    Sample response:

    {
        "status": "OK",
        "tag": "payRequest",
        "commentAllowed": 255,
        "callback": "https://lightning-wallet-domain.com/lnurlp/username/callback",
        "metadata": "[[\"text/identifier\",\"[email protected]\"],[\"text/plain\",\"Payment\"]]",
        "minSendable": 1000,
        "maxSendable": 11000000000,
        "payerData": {
            "name": {
                "mandatory": false
            },
            "email": {
                "mandatory": false
            },
            "pubkey": {
                "mandatory": false
            }
        }
    }
    
  3. Process payment using LNbits API:

    curl -X 'POST' 
      'https://your-lnbits-endpoint.com/api/v1/payments/lnurl'
      -H "X-Api-Key: <ADMIN KEY>"
      -H 'Content-Type: application/json' 
      -d '{
        "description_hash": <string>,
        "callback": <string>,
        "amount": <int>,
        "comment": <string>,
        "description": <string>
    }'
    

    WHERE:

    description_hash = the sha256 hash of metadata from decoded LNURL or lightning address

    callback = callback url from decoded LNURL or lightning address

    amount = amount to be paid; specified in millisats (sats to be paid * 1000)

    comment = transaction note that will appear in receiver's lightning wallet (write what you want)

    description = memo that will appear in your LNbits wallet (write what you want)

Relevant links:

  1. On lightning addresses: https://github.com/andrerfneves/lightning-address/blob/master/README.md
  2. On LNURL payRequest: https://github.com/lnurl/luds/blob/luds/06.md

About

Documentation on using LNbits API to pay lightning addresses and LNURL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published