Developer Resources
...
API Resources
LND Node API

GRPC API Examples

4min

Prerequisites:

  • Admin Macaroon - The admin macaroon is an authentication token that allows you to interact with your LND node's gRPC API with administrative permissions. You can also grab a "Read Only" macaroon that wont have permissions to spend. You can find your Macaroons in your Voltage Dashboard by visiting Manage Access -> Macaroon Bakery
  • Lightning.proto File - The lightning.proto file is a Protocol Buffers (protobuf) definition file that defines the gRPC service and messages used to interact with an LND node. It specifies the methods available for communication, as well as the structure of the request and response messages. This file is essential for generating the client and server code needed to use the gRPC API. You can download the lightning.proto file from the LND GitHub repository: LND GitHub - lnrpc directory

Interacting With Your Node's LND gRPC API

Here are some code snippets demonstrating how to interact with some of the most common and popular LND API methods using the gRPC API:

JS

JS

JS


This script demonstrates how to make three different API calls to your LND node using the gRPC API:

  • getInfo
    : Retrieves general information about your node.
  • addInvoice
    : Creates a new invoice with a specified amount and optional memo.
  • sendPaymentSync
    : Pays an invoice by providing the payment request and the amount to pay.

Make sure to replace the placeholders in the script with your actual macaroon file path, TLS certificate path, node URL, and the desired invoice details.