jorijn/bitcoin-bolt11
Composer 安装命令:
composer require jorijn/bitcoin-bolt11
包简介
A library for decoding lightning network payment requests as defined in BOLT #11
README 文档
README
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
$ composer require jorijn/bitcoin-bolt11
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 directory.
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
This library is based on other BOLT #11 libraries from other programming languages. Special thanks to:
- https://github.com/lightningnetwork/lnd/blob/master/zpay32/decode.go
- https://github.com/bitcoinjs/bolt11
- https://github.com/nievk/bolt11
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 & CSV. Download and usage here: https://github.com/Jorijn/bitcoin-bolt11-cli
jorijn/bitcoin-bolt11 适用场景与选型建议
jorijn/bitcoin-bolt11 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23.75k 次下载、GitHub Stars 达 11, 最近一次更新时间为 2021 年 02 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「bitcoin」 「lightning-network」 「bolt11」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jorijn/bitcoin-bolt11 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jorijn/bitcoin-bolt11 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jorijn/bitcoin-bolt11 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The BlockTrail PHP SDK, for integration of Bitcoin functionality through the BlockTrail API
Modern PHP 8.3+ BOLT 11 Lightning Network invoice encoder/decoder
CoinDesk Bitcoin Price Index API for Laravel
phinance, binance API PHP client
pholoniex, poloniex API PHP client
Convertation from/to any user-defined base-chars-string throught decimal representation of arbitrary precision
统计信息
- 总下载量: 23.75k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-02-05