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.
composer require lnpay/php-lndconnect
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....'
* ]
*/
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.....
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...
Run the tests suite:
vendor/bin/phpunit
Feel free to dive in! Open an issue or submit PRs.
lndconnect follows the Contributor Covenant Code of Conduct.
MIT © Tim Kijewski