定制 lnpay/php-lnd-grpc 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lnpay/php-lnd-grpc

Composer 安装命令:

composer require lnpay/php-lnd-grpc

包简介

PHP LND RPC Implementation

README 文档

README

PHP Requirements

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

Installation

The preferred way to install this extension is through composer:

composer require lnpay/php-lnd-grpc

Basic Usage

Then can be used as such:

<?php

putenv('GRPC_SSL_CIPHER_SUITES=HIGH+ECDSA');

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('127.0.0.1:10009',['credentials'=>$credentials,'update_metadata'=>$callback]);
$gir = new \Lnrpc\WalletBalanceRequest();
$result = $x->WalletBalance($gir);
echo "Balance:".$result->wait()[0]->getTotalBalance();

Multiple client example

//EXAMPLE BY @MrHash

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 regenerate_rpc.sh v0.11.1-beta

regenerate_rpc.sh pulls in https://raw.githubusercontent.com/lightningnetwork/lnd/master/v0.11.1-beta/XXX.proto and generates based on this.

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

统计信息

  • 总下载量: 830
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 4
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2020-07-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固