Skip to main content

A library for encoding and decoding BOLT11 payment requests.

Project description

Lightning BOLT11 utils

github-tests-badge github-mypy-badge codecov-badge pypi-badge pypi-versions-badge license-badge

This is an implementation of the Lightning BOLT11 specification, based on previous work by Rusty Russell, the Electrum Wallet team, and the LNbits bolt11 helpers created by @fiatjaf.

resources

installing

$ git clone https://github.com/lnbits/bolt11
$ cd bolt11
$ uv sync

running CLI

$ uv run bolt11 --help
$ uv run bolt11 decode

run all checks and tests

$ make

using pre-commit as git hook

$ uv run pre-commit install

running CLI

$ uv run bolt11 --help

running CLI decode

$ uv run bolt11 decode lnbc20m1pvjluez.....
{
  "currency": "bc",
  "amount": 2000000000,
  "timestamp": 1496314658,
  "signature": "6a6586db4e8f6d40e3a5bb92e4df5110c627e9ce493af237e20a046b4e86ea200178c59564ecf892f33a9558bf041b6ad2cb8292d7a6c351fbb7f2ae2d16b54e",
  "description_hash": "3925b6f67e2c340036ed12093dd44e0368df1b6ea26c53dbe4811f58fd5db8c1",
  "features": {
    "var_onion_optin": "required",
    "payment_secret": "required"
  },
  "fallback": "1RustyRX2oai4EYYDpQGWvEL62BBGqN9T",
  "route_hints": [
    {
      "public_key": "029e03a901b85534ff1e92c43c74431f7ce72046060fcf7a95c37e148f78c77255",
      "short_channel_id": "66051x263430x1800",
      "base_fee": 1,
      "ppm_fee": 20,
      "cltv_expiry_delta": 3
    },
    {
      "public_key": "039e03a901b85534ff1e92c43c74431f7ce72046060fcf7a95c37e148f78c77255",
      "short_channel_id": "197637x395016x2314",
      "base_fee": 2,
      "ppm_fee": 30,
      "cltv_expiry_delta": 4
    }
  ],
  "min_final_cltv_expiry": 9,
  "payment_hash": "0001020304050607080900010203040506070809000102030405060708090102",
  "payment_secret": "1111111111111111111111111111111111111111111111111111111111111111",
  "payee": "03e7156ae33b0a208d0744199163177e909e80176e55d97a2f221ede0f934dd9ad"
}

running CLI encode

$ uv run bolt11 encode '{
  "currency": "bc",
  "amount_msat": 1000,
  "date": 1590000000,
  "payment_hash": "0001020304050607080900010203040506070809000102030405060708090102",
  "payment_secret": "1111111111111111111111111111111111111111111111111111111111111111",
  "description": "description"
}' e126f68f7eafcc8b74f54d269fe206be715000f94dac067d1c04a8ca3b2db734

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

bolt11-2.2.0.tar.gz (57.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bolt11-2.2.0-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file bolt11-2.2.0.tar.gz.

File metadata

  • Download URL: bolt11-2.2.0.tar.gz
  • Upload date:
  • Size: 57.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for bolt11-2.2.0.tar.gz
Algorithm Hash digest
SHA256 12cd9d0d3eb0f08c505b1834f21630369974c1de3b9c39b9abd48ddd0d1a444b
MD5 99d2a2ec931ed89d746d087fb2157707
BLAKE2b-256 cb8ae936a9bf1888742a55f52b143a81050ebce03c3ce21a243862c5c386220c

See more details on using hashes here.

File details

Details for the file bolt11-2.2.0-py3-none-any.whl.

File metadata

  • Download URL: bolt11-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for bolt11-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4684ac33cf274a2ee00f45b5a691d6743ede04ef455b4c12046648b4f20e2a81
MD5 92cebacdfa5a866dcd4c06ea47ac7d29
BLAKE2b-256 a87c9671c85e7a0883fa732c83dccd5ed64338ab14a02adc384ecb47477f8348

See more details on using hashes here.

Supported by

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