lnpay / php-lndconnect
PHP implementation of LNDConnect Spec
Requires (Dev)
- phpunit/phpunit: ^5.4.0
- squizlabs/php_codesniffer: ^2.0.0
This package is auto-updated.
Last update: 2024-10-25 04:45:43 UTC
README
Generate and parse lndconnect uris https://github.com/LN-Zap/lndconnect ⚡️
This package provides utilities for generating and parsing lndconnect uris in PHP.
For more information take a look at the specification of the uri format.
Table of Contents
Install
composer require lnpay/php-lndconnect
Usage
LndConnect::format($host,$encoded_cert,$base64url_macaroon);
Formats a host / cert / macaroon combo into an lndconnect link.
use LndConnect\LndConnect; LndConnect::format('127.0.0.1:10009','MIICuDCCAl...','AgEDbG5kAus...'); //lndconnect://127.0.0.1:10009?cert=MIICuDCCAl...&macaroon=AgEDbG5kAus...')
LndConnect::encode($host,$raw_cert,$macaroon_hex);
Encodes a host / cert / macaroon combo and formats into an lndconnect link.
use LndConnect\LndConnect; LndConnect::encode('127.0.0.1:10009','-----BEGIN CERTIFICATE-----...','0201036c6...'); //lndconnect://127.0.0.1:10009?cert=MIICuDCCAl...&macaroon=AgEDbG5kAus...')
LndConnect::decode($lndconnect_uri);
Decodes an lndconnect link into it's component parts (host / cert as utf8 / macaroon as hex)
use LndConnect\LndConnect; LndConnect::decode('lndconnect://127.0.0.1:10001?cert=MIICDjCCAbSgAwI&macaroon=AgEDbG5'); /* * [ * 'host' => '127.0.0.1:10001', * 'cert => '-----BEGIN CERTIFICATE-----.....', * 'macaroon'=>'0201036c6....' * ] */
Certificate
LndConnect::encodeCert($raw_cert):
Encodes a certificate string to base64url encoded DER format.
use LndConnect\LndConnect; LndConnect::encodeCert('-----BEGIN CERTIFICATE-----\n.....'); //MIICDjCCAbSgAwI
LndConnect::decodeCert($lndconnect_cert):
Decodes a certificate from base64url encoded DER format to a string.
use LndConnect\LndConnect; LndConnect::decodeCert('MIICDjCCAbSgAwI'); //-----BEGIN CERTIFICATE-----\n.....
Macaroon
LndConnect::encodeMacaroon($macaroon_hex):
Encodes a binary macaroon hex to base64url encoded string.
use LndConnect\LndConnect; LndConnect::encodeMacaroon('0201036c6...'); //AgEDbG5kAus...
LndConnect::decodeMacaroon($lndconnect_macaroon):
Decodes a base64url encoded macaroon to a hex encoded macaroon.
use LndConnect\LndConnect; LndConnect::decodeMacaroon('AgEDbG5kAus...'); //0201036c6...
Testing
Run the tests suite:
vendor/bin/phpunit
Maintainers
Contribute
Feel free to dive in! Open an issue or submit PRs.
lndconnect follows the Contributor Covenant Code of Conduct.
License
MIT © Tim Kijewski