Giter Club home page Giter Club logo

lnbits-lightning-lnurl's Introduction

lnbits-lightning-lnurl

Documentation on using LNbits API to pay lightning addresses and LNURL

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

For testing purposes, you can inspect your LNURL and lightning address and view the expected description_hash using this tool: https://lightninginspector.mysatoshikit.com/

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 parsed 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
  3. Tool to view expected description_hash of parsed metadata from decoded LNURL or lightning address: https://lightninginspector.mysatoshikit.com/

lnbits-lightning-lnurl's People

Contributors

cdekort avatar jimasuen avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

cdekort

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.