2022-08-12 16:29:27 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2023-05-22 14:56:15 +00:00
|
|
|
# generate LND grpc definitions
|
2022-08-12 16:29:27 +00:00
|
|
|
cd api/lightning
|
2024-01-22 09:13:48 +00:00
|
|
|
[ -d googleapis ] || git clone https://github.com/googleapis/googleapis.git --depth=1 googleapis
|
|
|
|
|
|
|
|
echo "Downloading LND & CLN GRPC specs.."
|
|
|
|
curl --parallel -o lightning.proto https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/lightning.proto \
|
|
|
|
-o invoices.proto https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/invoicesrpc/invoices.proto \
|
|
|
|
-o router.proto https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/routerrpc/router.proto \
|
|
|
|
-o signer.proto https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/signrpc/signer.proto \
|
|
|
|
-o verrpc.proto https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/verrpc/verrpc.proto \
|
2024-06-17 21:33:49 +00:00
|
|
|
-o hold.proto https://raw.githubusercontent.com/daywalker90/holdinvoice/master/proto/hold.proto \
|
|
|
|
-o primitives.proto https://raw.githubusercontent.com/ElementsProject/lightning/v24.05/cln-grpc/proto/primitives.proto \
|
|
|
|
-o node.proto https://raw.githubusercontent.com/ElementsProject/lightning/v24.05/cln-grpc/proto/node.proto
|
2024-01-22 09:13:48 +00:00
|
|
|
|
|
|
|
echo -n "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
|
2023-09-06 15:18:22 +00:00
|
|
|
python3 -m grpc_tools.protoc --proto_path=. --python_out=. --grpc_python_out=. node.proto hold.proto primitives.proto
|
2023-05-22 14:56:15 +00:00
|
|
|
|
2022-08-12 16:29:27 +00:00
|
|
|
# patch generated files relative imports
|
2023-05-22 14:56:15 +00:00
|
|
|
# LND
|
2022-08-12 16:29:27 +00:00
|
|
|
sed -i 's/^import .*_pb2 as/from . \0/' router_pb2.py
|
2023-05-16 17:12:15 +00:00
|
|
|
sed -i 's/^import .*_pb2 as/from . \0/' signer_pb2.py
|
2022-08-12 16:29:27 +00:00
|
|
|
sed -i 's/^import .*_pb2 as/from . \0/' invoices_pb2.py
|
2023-04-22 18:54:03 +00:00
|
|
|
sed -i 's/^import .*_pb2 as/from . \0/' verrpc_pb2.py
|
2022-08-12 16:29:27 +00:00
|
|
|
sed -i 's/^import .*_pb2 as/from . \0/' router_pb2_grpc.py
|
2023-05-16 17:12:15 +00:00
|
|
|
sed -i 's/^import .*_pb2 as/from . \0/' signer_pb2_grpc.py
|
2022-08-12 16:29:27 +00:00
|
|
|
sed -i 's/^import .*_pb2 as/from . \0/' lightning_pb2_grpc.py
|
|
|
|
sed -i 's/^import .*_pb2 as/from . \0/' invoices_pb2_grpc.py
|
2023-05-15 09:46:59 +00:00
|
|
|
sed -i 's/^import .*_pb2 as/from . \0/' verrpc_pb2_grpc.py
|
|
|
|
|
2023-05-22 14:56:15 +00:00
|
|
|
# CLN
|
2023-09-06 15:18:22 +00:00
|
|
|
sed -i 's/^import .*_pb2 as/from . \0/' hold_pb2.py
|
|
|
|
sed -i 's/^import .*_pb2 as/from . \0/' hold_pb2_grpc.py
|
2023-05-22 14:56:15 +00:00
|
|
|
sed -i 's/^import .*_pb2 as/from . \0/' node_pb2.py
|
|
|
|
sed -i 's/^import .*_pb2 as/from . \0/' node_pb2_grpc.py
|
|
|
|
|
2024-01-22 09:13:48 +00:00
|
|
|
echo -n "Done\nDeleting googleapi..."
|
|
|
|
rm -rf googleapis # delete googleapis
|
|
|
|
echo "Done"
|
|
|
|
|
2023-05-15 09:46:59 +00:00
|
|
|
# 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/
|
2024-01-22 09:13:48 +00:00
|
|
|
cp -r *_grpc.py /tmp/
|