This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.
This package is abandoned and no longer maintained. The author suggests using the package instead.
There is no license information available for the latest version (v0.13.0-beta) of this package.

PHP LND RPC Implementation

v0.13.0-beta 2021-06-23 18:28 UTC

This package is auto-updated.

Last update: 2021-06-23 18:29:05 UTC


PHP Requirements

$ sudo apt-get install php-dev php-pear zlib1g-dev zip unzip
$ pecl install grpc
$ sudo sh -c "echo '' >> /etc/php/7.2/cli/php.ini" #depends on PHP version you are using. Add this line in the ini file


The preferred way to install this extension is through composer:

composer require lnpay/php-lnd-grpc

Basic Usage

Then can be used as such:



require __DIR__ . '/vendor/autoload.php';

$certPath = '../.lnd/tls.cert';
$macaroonPath = '../.lnd/data/chain/bitcoin/mainnet/admin.macaroon';

$cert = file_get_contents($certPath);
$macaroon = file_get_contents($macaroonPath);
$callback = function ($metadata) use ($macaroon) {
        return ['macaroon' => [bin2hex($macaroon)]];

$credentials = \Grpc\ChannelCredentials::createSsl($cert);
$x = new \Lnrpc\LightningClient('',['credentials'=>$credentials,'update_metadata'=>$callback]);
$gir = new \Lnrpc\WalletBalanceRequest();
$result = $x->WalletBalance($gir);
echo "Balance:".$result->wait()[0]->getTotalBalance();

Multiple client example


use Invoicesrpc\InvoicesClient;
use Lnrpc\LightningClient;

final class LndGrpcClient
    /** @var LightningClient */
    public $lnrpc;

    /** @var InvoicesClient */
    public $invoicesrpc;

    public function __construct(string $endpoint, array $options)
        $this->lnrpc = new LightningClient($endpoint, $options); //$options example seen in Basic Usage
        $this->invoicesrpc = new InvoicesClient($endpoint, $options); //$options example seen in Basic Usage

Updating the RPC definitions

$ bash v0.11.1-beta pulls in and generates based on this.

Currently generated: rpc.proto invoices.proto router.proto walletkit.proto chainnotifier.proto signer.proto