Last active
January 23, 2019 05:25
-
-
Save mariodian/301a3e96cd017744defed359b738a13a to your computer and use it in GitHub Desktop.
Connect to peers that you have open channels with.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
jq --help >/dev/null 2>&1 || { echo >&2 "Error: 'jq' is required but not installed."; exit 1; } | |
LIST=$(lncli listchannels | jq -r '.[]') | |
LENGTH=$(echo $LIST | jq 'length') | |
for (( i=0; i<$LENGTH; i++ )); | |
do | |
NODE_PUBKEY=$(echo $LIST | jq ".[$i].remote_pubkey" | tr -d '"') | |
NODE=$(lncli getnodeinfo $NODE_PUBKEY | jq -r '.node') | |
NODE_ADDRESS=$(echo $NODE | jq -r '.addresses[0].addr') | |
if [[ $(lncli listpeers | grep -c $NODE_PUBKEY) -eq 0 ]] && [ "$NODE_ADDRESS" != "null" ] && [[ ! "$NODE_ADDRESS" =~ .*onion.* ]]; | |
then | |
echo "Connecting to $(echo $NODE | jq '.alias') ($NODE_PUBKEY)" | |
lncli connect --perm $NODE_PUBKEY@$NODE_ADDRESS | |
echo "" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment