multi: add script to connect to nodes in flagship dockerfile

This commit is contained in:
Carla Kirk-Cohen 2024-04-10 17:12:40 -04:00
parent 2f49b06152
commit d750de876c
No known key found for this signature in database
GPG Key ID: 4CA7FE54A6213C91
3 changed files with 28 additions and 0 deletions

View File

@ -101,6 +101,8 @@ The following utilities are available for your convenience:
* `source ./lncli.sh` provides aliases for your LND nodes (`lncli0`,
`lncli1`, `lncli2`)
* `./fund.sh` funds each of your LND nodes.
* `./connect_nodes.sh` connects the attacking nodes to the network
so that they can sync gossip.
* `bitcoin-cli` provides access to the bitcoin node that all three
LND nodes are connected to.

View File

@ -41,5 +41,8 @@ COPY lncli.sh /lncli.sh
COPY fund.sh /fund.sh
RUN chmod +x fund.sh
COPY connect_nodes.sh /connect_nodes.sh
RUN chmod +x connect_nodes.sh
# Set entrypoint to just sleep indefinitely - attackers will run their own scripts.
ENTRYPOINT ["bash", "-c", "while true; do sleep 30; done;"]

23
setup/connect_nodes.sh Normal file
View File

@ -0,0 +1,23 @@
#!/bin/bash
# Path to the nodes.txt file
nodes_file="credentials/nodes.txt"
# Check if nodes.txt exists
if [ ! -f "$nodes_file" ]; then
echo "Error: nodes.txt file not found."
exit 1
fi
lncli0="lncli --network=regtest --tlscertpath=/credentials/lnd0-tls.cert --macaroonpath=/credentials/lnd0-admin.macaroon --rpcserver=lightning-0.warnet-armada "
lncli1="lncli --network=regtest --tlscertpath=/credentials/lnd1-tls.cert --macaroonpath=/credentials/lnd1-admin.macaroon --rpcserver=lightning-1.warnet-armada "
lncli2="lncli --network=regtest --tlscertpath=/credentials/lnd2-tls.cert --macaroonpath=/credentials/lnd2-admin.macaroon --rpcserver=lightning-2.warnet-armada "
# Iterate through each line in nodes.txt
while IFS= read -r line; do
echo "Connecting nodes to $line"
# Call lncli connect with the extracted string
$lncli0 connect "$line"
$lncli1 connect "$line"
$lncli2 connect "$line"
done < "$nodes_file"