Last active
July 1, 2020 16:13
-
-
Save bumi/aef510e637f7a3d0792116e3871617e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Path to autoload.php created by composer. | |
require dirname(__FILE__).'/../vendor/autoload.php'; | |
error_reporting(2); | |
$lndIp = ''; // IP:PORT | |
$sslCert = ''; | |
$macaroon = ''; | |
// We need to set env variables to make ssl work: | |
putenv('GRPC_SSL_CIPHER_SUITES=ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256'); | |
try { | |
$client = new Lnrpc\LightningClient($lndIp, [ | |
'credentials' => Grpc\ChannelCredentials::createSsl($sslCert), | |
'update_metadata' => [ 'Grpc-Metadata-macaroon' => [$macaroon] ]; | |
]); | |
var_dump($client); | |
} catch (Exception $e) { | |
throw new Exception($e->getMessage()); | |
} | |
if (is_null($client)) { | |
throw new Exception('Could not connect or authenticate to LND node.'); | |
} | |
// As example we get the public key of the lnd node. | |
// See directory "src/Lnrpc" for available classes. | |
print('GetInfo:' . PHP_EOL); | |
try { | |
$getInfoRequest = new Lnrpc\GetInfoRequest(); | |
list($reply, $status) = $client->GetInfo($getInfoRequest)->wait(); | |
print_r($reply->getIdentityPubkey()); | |
print(PHP_EOL); | |
} catch (Exception $e) { | |
print($e->getMessage()); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment