PHPackages                             jorijn/bitcoin-bolt11 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. jorijn/bitcoin-bolt11

ActiveLibrary[Payment Processing](/categories/payments)

jorijn/bitcoin-bolt11
=====================

A library for decoding lightning network payment requests as defined in BOLT #11

v1.0.1(1y ago)1121.9k↑17.6%13[1 PRs](https://github.com/Jorijn/bitcoin-bolt11/pulls)MITPHPPHP ^7.4|^8.0

Since Feb 3Pushed 1y ago2 watchersCompare

[ Source](https://github.com/Jorijn/bitcoin-bolt11)[ Packagist](https://packagist.org/packages/jorijn/bitcoin-bolt11)[ Docs](https://github.com/Jorijn/bitcoin-bolt11/)[ RSS](/packages/jorijn-bitcoin-bolt11/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (5)Used By (0)

A PHP library for BOLT #11: Invoice Protocol for Lightning Payments
===================================================================

[](#a-php-library-for-bolt-11-invoice-protocol-for-lightning-payments)

[![Latest Stable Version](https://camo.githubusercontent.com/9ba6bb3fd4833690eead6af8543434d150306002c7db0e380ad447d681d913db/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a6f72696a6e2f626974636f696e2d626f6c7431312e737667)](https://packagist.org/packages/jorijn/bitcoin-bolt11)[![Total Downloads](https://camo.githubusercontent.com/6632eb5eb2d0cc8028f1c45c8c8d8e445a3fdfd273bf8270a881444802534833/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a6f72696a6e2f626974636f696e2d626f6c7431312e737667)](https://packagist.org/packages/jorijn/bitcoin-bolt11)[![License](https://camo.githubusercontent.com/3feff138034cbfda66692fa9509b3e27db4d2a8f7c01ffa67bbb2be1ddb5a78a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6a6f72696a6e2f626974636f696e2d626f6c7431312e737667)](https://packagist.org/packages/jorijn/bitcoin-bolt11)[![PHPUnit Tests](https://github.com/Jorijn/bitcoin-bolt11/workflows/PHPUnit%20Tests/badge.svg)](https://github.com/Jorijn/bitcoin-bolt11/workflows/PHPUnit%20Tests/badge.svg)

This library aims to be a tool to decode BOLT #11 Payment Requests into usable PHP objects. Currently, only decoding is supported.

BOLT #11 is a simple, extendable, QR-code-ready protocol for requesting payments over Lightning.

Installation
------------

[](#installation)

```
$ composer require jorijn/bitcoin-bolt11
```

Usage
-----

[](#usage)

```
$invoice = 'lnbc9678785340p1pwmna7lpp5gc3xfm08u9qy06djf8dfflhugl6p7lgza6dsjxq454gxhj9t7a0sd8dgfkx7cmtwd68yetpd5s9xar0wfjn5gpc8qhrsdfq24f5ggrxdaezqsnvda3kkum5wfjkzmfqf3jkgem9wgsyuctwdus9xgrcyqcjcgpzgfskx6eqf9hzqnteypzxz7fzypfhg6trddjhygrcyqezcgpzfysywmm5ypxxjemgw3hxjmn8yptk7untd9hxwg3q2d6xjcmtv4ezq7pqxgsxzmnyyqcjqmt0wfjjq6t5v4khxxqyjw5qcqp2rzjq0gxwkzc8w6323m55m4jyxcjwmy7stt9hwkwe2qxmy8zpsgg7jcuwz87fcqqeuqqqyqqqqlgqqqqn3qq9qn07ytgrxxzad9hc4xt3mawjjt8znfv8xzscs7007v9gh9j569lencxa8xeujzkxs0uamak9aln6ez02uunw6rd2ht2sqe4hz8thcdagpleym0j';

$decoder = new \Jorijn\Bitcoin\Bolt11\Encoder\PaymentRequestDecoder();
$denormalizer = new \Jorijn\Bitcoin\Bolt11\Normalizer\PaymentRequestDenormalizer();

$paymentRequest = $denormalizer->denormalize($decoder->decode($invoice));

// satoshis: 967878
echo 'satoshis: ' . $paymentRequest->getSatoshis();

// description: Blockstream Store: 88.85 USD for Blockstream Ledger Nano S x 1, "Back In My Day" Sticker x 2, "I Got Lightning Working" Sticker x 2 and 1 more items
echo 'description: ' . $paymentRequest->findTagByName(\Jorijn\Bitcoin\Bolt11\Model\Tag::DESCRIPTION)->getData();

// timestamp: DateTime Object
// (
//     [date] => 2019-10-30 20:51:43.000000
//     [timezone_type] => 1
//     [timezone] => +00:00
// )
echo 'timestamp: ' . print_r($paymentRequest->getTimestampDateTime(), true);

// hop: 0
// public key: 029e03a901b85534ff1e92c43c74431f7ce72046060fcf7a95c37e148f78c77255
// short channel id: 0102030405060708
// fee base msat: 1
// fee proportional millionths 20
// cltv expiry delta: 3
foreach ($paymentRequest->findTagByName(\Jorijn\Bitcoin\Bolt11\Model\Tag::ROUTING_INFO)->getData() as $hop => $routingInfo) {
    echo 'hop: ' . $hop;
    echo 'public key: ' . $routingInfo->getPubKey();
    echo 'short channel id: ' . $routingInfo->getShortChannelId();
    echo 'fee base msat: ' . $routingInfo->getFeeBaseMsat();
    echo 'fee proportional millionths ' . $routingInfo->getFeeProportionalMillionths();
    echo 'cltv expiry delta: ' . $routingInfo->getCltvExpiryDelta();
}
```

More examples are available in the [examples](examples) directory.

Warning
-------

[](#warning)

The `->getSatoshis()` method will only return a valid number if the invoice is for a whole number of satoshis. If it is in a fractional number of satoshis, and the method returns NULL, the `->getMilliSatoshis()` method must be used. 1000 millisatoshis is 1 satoshi.

Thanks
------

[](#thanks)

This library is based on other BOLT #11 libraries from other programming languages. Special thanks to:

-
-
-

CLI tool
--------

[](#cli-tool)

There is a CLI tool based on this library. It allows for easy decoding and converting of payment requests into JSON, XML, YAML &amp; CSV. Download and usage here:

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 94.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~419 days

Total

4

Last Release

671d ago

Major Versions

v0.2.0 → v1.0.02022-08-20

PHP version history (3 changes)v0.1.0PHP ^7.3

v0.2.0PHP ^7.3|^8.0

v1.0.0PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7350da3312b4ad789e82ccacc049b88844d215cdbb93fb0bcdea93687416c0d0?d=identicon)[jorijn](/maintainers/jorijn)

---

Top Contributors

[![jorijn](https://avatars.githubusercontent.com/u/85466?v=4)](https://github.com/jorijn "jorijn (36 commits)")[![dsbaars](https://avatars.githubusercontent.com/u/480514?v=4)](https://github.com/dsbaars "dsbaars (2 commits)")

---

Tags

bitcoinbolt11lightning-networkbitcoinlightning-networkbolt11

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/jorijn-bitcoin-bolt11/health.svg)

```
[![Health](https://phpackages.com/badges/jorijn-bitcoin-bolt11/health.svg)](https://phpackages.com/packages/jorijn-bitcoin-bolt11)
```

###  Alternatives

[coingate/coingate-php

CoinGate library for PHP

56459.2k1](/packages/coingate-coingate-php)[bitpay/sdk

Complete version of the PHP library for the new cryptographically secure BitPay API

42337.5k4](/packages/bitpay-sdk)[block_io-php/block_io-php

Block.io is the easiest way to create wallets, send, and accept payments through Bitcoin, Litecoin, and Dogecoin. This is its PHP library.

57118.1k2](/packages/block-io-php-block-io-php)[hexters/coinpayment

CoinPayment is a Laravel module for handling transactions from CoinPayment like a create transaction, history transaction, etc.

7058.0k](/packages/hexters-coinpayment)[bitpay/sdk-light

Light version of the PHP library for the new cryptographically secure BitPay API

19143.6k3](/packages/bitpay-sdk-light)[omnipay/bitpay

BitPay driver for the Omnipay payment processing library

1383.2k1](/packages/omnipay-bitpay)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
