docs+lnrpc: rename rpc.proto to lightning.proto

To avoid a naming conflict with etcd, we rename our very generic
rpc.proto to lightning.proto to match the service name that's declared
within. This will break many external tutorials and possibly also our
API docs but the change needs to be done eventually.
This commit is contained in:
Oliver Gugger
2021-07-27 12:59:56 +02:00
parent 62888894d2
commit 235efc04e4
20 changed files with 4241 additions and 4240 deletions

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>
```

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";

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'

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

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"