Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ djangorestframework==3.16.1
channels==4.2.2
channels-redis==4.2.1
celery==5.5.3
grpcio==1.67.0
grpcio==1.81.0
googleapis-common-protos==1.70.0
grpcio-tools==1.67.0
grpcio-tools==1.81.0
numpy==1.26.4
Pillow==12.1.1
python-decouple==3.8
Expand Down
32 changes: 14 additions & 18 deletions scripts/generate_grpc.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
set -eu

# generate LND grpc definitions
cd api/lightning
Expand All @@ -14,33 +15,28 @@ curl --parallel -o lightning.proto https://raw.githubusercontent.com/lightningne
-o primitives.proto https://raw.githubusercontent.com/ElementsProject/lightning/v24.08/cln-grpc/proto/primitives.proto \
-o node.proto https://raw.githubusercontent.com/ElementsProject/lightning/v24.08/cln-grpc/proto/node.proto

echo -n "Done\nBuilding api from GRPC specs..."
printf "Done\nBuilding api from GRPC specs..."
python3 -m grpc_tools.protoc --proto_path=googleapis:. --python_out=. --grpc_python_out=. lightning.proto invoices.proto router.proto signer.proto verrpc.proto
python3 -m grpc_tools.protoc --proto_path=. --python_out=. --grpc_python_out=. node.proto hold.proto primitives.proto

# patch generated files relative imports
# LND
sed -i 's/^import .*_pb2 as/from . \0/' router_pb2.py
sed -i 's/^import .*_pb2 as/from . \0/' signer_pb2.py
sed -i 's/^import .*_pb2 as/from . \0/' invoices_pb2.py
sed -i 's/^import .*_pb2 as/from . \0/' verrpc_pb2.py
sed -i 's/^import .*_pb2 as/from . \0/' router_pb2_grpc.py
sed -i 's/^import .*_pb2 as/from . \0/' signer_pb2_grpc.py
sed -i 's/^import .*_pb2 as/from . \0/' lightning_pb2_grpc.py
sed -i 's/^import .*_pb2 as/from . \0/' invoices_pb2_grpc.py
sed -i 's/^import .*_pb2 as/from . \0/' verrpc_pb2_grpc.py
python3 <<'PY'
from pathlib import Path

# CLN
sed -i 's/^import .*_pb2 as/from . \0/' hold_pb2.py
sed -i 's/^import .*_pb2 as/from . \0/' hold_pb2_grpc.py
sed -i 's/^import .*_pb2 as/from . \0/' node_pb2.py
sed -i 's/^import .*_pb2 as/from . \0/' node_pb2_grpc.py
for path in Path(".").glob("*_pb2*.py"):
lines = path.read_text().splitlines()
patched = [
f"from . {line}" if line.startswith("import ") and "_pb2 as " in line else line
for line in lines
]
path.write_text("\n".join(patched) + "\n")
PY

echo -n "Done\nDeleting googleapi..."
printf "Done\nDeleting googleapi..."
rm -rf googleapis # delete googleapis
echo "Done"

# On development environments the local volume will be mounted over these files. We copy pb2 and grpc files to /tmp/.
# This way, we can find if these files are missing with our entrypoint.sh and copy them into the volume.
cp -r *_pb2.py /tmp/
cp -r *_grpc.py /tmp/
cp -r *_grpc.py /tmp/