{"id":13499318,"url":"https://github.com/RadarTech/lnrpc","last_synced_at":"2025-03-29T04:31:04.313Z","repository":{"id":34068319,"uuid":"164516031","full_name":"RadarTech/lnrpc","owner":"RadarTech","description":"A Typescript gRPC client for LND with support for all LND sub-servers","archived":false,"fork":false,"pushed_at":"2023-06-21T14:12:14.000Z","size":809,"stargazers_count":43,"open_issues_count":11,"forks_count":14,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-25T09:14:04.766Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RadarTech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-01-07T23:51:15.000Z","updated_at":"2024-07-28T20:03:23.000Z","dependencies_parsed_at":"2024-01-14T03:51:11.751Z","dependency_job_id":"d976eac6-da75-4574-909d-c35840ac5df3","html_url":"https://github.com/RadarTech/lnrpc","commit_stats":null,"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RadarTech%2Flnrpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RadarTech%2Flnrpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RadarTech%2Flnrpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RadarTech%2Flnrpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RadarTech","download_url":"https://codeload.github.com/RadarTech/lnrpc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246140565,"owners_count":20729797,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T22:00:32.159Z","updated_at":"2025-03-29T04:31:03.863Z","avatar_url":"https://github.com/RadarTech.png","language":"TypeScript","readme":"## @radar/lnrpc\n\n[![CircleCI](https://img.shields.io/circleci/project/github/RadarTech/lnrpc/master.svg?style=flat)](https://circleci.com/gh/RadarTech/lnrpc)\n[![Known Vulnerabilities](https://snyk.io/test/github/RadarTech/lnrpc/badge.svg?targetFile=package.json)](https://snyk.io/test/github/RadarTech/lnrpc?targetFile=package.json)\n[![NPM Version](https://img.shields.io/npm/v/@radar/lnrpc.svg?style=flat)](https://www.npmjs.com/package/@radar/lnrpc)\n[![License](https://img.shields.io/github/license/radartech/lnrpc.svg?style=flat)](https://img.shields.io/github/license/radartech/lnrpc.svg?style=flat)\n\nA Typescript gRPC client for LND with support for all LND sub-servers. Originally forked from [Matt-Jensen/lnrpc](https://github.com/Matt-Jensen/lnrpc).\n\n### Features\n- Auto-generates [lnd/lnrpc](https://github.com/lightningnetwork/lnd/tree/master/lnrpc) clients and Typescript type definitions using a target release tag\n- Supports all LND sub-servers\n- Wraps requests in promises\n- Easily setup SSL and Macaroons\n- Instantiates all gRPC services\n- uint64/int64 types cast to string to prevent precision loss\n\n### Installation\n```sh\nnpm install @radar/lnrpc\n# OR\nyarn add @radar/lnrpc\n```\n\n**Notes:**\n  - Ensure you have an lnd instance running with `--no-macaroons`, unless you provide macaroon authentication to your lnrpc instance when created.\n  - If you want to interact with the LND sub-servers, ensure that LND was compiled with the necessary sub-server build tags.\n  - If the following error is thrown in the consuming application, run `npm rebuild`:\n    ```\n    Error: Failed to load gRPC binary module because it was not installed for the current system\n    ```\n\n### Usage\n\nThis package exports a create function for the main gRPC server as well as each sub-server:\n\n```typescript\nimport {\n  createAutopilotRpc,\n  createChainRpc,\n  createInvoicesRpc,\n  createLnRpc,\n  createRouterRpc,\n  createSignRpc,\n  createWalletRpc,\n  createWatchtowerRpc,\n  createWtClientRpc,\n} from '@radar/lnrpc';\n```\n\nYou can also import the create function for the main gRPC server using the default import:\n\n```typescript\nimport createLnRpc from '@radar/lnrpc';\n```\n\nIf you want to interact with all servers, wrap the functions in a class or object for easy initialization:\n\n```typescript\nimport createLnRpc, {\n  AutopilotRpc,\n  ChainRpc,\n  createAutopilotRpc,\n  createChainRpc,\n  createInvoicesRpc,\n  createRouterRpc,\n  createSignRpc,\n  createWalletRpc,\n  createWatchtowerRpc,\n  createWtClientRpc,\n  InvoicesRpc,\n  LnRpc,\n  RouterRpc,\n  RpcClientConfig,\n  SignRpc,\n  WalletRpc,\n  WatchtowerRpc,\n  WtClientRpc,\n} from '@radar/lnrpc';\n\nexport class Lightning {\n  public static lnrpc: LnRpc;\n  public static autopilotrpc: AutopilotRpc;\n  public static chainrpc: ChainRpc;\n  public static invoicesrpc: InvoicesRpc;\n  public static routerrpc: RouterRpc;\n  public static signrpc: SignRpc;\n  public static walletrpc: WalletRpc;\n  public static watchtowerrpc: WatchtowerRpc;\n  public static wtclientrpc: WtClientRpc;\n\n  /**\n   * Initialize gRPC clients for the main server and all sub-servers\n   * @param config The RPC client connection configuration\n   */\n  public static async init(config: RpcClientConfig): Promise\u003cvoid\u003e {\n    this.lnrpc = await createLnRpc(config);\n    this.autopilotrpc = await createAutopilotRpc(config);\n    this.chainrpc = await createChainRpc(config);\n    this.invoicesrpc = await createInvoicesRpc(config);\n    this.routerrpc = await createRouterRpc(config);\n    this.signrpc = await createSignRpc(config);\n    this.walletrpc = await createWalletRpc(config);\n    this.watchtowerrpc = await createWatchtowerRpc(config);\n    this.wtclientrpc = await createWtClientRpc(config);\n  }\n}\n```\n\n### Usage Example - Main Server\n\nConnecting to an lnd instance at `localhost:10001`.\n\n```typescript\nimport createLnRpc from '@radar/lnrpc';\n\n(async () =\u003e {\n  const lnRpcClient = await createLnRpc(config);\n\n  // All requests are promisified and typed\n  const { confirmedBalance } = await lnRpcClient.walletBalance();\n\n  // ...and you're off!\n  console.log(confirmedBalance);\n\n  // subscribe to LND server events\n  const subscriber = await lnRpcClient.subscribeInvoices();\n  subscriber.on('data', invoice =\u003e {\n    console.log(invoice); // do something with invoice event\n  });\n})();\n```\n\n### Options Example - Main Server\n\n```typescript\nimport createLnRpc from '@radar/lnrpc';\n\n(async () =\u003e {\n  const lnRpcClient = await createLnRpc({\n    /*\n     * By default lnrpc connects to `localhost:10001`,\n     * however we can point to any host.\n     */\n    server: '173.239.209.2:3001',\n\n    /*\n     * By default  lnrpc looks for your tls certificate at:\n     * `~/.lnd/tls.cert`, unless it detects you're using macOS and\n     * defaults to `~/Library/Application\\ Support/Lnd/tls.cert`\n     * however you can configure your own SSL certificate path like:\n     */\n    tls: './path/to/tls.cert',\n\n    /*\n     * You can also provide a TLS certificate directly as a string\n     * (Just make sure you don't commit this to git).\n     * Overwrites: `tls`\n     */\n    cert: process.env.MY_SSL_CERT,\n\n    /*\n     * Optional path to configure macaroon authentication\n     * from LND generated macaroon file.\n     */\n    macaroonPath: './path/to/data/admin.macaroon',\n\n    /*\n     * Optional way to configure macaroon authentication by\n     * passing a hex encoded string of your macaroon file.\n     * Encoding: `xxd -ps -u -c 1000 ./path/to/data/admin.macaroon`\n     * Details: https://github.com/lightningnetwork/lnd/blob/dc3db4b/docs/macaroons.md#using-macaroons-with-grpc-clients\n     */\n    macaroon: process.env.MY_MACAROON_HEX,\n  });\n\n  try {\n    const getInfoResponse = await lnRpcClient.getInfo();\n    console.log(getInfoResponse);\n  } catch (error) {\n    console.error(error);\n  }\n})();\n```\n\n### API Reference\n\n[All main server (lnrpc) methods documentation can be found here](http://api.lightning.community).\n\n### Usage With BTCPayServer\n\nBy default lnrpc assumes SSl certificate pinning.\nIn order to use lnrpc with a service (like BTCPayServer) which manages your certification,\nyou'll have to opt to disable certificate pinning by passing `{ tls: false }` within your lnrpc configuration.\n\n### Contributing\n\n#### Clone Repository \u0026 Install Dependencies\n```sh\ngit clone git@github.com:RadarTech/lnrpc.git \u0026\u0026 cd $_\n\nnpm install\n# OR\nyarn\n```\n\n#### Change LND gRPC release version\nTo 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](https://github.com/lightningnetwork/lnd/releases) and run the following:\n\n```sh\nnpm run update-protos\n# OR\nyarn update-protos\n\n# AND\n\nnpm run generate\n# OR\nyarn generate\n```\nNewly generated type definitions will be available in `./generated`.\nYou can now delete the old proto file inside the lnd directory.\nUse the generated type definitions to update the types in `src/types/rpc`.\nAny added streaming methods must be included in the `subscriptionMethods` array that's into the `createServiceClient` function.\nThis prevents streaming methods from being promisified.\n\n### License\n\nThis project is licensed under the MIT License.\n","funding_links":[],"categories":["Developer Resources"],"sub_categories":["Libraries"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRadarTech%2Flnrpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRadarTech%2Flnrpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRadarTech%2Flnrpc/lists"}