@radar/lnrpc

A Typescript gRPC client for LND with support for all LND sub-servers.

CircleCI Known Vulnerabilities NPM Version License

Originally forked from Matt-Jensen/lnrpc.

Features

  • Auto-generates lnd/lnrpc clients and Typescript type definitions using a target release tag

  • Supports all LND sub-servers

  • Wraps requests in promises

  • Easily setup SSL and Macaroons

  • Instantiates all gRPC services

  • uint64/int64 types cast to string to prevent precision loss

Installation

npm install @radar/lnrpc
# OR
yarn add @radar/lnrpc

Notes:

  • Ensure you have an lnd instance running with --no-macaroons, unless you provide macaroon authentication to your lnrpc instance when created.

  • If you want to interact with the LND sub-servers, ensure that LND was compiled with the necessary sub-server build tags.

  • If the following error is thrown in the consuming application, run npm rebuild:

Usage

This package exports a create function for the main gRPC server as well as each sub-server:

You can also import the create function for the main gRPC server using the default import:

If you want to interact with all servers, wrap the functions in a class or object for easy initialization:

Usage Example - Main Server

Connecting to an lnd instance at localhost:10001.

Options Example - Main Server

API Reference

All main server (lnrpc) methods documentation can be found here.

Usage With BTCPayServer

By default lnrpc assumes SSl certificate pinning. In order to use lnrpc with a service (like BTCPayServer) which manages your certification, you'll have to opt to disable certificate pinning by passing { tls: false } within your lnrpc configuration.

Contributing

Clone Repository & Install Dependencies

Change LND gRPC release version

To change the gRPC definitions used for all auto-generated types and RPC methods edit the config.lnd_release_tag value in package.json to the desired LND release tag and run the following:

Newly generated type definitions will be available in ./generated. You can now delete the old proto file inside the lnd directory. Use the generated type definitions to update the types in src/types/rpc.

License

This project is licensed under the MIT License.

Last updated

Was this helpful?