How to use the lnd-grpc.getClosestProtoVersion function in lnd-grpc

To help you get started, we’ve selected a few lnd-grpc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LN-Zap / zap-desktop / services / grpc / lightning / lightning.js View on Github external
async onBeforeConnect() {
    // Establish a connection.
    const { useMacaroon, waitForMacaroon } = this._getConnectionSettings()
    await this.establishConnection({ useMacaroon, waitForMacaroon })

    // Once connected, make a call to getInfo in order to determine the api version.
    const info = await this.getInfo()
    grpcLog.info('Connected to Lightning gRPC:', info)

    // Determine most relevant proto version and reconnect using the right rpc.proto if we need to.
    const { protoPath } = this.lndConfig
    const [closestProtoVersion, latestProtoVersion] = await Promise.all([
      lndgrpc.getClosestProtoVersion(info.version, { path: protoPath }),
      lndgrpc.getLatestProtoVersion({ path: protoPath }),
    ])
    if (closestProtoVersion !== latestProtoVersion) {
      grpcLog.info(
        'Found better match. Reconnecting using rpc.proto version: %s',
        closestProtoVersion
      )
      this.service.close()
      await this.establishConnection({
        version: closestProtoVersion,
        useMacaroon,
        waitForMacaroon,
      })
    }
  }

lnd-grpc

Repository of lnd rpc protocol files and utilities for working with them

MIT
Latest version published 1 year ago

Package Health Score

39 / 100
Full package analysis