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.

Files for lnurl, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size lnurl-0.1.1-py3-none-any.whl (5.5 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size lnurl-0.1.1.tar.gz (4.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page