Browse Source

open channel first draft

#146
rootzoll 6 years ago
parent
commit
e1970129bf
  1. 7
      home.admin/00mainMenu.sh
  2. 62
      home.admin/BBopenChannel.sh

7
home.admin/00mainMenu.sh

@ -70,6 +70,7 @@ else
OPTIONS+=(INFO "RaspiBlitz Status Screen" \
FUNDING "Fund your Wallet" \
CONNECT "Connect to a Peer" \
CHANNEL "Open a Channel with Peer" \
lnbalance "Detailed Wallet Balances" \
lnchannels "Lightning Channel List" \
SWITCH "Switch ${switchOption}"
@ -136,6 +137,12 @@ case $CHOICE in
read key
./00mainMenu.sh
;;
FUNDING)
./BBopenChannel.sh
echo "Press ENTER to return to main menu."
read key
./00mainMenu.sh
;;
SWITCH)
sudo ./95switchMainTest.sh
echo "Press ENTER to return to main menu."

62
home.admin/BBopenChannel.sh

@ -61,7 +61,8 @@ if [ ${#pubKey} -eq 0 ]; then
exit 1
fi
# find out what is the minimum amount
# find out what is the minimum amount
# TODO find a better way - also consider dust and channel reserve
minSat=20000
_error="./.error.out"
lncli openchannel ${CHOICE} 1 0 2>$_error
@ -100,64 +101,21 @@ echo "RESULT:"
# execute command
result=$($command 2>$_error)
error=`cat ${_error}`
echo "result(${result})"
echo "error(${error})"
exit 1
# on no result
if [ ${#result} -eq 0 ]; then
# basic error
win=0
info="No return value. Error not known."
# try to get error output
result=`cat ${_error}`
echo "$result"
# basic cli error
cliError=$(echo "${result}" | grep "[lncli]" -c )
if [ ${cliError} -gt 0 ]; then
info="Its possible that LND daemon is not running, not configured correct or not connected to the lncli."
fi
if [ ${#error} -gt 0 ]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "FAIL"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "${error}"
else
# when result is available
echo "$result"
# check if the node is now in peer list
pubkey=$(echo $_input | cut -d '@' -f1)
isPeer=$(lncli listpeers 2>/dev/null| grep "${pubkey}" -c)
if [ ${isPeer} -eq 0 ]; then
# basic error message
win=0
info="Was not able to establish connection to node."
# TODO: try to find out more details from cli output
else
info="Perfect - a connection to that node got established :)"
fi
fi
# output info
echo ""
if [ ${win} -eq 1 ]; then
echo "******************************"
echo "WIN"
echo "******************************"
echo "${info}"
echo "${result}"
echo ""
echo "Whats next? --> Open a channel with that node."
else
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "FAIL"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "${info}"
echo "Whats next? --> You need to wait 6 confirmations, for the channel to be ready."
fi
echo ""
Loading…
Cancel
Save