2021-04-13 02:09:59 +02:00
---
id: lnd-rpc
title: LND
---
This is an RPC client for [LND ](https://github.com/LightningNetwork/lnd ). It assumes that a bitcoind instance is running.
2024-05-10 19:37:02 +02:00
Currently, this RPC client is written for [v0.17.5 ](https://github.com/lightningnetwork/lnd/releases/tag/v0.17.3-beta ) version of LND.
2021-04-13 02:09:59 +02:00
## Configuration of LND
2024-01-27 18:28:25 +01:00
Please see the [sample configuration for LND ](https://github.com/lightningnetwork/lnd/blob/v0.17.3-beta/sample-lnd.conf ).
2021-04-13 02:09:59 +02:00
You can find the configuration we use for our testing infrastructure for lnd [here ](https://github.com/bitcoin-s/bitcoin-s/blob/656e0928bf1bf4f511f60dec625699b454f29a1f/testkit/src/main/scala/org/bitcoins/testkit/lnd/LndRpcTestUtil.scala#L90 ).
## Starting LND
2024-01-27 18:28:25 +01:00
You need to download the binaries from the [LND's github ](https://github.com/lightningnetwork/lnd/releases/tag/v0.17.3-beta ).
2021-04-13 02:09:59 +02:00
2024-05-10 19:37:02 +02:00
To run lnd by unzipping the `lnd-linux-amd64-v0.17.5-beta.tar.gz` (or whichever platform you are on) and then running
2021-04-13 02:09:59 +02:00
```bash
2024-01-27 18:28:25 +01:00
$ ./lnd-linux-amd64-v0.17.3-beta/lnd
2021-04-13 02:09:59 +02:00
```
If you wish to start lnd from the RPC client, you can construct a [`LndRpcClient.binary` ](https://github.com/bitcoin-s/bitcoin-s/blob/656e0928bf1bf4f511f60dec625699b454f29a1f/lnd-rpc/src/main/scala/org/bitcoins/lnd/rpc/LndRpcClient.scala#L35 ) 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:
```scala mdoc:invisible
2024-02-22 17:26:21 +01:00
import org.apache.pekko.actor.ActorSystem
2021-04-13 02:09:59 +02:00
import org.bitcoins.lnd.rpc._
import org.bitcoins.lnd.rpc.config._
import java.nio.file.Paths
2024-05-10 19:37:02 +02:00
import scala.concurrent.ExecutionContext
2021-04-13 02:09:59 +02:00
```
```scala mdoc:compile-only
2024-05-10 19:37:02 +02:00
implicit val system: ActorSystem = ActorSystem(s"lnd-rpc-${System.currentTimeMillis}")
implicit val ec: ExecutionContext = system.dispatcher
2021-04-13 02:09:59 +02:00
val datadirPath = Paths.get("path", "to", "datadir")
2024-05-10 19:37:02 +02:00
val binaryPath = Paths.get("path", "to", "lnd-linux-amd64-v0.17.5-beta", "lnd")
2021-09-07 15:49:01 +02:00
val instance = LndInstanceLocal.fromDataDir(datadirPath.toFile)
2021-04-13 02:09:59 +02:00
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 ](https://github.com/bitcoin-s/bitcoin-s/tree/master/lnd-rpc/src/main/protobuf ).
You can find the files to copy from LND [here ](https://github.com/lightningnetwork/lnd/tree/master/lnrpc ).
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.