Skip to content

Commit

Permalink
Merge pull request #21 from ramondevries/main
Browse files Browse the repository at this point in the history
added command to connect to all peers of the ring of fire.
  • Loading branch information
RooSoft authored Nov 21, 2022
2 parents d0cafe4 + f688ac4 commit f1a5bdf
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ Test that all nodes are properly connected with this command
./igniter.sh build
```

### Connect to all peers

Test that all peers are up and your node can connect with this command

```bash
./igniter.sh connect
```

### Route the payment

All that's left to do is to execute the script with this command
Expand Down
27 changes: 25 additions & 2 deletions igniter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,25 @@ build () {
$LNCLI buildroute --amt ${AMOUNT} --hops ${HOPS} --outgoing_chan_id ${OUTGOING_CHAN_ID}
}

# Arg option: 'connect'
connect () {
IFS=,
PEERS=$($LNCLI listpeers | grep pub_key | tr '"' ' ' | awk '{print $3}')
SELF=$($LNCLI getinfo | grep pubkey | tr '"' ' ' | head -n 1 | awk '{print $3}')
for KEY in $HOPS
do
if [[ "$PEERS" =~ "$KEY" ]]; then
echo "Already connected to: $KEY "
else
if [ "$SELF" != "$KEY" ] ; then
ADDRESS=$($LNCLI getnodeinfo $KEY | grep \"addr\" |head -n 1| awk '{print $2}' |sed 's/"//g' )
echo "Connecting to: $KEY@$ADDRESS"
$LNCLI connect $KEY@$ADDRESS
fi
fi
done
}

# Arg option: 'send'
send () {
INVOICE=$($LNCLI addinvoice --amt=${AMOUNT} --memo="Rebalancing...")
Expand Down Expand Up @@ -76,13 +95,14 @@ assert_tools () {
# Arg option: '--help'
help () {
cat << EOF
usage: ./igniter.sh [--help] [build] [send]
usage: ./igniter.sh [--help] [build] [connect] [send]
<command> [<args>]
Open the script and configure values first. Then run
the script with one of the following flags:
build Build the routes for the configured nodes
build Build the routes for the configured node
connect Connect to every peer with lncli
send Build route and send payment along route
EOF
Expand All @@ -99,6 +119,9 @@ case $1 in
"build" )
build $rest_args
;;
"connect" )
connect $rest_args
;;
"send" )
send $rest_args
;;
Expand Down

0 comments on commit f1a5bdf

Please sign in to comment.