Skip to content

Commit 266165a

Browse files
committed
taprpc: allow importing/referencing lnd proto files
This commit allows us to use the gRPC import statement to re-use lnd protobuf definitions. We'll use that to be able to embed lnd RPC messages in some of the new tapchannelrpc calls.
1 parent f72981e commit 266165a

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

taprpc/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ RUN apt-get update && apt-get install -y \
1010
# update them here if we bump the versions.
1111
ARG PROTOBUF_VERSION
1212
ARG GRPC_GATEWAY_VERSION
13+
ARG LND_VERSION
1314

1415
ENV PROTOC_GEN_GO_GRPC_VERSION="v1.1.0"
1516
ENV FALAFEL_VERSION="v0.9.1"
1617
ENV GOCACHE=/tmp/build/.cache
1718
ENV GOMODCACHE=/tmp/build/.modcache
19+
ENV LND_VERSION=${LND_VERSION}
1820

1921
RUN cd /tmp \
2022
&& mkdir -p /tmp/build/.cache \
@@ -25,6 +27,7 @@ RUN cd /tmp \
2527
&& go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@${GRPC_GATEWAY_VERSION} \
2628
&& go install github.com/lightninglabs/falafel@${FALAFEL_VERSION} \
2729
&& go install golang.org/x/tools/cmd/[email protected] \
30+
&& go mod download github.com/lightningnetwork/lnd@${LND_VERSION} \
2831
&& chmod -R 777 /tmp/build/
2932

3033
WORKDIR /build

taprpc/gen_protos.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ tapchannelrpc/tapchannel.proto"
1919

2020
# Generate the protos.
2121
protoc -I/usr/local/include -I. \
22+
-I/tmp/build/.modcache/github.com/lightningnetwork/lnd@${LND_VERSION}/lnrpc \
2223
--go_out . --go_opt paths=source_relative \
2324
--go-grpc_out . --go-grpc_opt paths=source_relative \
2425
"${file}"
2526

2627
# Generate the REST reverse proxy.
2728
annotationsFile=${file//proto/yaml}
2829
protoc -I/usr/local/include -I. \
30+
-I/tmp/build/.modcache/github.com/lightningnetwork/lnd@${LND_VERSION}/lnrpc \
2931
--grpc-gateway_out . \
3032
--grpc-gateway_opt logtostderr=true \
3133
--grpc-gateway_opt paths=source_relative \
@@ -34,6 +36,7 @@ tapchannelrpc/tapchannel.proto"
3436

3537
# Generate the swagger file which describes the REST API in detail.
3638
protoc -I/usr/local/include -I. \
39+
-I/tmp/build/.modcache/github.com/lightningnetwork/lnd@${LND_VERSION}/lnrpc \
3740
--openapiv2_out . \
3841
--openapiv2_opt logtostderr=true \
3942
--openapiv2_opt grpc_api_configuration=${annotationsFile} \
@@ -46,6 +49,7 @@ tapchannelrpc/tapchannel.proto"
4649
pkg="taprpc"
4750
opts="package_name=$pkg,js_stubs=1"
4851
protoc -I/usr/local/include -I. -I.. \
52+
-I/tmp/build/.modcache/github.com/lightningnetwork/lnd@${LND_VERSION}/lnrpc \
4953
--plugin=protoc-gen-custom=$falafel\
5054
--custom_out=. \
5155
--custom_opt="$opts" \
@@ -58,6 +62,7 @@ tapchannelrpc/tapchannel.proto"
5862
opts="package_name=$package,manual_import=$manual_import,js_stubs=1"
5963
pushd $package
6064
protoc -I/usr/local/include -I. -I.. \
65+
-I/tmp/build/.modcache/github.com/lightningnetwork/lnd@${LND_VERSION}/lnrpc \
6166
--plugin=protoc-gen-custom=$falafel\
6267
--custom_out=. \
6368
--custom_opt="$opts" \

taprpc/gen_protos_docker.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
77

88
PROTOBUF_VERSION=$(go list -f '{{.Version}}' -m google.golang.org/protobuf)
99
GRPC_GATEWAY_VERSION=$(go list -f '{{.Version}}' -m github.com/grpc-ecosystem/grpc-gateway/v2)
10+
LND_VERSION=$(go list -f '{{.Version}}' -m github.com/lightningnetwork/lnd)
1011

1112
echo "Building protobuf compiler docker image..."
1213
docker build -t taproot-assets-protobuf-builder \
1314
--build-arg PROTOBUF_VERSION="$PROTOBUF_VERSION" \
1415
--build-arg GRPC_GATEWAY_VERSION="$GRPC_GATEWAY_VERSION" \
16+
--build-arg LND_VERSION="$LND_VERSION" \
1517
.
1618

1719
echo "Compiling and formatting *.proto files..."

0 commit comments

Comments
 (0)