Skip to main content

LNURL implementation for Python.

Project description

LNURL implementation for Python

travis-badge codecov-badge pypi-badge license-badge

Basic usage

import lnurl

lnurl.encode('https://example.com/c?p=a8dw93x2h39s1f')
lnurl.decode('LNURL1DP68GURN8GHJ7ETCV9KHQMR99E3K7MF0VVLHQ0TP8PJ8WWFN0QEXSVEEWVCKVF3A4RP')

Advanced usage

The Lnurl object wraps a bech32 LNURL to provide some extra utilities.

from lnurl import Lnurl

lnurl = Lnurl('LNURL1DP68GURN8GHJ7ETCV9KHQMR99E3K7MF0VVLHQ0TP8PJ8WWFN0QEXSVEEWVCKVF3A4RP')
lnurl.bech32  # 'LNURL1DP68GURN8GHJ7ETCV9KHQMR99E3K7MF0VVLHQ0TP8PJ8WWFN0QEXSVEEWVCKVF3A4RP'
lnurl.decoded  # 'https://example.com/c?p=a8dw93x2h39s1f'
lnurl.url.base  # 'https://example.com/c'
lnurl.url.query_params  # {'p': 'a8dw93x2h39s1f'}

You can also use a LnurlResponse to wrap responses you get from a LNURL.
The different types of responses defined in the LNURL specification have a different response class with different properties (see models.py):

import requests

from lnurl import Lnurl, LnurlWithdrawResponse

lnurl = Lnurl('LNURL1DP68GURN8GHJ7UM9WFMXJCM99E3K7MF0V9CXJ0M384EKZAR0WD5XJ0JELRS')
res = requests.get(lnurl.decoded)
withdraw = LnurlWithdrawResponse(res.json())
withdraw.max_sats  # int
withdraw.callback.base  # str
withdraw.callback.query_params # dict

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lnurl-0.1.0.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

lnurl-0.1.0-py3-none-any.whl (5.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page