bitcoin-s/docs/rpc/lnd.md
2021-07-21 15:19:32 -05:00

2.6 KiB

id title
lnd-rpc LND

This is an RPC client for LND. It assumes that a bitcoind instance is running.

Currently, this RPC client is written for v0.13.1 version of LND.

Configuration of LND

Please see the sample configuration for LND.

You can find the configuration we use for our testing infrastructure for lnd here.

Starting LND

You need to download the binaries from the LND's github.

To run lnd by unzipping the lnd-linux-amd64-v0.13.1-beta.tar.gz (or whichever platform you are on) and then running

$ ./lnd-linux-amd64-v0.13.1-beta/lnd

If you wish to start lnd from the RPC client, you can construct a LndRpcClient.binary field set

We will default to using the binary field first when trying to start the jar, and the fallback to the default datadir (~/.lnd).

Here is an example of how to start lnd:

import akka.actor.ActorSystem
import org.bitcoins.lnd.rpc._
import org.bitcoins.lnd.rpc.config._
import java.nio.file.Paths

implicit val system = ActorSystem(s"lnd-rpc-${System.currentTimeMillis}")
implicit val ec = system.dispatcher

val datadirPath = Paths.get("path", "to", "datadir")
val binaryPath = Paths.get("path", "to", "lnd-linux-amd64-v0.13.1-beta", "lnd")
val instance = LndInstance.fromDataDir(datadirPath.toFile)
val client = new LndRpcClient(instance, Some(binaryPath.toFile))

val startedF = client.start()

for {
  lnd <- startedF
  info <- lnd.getInfo
} yield {
  println(s"Lnd info: $info")
}

Updating to a new LND version

The lnd rpc module uses lnd's gRPC. This means when updating to the latest version, the .proto files will need to be updated. Bitcoin-S stores them in lnd-rpc/src/main/protobuf. You can find the files to copy from LND here.

After updating the proto files you can run sbt compile and this will generate the corresponding class files, this should then give compile warnings for changed rpc functions.