Skip to content

Commit f1a5bdf

Browse files
authored
Merge pull request #21 from ramondevries/main
added command to connect to all peers of the ring of fire.
2 parents d0cafe4 + f688ac4 commit f1a5bdf

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ Test that all nodes are properly connected with this command
6464
./igniter.sh build
6565
```
6666

67+
### Connect to all peers
68+
69+
Test that all peers are up and your node can connect with this command
70+
71+
```bash
72+
./igniter.sh connect
73+
```
74+
6775
### Route the payment
6876

6977
All that's left to do is to execute the script with this command

igniter.sh

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,25 @@ build () {
3535
$LNCLI buildroute --amt ${AMOUNT} --hops ${HOPS} --outgoing_chan_id ${OUTGOING_CHAN_ID}
3636
}
3737

38+
# Arg option: 'connect'
39+
connect () {
40+
IFS=,
41+
PEERS=$($LNCLI listpeers | grep pub_key | tr '"' ' ' | awk '{print $3}')
42+
SELF=$($LNCLI getinfo | grep pubkey | tr '"' ' ' | head -n 1 | awk '{print $3}')
43+
for KEY in $HOPS
44+
do
45+
if [[ "$PEERS" =~ "$KEY" ]]; then
46+
echo "Already connected to: $KEY "
47+
else
48+
if [ "$SELF" != "$KEY" ] ; then
49+
ADDRESS=$($LNCLI getnodeinfo $KEY | grep \"addr\" |head -n 1| awk '{print $2}' |sed 's/"//g' )
50+
echo "Connecting to: $KEY@$ADDRESS"
51+
$LNCLI connect $KEY@$ADDRESS
52+
fi
53+
fi
54+
done
55+
}
56+
3857
# Arg option: 'send'
3958
send () {
4059
INVOICE=$($LNCLI addinvoice --amt=${AMOUNT} --memo="Rebalancing...")
@@ -76,13 +95,14 @@ assert_tools () {
7695
# Arg option: '--help'
7796
help () {
7897
cat << EOF
79-
usage: ./igniter.sh [--help] [build] [send]
98+
usage: ./igniter.sh [--help] [build] [connect] [send]
8099
<command> [<args>]
81100
82101
Open the script and configure values first. Then run
83102
the script with one of the following flags:
84103
85-
build Build the routes for the configured nodes
104+
build Build the routes for the configured node
105+
connect Connect to every peer with lncli
86106
send Build route and send payment along route
87107
88108
EOF
@@ -99,6 +119,9 @@ case $1 in
99119
"build" )
100120
build $rest_args
101121
;;
122+
"connect" )
123+
connect $rest_args
124+
;;
102125
"send" )
103126
send $rest_args
104127
;;

0 commit comments

Comments
 (0)