Merge pull request #5473 from guggero/grpc-gateway-update

maintenance: update etcd and grpc-gateway libraries, rename rpc.proto to lightning.proto
This commit is contained in:
Oliver Gugger authored and GitHub committed 2021-07-27 16:11:48 +02:00
commit c3962528e2
107 files changed
+14306 -13096

No files matched your search

-6
View File
@@ -433,12 +433,6 @@ _exact same_ version of `protoc`. As of the writing of this article, the `lnd`
project uses [v3.4.0](https://github.com/google/protobuf/releases/tag/v3.4.0)
of `protoc`.
The following two libraries must be installed with the exact commit hash as
described in [lnrpc README](https://github.com/lightningnetwork/lnd/blob/master/lnrpc/README.md)
otherwise the CI pipeline on Travis will fail:
- grpc-ecosystem/grpc-gateway
- golang/protobuf
For detailed instructions on how to compile modifications to `lnd`'s `protobuf`
definitions, check out the [lnrpc README](https://github.com/lightningnetwork/lnd/blob/master/lnrpc/README.md).
+3 -3
View File
@@ -23,7 +23,7 @@ Create a folder `Grpc` in the root of your project and fetch the lnd proto files
```shell
⛰ mkdir Grpc
⛰ curl -o Grpc/rpc.proto -s https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/rpc.proto
⛰ curl -o Grpc/lightning.proto -s https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/lightning.proto
```
Install `Grpc.Tools`, `Google.Protobuf`, `Grpc.Core` using NuGet or manually with `dotnet add`:
@@ -34,11 +34,11 @@ Install `Grpc.Tools`, `Google.Protobuf`, `Grpc.Core` using NuGet or manually wit
⛰ dotnet add package Grpc.Core
```
Add the `rpc.proto` file to the `.csproj` file in an ItemGroup. (In Visual Studio you can do this by unloading the project, editing the `.csproj` file and then reloading it)
Add the `lightning.proto` file to the `.csproj` file in an ItemGroup. (In Visual Studio you can do this by unloading the project, editing the `.csproj` file and then reloading it)
```xml
<ItemGroup>
<Protobuf Include="Grpc\rpc.proto" GrpcServices="Client" />
<Protobuf Include="Grpc\lightning.proto" GrpcServices="Client" />
</ItemGroup>
```
+2 -2
View File
@@ -24,7 +24,7 @@ with lnd in Java. We'll be using Maven as our build tool.
│ ├── annotations.proto
│ └── http.proto
└── lnrpc
└── rpc.proto
└── lightning.proto
```
Note the ***proto*** folder, where all the proto files are kept.
@@ -233,7 +233,7 @@ Execute the following command in the directory where the **pom.xml** file is loc
### Java proto options
There are 2 options available that can be used in the *rpc.proto* file :
There are 2 options available that can be used in the *lightning.proto* file :
* option java_multiple_files = true;
* option java_package = "network.lightning.rpc";
+7 -7
View File
@@ -13,16 +13,16 @@ dependencies:
npm install grpc @grpc/proto-loader --save
```
You also need to copy the `lnd` `rpc.proto` file in your project directory (or
at least somewhere reachable by your Javascript code).
You also need to copy the `lnd` `lightning.proto` file in your project directory
(or at least somewhere reachable by your Javascript code).
The `rpc.proto` file is [located in the `lnrpc` directory of the `lnd`
sources](https://github.com/lightningnetwork/lnd/blob/master/lnrpc/rpc.proto).
The `lightning.proto` file is [located in the `lnrpc` directory of the `lnd`
sources](https://github.com/lightningnetwork/lnd/blob/master/lnrpc/lightning.proto).
### Imports and Client
Every time you work with Javascript gRPC, you will have to import `grpc`, load
`rpc.proto`, and create a connection to your client like so:
`lightning.proto`, and create a connection to your client like so:
```js
const grpc = require('grpc');
@@ -43,7 +43,7 @@ const loaderOptions = {
defaults: true,
oneofs: true
};
const packageDefinition = protoLoader.loadSync('rpc.proto', loaderOptions);
const packageDefinition = protoLoader.loadSync('lightning.proto', loaderOptions);
// Lnd cert is at ~/.lnd/tls.cert on Linux and
// ~/Library/Application Support/Lnd/tls.cert on Mac
@@ -192,7 +192,7 @@ const loaderOptions = {
defaults: true,
oneofs: true
};
const packageDefinition = protoLoader.loadSync('rpc.proto', loaderOptions);
const packageDefinition = protoLoader.loadSync('lightning.proto', loaderOptions);
process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA'
+9 -9
View File
@@ -27,20 +27,20 @@ file in Python before you can use it to communicate with lnd.
```shell
lnd ⛰ git clone https://github.com/googleapis/googleapis.git
```
5. Copy the lnd rpc.proto file (you'll find this at
[lnrpc/rpc.proto](https://github.com/lightningnetwork/lnd/blob/master/lnrpc/rpc.proto))
5. Copy the lnd lightning.proto file (you'll find this at
[lnrpc/lightning.proto](https://github.com/lightningnetwork/lnd/blob/master/lnrpc/lightning.proto))
or just download it
```shell
lnd ⛰ curl -o rpc.proto -s https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/rpc.proto
lnd ⛰ curl -o lightning.proto -s https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/lightning.proto
```
6. Compile the proto file
```shell
lnd ⛰ python -m grpc_tools.protoc --proto_path=googleapis:. --python_out=. --grpc_python_out=. rpc.proto
lnd ⛰ python -m grpc_tools.protoc --proto_path=googleapis:. --python_out=. --grpc_python_out=. lightning.proto
```
After following these steps, two files `rpc_pb2.py` and `rpc_pb2_grpc.py` will
be generated. These files will be imported in your project anytime you use
Python gRPC.
After following these steps, two files `lightning_pb2.py` and
`lightning_pb2_grpc.py` will be generated. These files will be imported in your
project anytime you use Python gRPC.
### Generating RPC modules for subservers
@@ -63,8 +63,8 @@ Every time you use Python gRPC, you will have to import the generated rpc module
and set up a channel and stub to your connect to your `lnd` node:
```python
import rpc_pb2 as ln
import rpc_pb2_grpc as lnrpc
import lightning_pb2 as ln
import lightning_pb2_grpc as lnrpc
import grpc
import os
+8 -8
View File
@@ -25,28 +25,28 @@ Clone the Google APIs repository:
⛰ git clone https://github.com/googleapis/googleapis.git
```
Fetch the `rpc.proto` file (or copy it from your local source directory):
Fetch the `lightning.proto` file (or copy it from your local source directory):
```shell
⛰ curl -o rpc.proto -s https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/rpc.proto
⛰ curl -o lightning.proto -s https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/lightning.proto
```
Compile the proto file:
```shell
⛰ grpc_tools_ruby_protoc --proto_path googleapis:. --ruby_out=. --grpc_out=. rpc.proto
⛰ grpc_tools_ruby_protoc --proto_path googleapis:. --ruby_out=. --grpc_out=. lightning.proto
```
Two files will be generated in the current directory:
* `rpc_pb.rb`
* `rpc_services_pb.rb`
* `lightning_pb.rb`
* `lightning_services_pb.rb`
### Examples
#### Simple client to display wallet balance
Every time you use the Ruby gRPC you need to require the `rpc_services_pb` file.
Every time you use the Ruby gRPC you need to require the `lightning_services_pb` file.
We assume that `lnd` runs on the default `localhost:10009`.
@@ -58,7 +58,7 @@ We further assume you run `lnd` with `--no-macaroons`.
$:.unshift(File.dirname(__FILE__))
require 'grpc'
require 'rpc_services_pb'
require 'lightning_services_pb'
# Due to updated ECDSA generated tls.cert we need to let gprc know that
# we need to use that cipher suite otherwise there will be a handhsake
@@ -83,7 +83,7 @@ This will show the `total_balance` of the wallet.
$:.unshift(File.dirname(__FILE__))
require 'grpc'
require 'rpc_services_pb'
require 'lightning_services_pb'
ENV['GRPC_SSL_CIPHER_SUITES'] = "HIGH+ECDSA"
+7 -2
View File
@@ -2,8 +2,13 @@
## RPC Server
[Return payment address and add index from
addholdinvoice call](https://github.com/lightningnetwork/lnd/pull/5533).
* [Return payment address and add index from
addholdinvoice call](https://github.com/lightningnetwork/lnd/pull/5533).
* [The versions of several gRPC related libraries were bumped and the main
`rpc.proto` was renamed to
`lightning.proto`](https://github.com/lightningnetwork/lnd/pull/5473) to fix
a warning related to protobuf file name collisions.
# Build System