{"id":15021737,"url":"https://github.com/altangent/lnd-async","last_synced_at":"2025-04-10T19:42:54.841Z","repository":{"id":28518951,"uuid":"118611901","full_name":"altangent/lnd-async","owner":"altangent","description":"Lightning Network Daemon gRPC async client","archived":false,"fork":false,"pushed_at":"2025-04-07T12:13:28.000Z","size":516,"stargazers_count":21,"open_issues_count":7,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-07T13:26:05.131Z","etag":null,"topics":["bitcoin","grpc","lightning-network","lnd"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/altangent.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-23T13:10:34.000Z","updated_at":"2025-04-07T12:13:32.000Z","dependencies_parsed_at":"2023-01-14T08:58:40.040Z","dependency_job_id":"f31f33d0-ba9f-433b-9d97-86c13f24333e","html_url":"https://github.com/altangent/lnd-async","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altangent%2Flnd-async","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altangent%2Flnd-async/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altangent%2Flnd-async/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altangent%2Flnd-async/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/altangent","download_url":"https://codeload.github.com/altangent/lnd-async/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247660225,"owners_count":20974846,"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":["bitcoin","grpc","lightning-network","lnd"],"created_at":"2024-09-24T19:56:57.890Z","updated_at":"2025-04-10T19:42:54.832Z","avatar_url":"https://github.com/altangent.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lnd-async\n\nThis library simplifies connecting to the Bitcoin Lightning Network Daemon via gRPC. It wraps all callback functions in promises to make api calls easier to work with.\n\nThis library supports LND version 0.17.0-beta.\n\nThe default behavior assumes LND is running on `localhost` port `10009`. It also assumes that macaroons are enabled and the `tls.cert` and `admin.macaroon` are found in the OS specific default data paths.\n\nTo establish a connection to gRPC `localhost:10009` with macaroons:\n\n```javascript\nconst lnd = require('lnd-async');\n\nasync function getInfo() {\n  let client = await lnd.connect();\n  return await client.getInfo({});\n}\n```\n\nThis call can be customized to meet your specific needs:\n\n```javascript\nconst lnd = require('lnd-async');\n\nasync function getInfo() {\n  let client = await lnd.connect({\n    lndHost: '10.10.0.12',\n    lndPort: 10019,\n    certPath: __dirname + '/tls.cert',\n    macaroonPath: __dirname + '/admin.macaroon',\n  });\n  return await client.getInfo({});\n}\n```\n\nYou can also specify `cert` and `macaroon` as base64 encoded string. Usefull if you do not want to keep them on the server. To do this you can do it buy commands like `base64 -w 0 /path/to/lnd/data/tls.cert; echo` for `cert` or `base64 -w 0 /path/to/lnd/data/admin.macaroon; echo` for `macaroon`.\n\n```javascript\nconst lnd = require('lnd-async');\n\nasync function getInfo() {\n  let client = await lnd.connect({\n    lndHost: '10.10.0.12',\n    lndPort: 10019,\n    cert: 'base64 cert',\n    macaroon: 'base64 macaroon',\n  });\n  return await client.getInfo({});\n}\n```\n\nYou can also initiate calls with no macaroons by passing the `noMacaroons` flag. When this option is supplied, the `macaroonPath` is ignored.\n\n```javascript\nconst lnd = require('lnd-async');\n\nasync function getInfo() {\n  let client = await lnd.connect({ noMacaroons: true });\n  return await client.getInfo({});\n}\n```\n\n### How work with services\n\nBy default the `lnd-async` uses `Lightning` service but you can call certain methods of other services:\n\n```javascript\n// The \"Invoices\" service for example:\nawait client.Invoices.settleInvoice({preimage})\n\n// The default \"Lightning\" service:\nawait client.connectPeer({addr: {pubkey, host}, perm: false})\n\n// The stream method:\nconst grpc = require('grpc')\nlet stream = client.Invoices.subscribeSingleInvoice({r_hash: hash})\n\nstream.on('data', async data =\u003e {\n    try {\n        if (data.state === 'ACCEPTED' \u0026\u0026 accepted) {\n            await accepted()\n        }\n        else if (data.state === 'SETTLED' \u0026\u0026 settled) {\n            await settled()\n            stream.cancel()\n        }\n        else if (data.state === 'CANCELED' \u0026\u0026 canceled) {\n            await canceled()\n            stream.cancel()\n        }\n    }\n    catch (e) {\n        console.error('error in data event of stream: %s', e.message)\n    }\n})\nstream.on('error', (e) =\u003e {\n    // If e.code === grpc.status.CANCELLED - it's normal cancel state of stream\n    if (e.code !== grpc.status.CANCELLED) {\n        error(e)\n    }\n})\n\n```\n\n### Long integer treatment\n\nThe JavaScript Number type internally stores values as IEEE 754 floating point values. The max safe integer value is 2^53-1 which can result in data loss for 64-bit integers.\n\n**By default and for maximum portability, long values are returned as strings.** This allows the consumer of the data to convert the long integers using any big number library they prefer.\n\n`grpc-node` has [accomodations](https://github.com/dcodeIO/protobuf.js/blob/master/README.md#compatibility) for automatic number type conversion to [`Long.js`](https://github.com/dcodeIO/long.js). If you do not install `Long.js`, longs will be treated as JavaScript `Number` type and data loss may occur.\n\n`lnd-async` allows customization of this handling via the setting `longsAsNumbers`. Setting this value to `true` will pass the `Number` setting in `grpc-node`. By default, this value is set to false to prevent data loss.\n\n```javascript\nconst lnd = require('lnd-async');\n\nasync function getInfo() {\n  let client = await lnd.connect({ longsAsNumbers: true });\n  return await client.getInfo({});\n}\n```\n\n## Versions\n\n- 4.2.3 - Updated the protocol in accordance with LND v0.18.5-beta\n- 4.2.2 - Updated the protocol in accordance with LND v0.18.0-beta\n- 4.2.1 - Updated the protocol in accordance with LND v0.17.0-beta\n- 4.2.0 - Updated the protocol in accordance with LND v0.16.2-beta,\n          Mocha-based tests can be run with any parameters in the developer's .env file,\n          Bugs have been fixed based on the tests,\n          Updated dependencies to new ones with no known vulnerabilities\n- 4.1.3 - Updated for v0.13.1-beta, all proto services + the update of doc\n- 4.1.0 - Updated for v0.11.1-beta, now includes all proto services\n- 4.0.0 - Updated for 0.8.1-beta, now includes all proto services\n- 3.0.0 - Support for 0.8.0-beta\n- 2.0.0 - Support for 0.7.1-beta, switching to valid SEMVER release format\n- 1.8.0 - Support for 0.6.1-beta\n- 1.7.0 - Add `longsAsNumbers` option\n- 1.6.0 - Support for 0.5.2-beta\n- 1.5.0 - Support for 0.5-beta\n- 1.4.0 - Support for base64 macaroon and cert files\n- 1.3.0 - Support for 0.4.2-beta\n- 1.2.0 - Support for 0.4.1-beta\n- 1.1.0 - Support for 0.4.0-beta\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faltangent%2Flnd-async","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faltangent%2Flnd-async","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faltangent%2Flnd-async/lists"}