8000 GitHub - torkelrogstad/lnd-async: Lightning Network Daemon gRPC async client
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

torkelrogstad/lnd-async

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lnd-async

This 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.

This library supports LND version 0.4.2-beta.

The 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.

To establish a connection to gRPC localhost:10009 with macaroons:

const lnd = require('lnd-async');

async function getInfo() {
  let client = await lnd.connect();
  return await client.getInfo({});
}

This call can be customized to meet your specific needs:

const lnd = require('lnd-async');

async function getInfo() {
  let client = await lnd.connect({
    lndHost: '10.10.0.12',
    lndPort: 10019,
    certPath: __dirname + '/tls.cert',
    macaroonPath: __dirname + '/admin.macaroon',
  });
  return await client.getInfo({});
}

You can also specify cert and macaroon as base64 encoded string. Usefull if you do not want to keep them on the server.

const lnd = require('lnd-async');

async function getInfo() {
  let client = await lnd.connect({
    lndHost: '10.10.0.12',
    lndPort: 10019,
    cert: 'base64 cert',
    macaroon: 'base64 macaroon',
  });
  return await client.getInfo({});
}

You can also initiate calls with no macaroons by passing the noMacaroons flag. When this option is supplied, the macaroonPath is ignored.

const lnd = require('lnd-async');

async function getInfo() {
  let client = await lnd.connect({ noMacaroons: true });
  return await client.getInfo({});
}

TypeScript

This library includes type definitions for TypeScript. These definitions are for the most part generated from lib/rpc.proto, with some manual tweaks on top. This means that there might be errors in the typings, particularely on returns values there an event stream is returned (openChannel, sendPayment and others).

The types (which were later manually modified) were generated using pbjs, with the following command:

pbjs --keep-case \
  -t static-module lib/rpc.proto \
  --wrap commonjs \
  --no-convert \
  --no-decode \
  --no-verify \
  --no-encode \
  --no-create \
  | pbts --out lib/lnd-async.d.ts \
  --name \"lnd-async\" -

Versions

  • 1.4.0 - Support for base64 macaroon and cert files
  • 1.3.0 - Support for 0.4.2-beta
  • 1.2.0 - Support for 0.4.1-beta
  • 1.1.0 - Support for 0.4.0-beta

About

Lightning Network Daemon gRPC async client

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%
0