mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-26 01:29:20 +01:00
Lnd rpc docs (#2896)
This commit is contained in:
parent
5abf399e40
commit
b80b039457
4 changed files with 75 additions and 2 deletions
66
docs/rpc/lnd.md
Normal file
66
docs/rpc/lnd.md
Normal file
|
@ -0,0 +1,66 @@
|
|||
---
|
||||
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.
|
||||
|
||||
Currently, this RPC client is written for [v0.12.1](https://github.com/lightningnetwork/lnd/releases/tag/v0.12.1-beta) version of LND.
|
||||
|
||||
## Configuration of LND
|
||||
|
||||
Please see the [sample configuration for LND](https://github.com/lightningnetwork/lnd/blob/v0.12.1-beta/sample-lnd.conf).
|
||||
|
||||
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
|
||||
|
||||
You need to download the binaries from the [LND's github](https://github.com/lightningnetwork/lnd/releases/tag/v0.12.1-beta).
|
||||
|
||||
To run lnd by unzipping the `lnd-linux-amd64-v0.12.1-beta.tar.gz` (or whichever platform you are on) and then running
|
||||
|
||||
```bash
|
||||
$ ./lnd-linux-amd64-v0.12.1-beta/lnd
|
||||
```
|
||||
|
||||
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
|
||||
import akka.actor.ActorSystem
|
||||
import org.bitcoins.lnd.rpc._
|
||||
import org.bitcoins.lnd.rpc.config._
|
||||
import java.nio.file.Paths
|
||||
```
|
||||
|
||||
```scala mdoc:compile-only
|
||||
|
||||
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.12.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](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.
|
|
@ -28,4 +28,4 @@ RPC calls like `getblockheader` we'll even parse the
|
|||
hexadecimal string into a complete header that you can
|
||||
interact with without goofing around with bits and bytes.
|
||||
|
||||
We currently have RPC clients for Bitcoin Core and Eclair.
|
||||
We currently have RPC clients for Bitcoin Core, Eclair, Lnd.
|
||||
|
|
|
@ -116,6 +116,9 @@
|
|||
"rpc/rpc-eclair": {
|
||||
"title": "Eclair"
|
||||
},
|
||||
"rpc/lnd-rpc": {
|
||||
"title": "LND"
|
||||
},
|
||||
"rpc/rpc-clients-intro": {
|
||||
"title": "Introduction"
|
||||
},
|
||||
|
@ -128,6 +131,9 @@
|
|||
"security": {
|
||||
"title": "Security"
|
||||
},
|
||||
"testkit/testkit-core": {
|
||||
"title": "Testkit Core"
|
||||
},
|
||||
"testkit/testkit": {
|
||||
"title": "Testkit"
|
||||
},
|
||||
|
|
|
@ -60,7 +60,8 @@
|
|||
"RPC Clients": [
|
||||
"rpc/rpc-clients-intro",
|
||||
"rpc/rpc-eclair",
|
||||
"rpc/rpc-bitcoind"
|
||||
"rpc/rpc-bitcoind",
|
||||
"rpc/lnd-rpc"
|
||||
],
|
||||
"Secp256k1": [
|
||||
"secp256k1/secp256k1",
|
||||
|
|
Loading…
Add table
Reference in a new issue