Browse Source

added chain parameter to lncli

#146
rootzoll 7 years ago
parent
commit
56ad6ac11a
  1. 2
      home.admin/00infoLCD.sh
  2. 2
      home.admin/00mainMenu.sh
  3. 2
      home.admin/10setupBlitz.sh
  4. 8
      home.admin/70initLND.sh
  5. 4
      home.admin/95switchMainTest.sh
  6. 4
      home.admin/AAunlockLND.sh
  7. 4
      home.admin/BBcashoutWallet.sh
  8. 4
      home.admin/BBcloseAllChannels.sh
  9. 4
      home.admin/BBconnectPeer.sh
  10. 8
      home.admin/BBcreateInvoice.sh
  11. 4
      home.admin/BBfundWallet.sh
  12. 12
      home.admin/BBopenChannel.sh
  13. 6
      home.admin/BBpayInvoice.sh

2
home.admin/00infoLCD.sh

@ -70,7 +70,7 @@ if [ "$USER" = "pi" ]; then
# get chain if not available before # get chain if not available before
chain=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 2>/dev/null | jq -r '.chain') chain=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 2>/dev/null | jq -r '.chain')
fi fi
lndSynced=$(sudo -u bitcoin /usr/local/bin/lncli getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true) lndSynced=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true)
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null | grep -c unlock) locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null | grep -c unlock)
if [ ${locked} -gt 0 ]; then if [ ${locked} -gt 0 ]; then

2
home.admin/00mainMenu.sh

@ -95,7 +95,7 @@ else
MOBILE "Connect Mobile Wallet") MOBILE "Connect Mobile Wallet")
# Depending Options # Depending Options
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli listchannels 2>/dev/null | grep chan_id -c) openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} listchannels 2>/dev/null | grep chan_id -c)
if [ ${openChannels} -gt 0 ]; then if [ ${openChannels} -gt 0 ]; then
OPTIONS+=(CLOSEALL "Close all open Channels") OPTIONS+=(CLOSEALL "Close all open Channels")
fi fi

2
home.admin/10setupBlitz.sh

@ -67,7 +67,7 @@ if [ ${lndRunning} -eq 1 ]; then
fi fi
# check if lnd is scanning blockchain # check if lnd is scanning blockchain
lndInfo=$(sudo -u bitcoin /usr/local/bin/lncli getinfo | grep "synced_to_chain") lndInfo=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} getinfo | grep "synced_to_chain")
lndSyncing=1 lndSyncing=1
if [ ${#lndInfo} -gt 0 ];then if [ ${#lndInfo} -gt 0 ];then
lndSyncing=$(echo "${chainInfo}" | grep "false" -c) lndSyncing=$(echo "${chainInfo}" | grep "false" -c)

8
home.admin/70initLND.sh

@ -127,11 +127,11 @@ Press OK and follow the 'Helping Instructions'.
echo "C) For 'passphrase' to encrypt your 'cipher seed' use PASSWORD D (optional)" echo "C) For 'passphrase' to encrypt your 'cipher seed' use PASSWORD D (optional)"
echo "****************************************************************************" echo "****************************************************************************"
echo "" echo ""
echo "lncli create" echo "lncli --chain=${network} create"
# execute command and monitor error # execute command and monitor error
_error="./.error.out" _error="./.error.out"
sudo -u bitcoin /usr/local/bin/lncli create 2>$_error sudo -u bitcoin /usr/local/bin/lncli --chain=${network} create 2>$_error
error=`cat ${_error}` error=`cat ${_error}`
if [ ${#error} -gt 0 ]; then if [ ${#error} -gt 0 ]; then
@ -209,7 +209,7 @@ fi
echo "" echo ""
echo "*** Check LND Sync ***" echo "*** Check LND Sync ***"
item=0 item=0
lndSyncing=$(sudo -u bitcoin /usr/local/bin/lncli getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true) lndSyncing=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true)
if [ ${lndSyncing} -eq 0 ]; then if [ ${lndSyncing} -eq 0 ]; then
echo "OK - wait for LND to be synced" echo "OK - wait for LND to be synced"
while : while :
@ -220,7 +220,7 @@ if [ ${lndSyncing} -eq 0 ]; then
sleep 15 sleep 15
# break loop when synced # break loop when synced
lndSyncing=$(sudo -u bitcoin /usr/local/bin/lncli getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true) lndSyncing=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true)
if [ ${lndSyncing} -eq 1 ]; then if [ ${lndSyncing} -eq 1 ]; then
break break
fi fi

4
home.admin/95switchMainTest.sh

@ -61,11 +61,11 @@ lndInstalled=$(systemctl status lnd.service | grep loaded -c)
if [ ${lndInstalled} -gt 0 ]; then if [ ${lndInstalled} -gt 0 ]; then
echo "check for open channels" echo "check for open channels"
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli listchannels 2>/dev/null | grep chan_id -c) openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} listchannels 2>/dev/null | grep chan_id -c)
if [ ${openChannels} -gt 0 ]; then if [ ${openChannels} -gt 0 ]; then
echo "" echo ""
echo "!!!!!!!!!!!!!!!!!!!" echo "!!!!!!!!!!!!!!!!!!!"
echo "FAIL - You have still open channels and could loose funds !! - close those first with 'lncli closeallchannels' or main menu option." echo "FAIL - You have still open channels and could loose funds !! - close those first with 'lncli --chain=${network} closeallchannels' or main menu option."
echo "!!!!!!!!!!!!!!!!!!!" echo "!!!!!!!!!!!!!!!!!!!"
exit 1 exit 1
else else

4
home.admin/AAunlockLND.sh

@ -5,14 +5,14 @@ network=`cat .network`
echo "" echo ""
echo "****************************************************************************" echo "****************************************************************************"
echo "Unlock LND Wallet --> lncli unlock" echo "Unlock LND Wallet --> lncli --chain=${network} unlock"
echo "****************************************************************************" echo "****************************************************************************"
echo "HELP: Enter your PASSWORD C" echo "HELP: Enter your PASSWORD C"
echo "****************************************************************************" echo "****************************************************************************"
while : while :
do do
chain="$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')" chain="$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')"
sudo -u bitcoin /usr/local/bin/lncli unlock sudo -u bitcoin /usr/local/bin/lncli --chain=${network} unlock
sleep 4 sleep 4
locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock) locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock)
if [ ${locked} -eq 0 ]; then if [ ${locked} -eq 0 ]; then

4
home.admin/BBcashoutWallet.sh

@ -7,7 +7,7 @@ network=`cat .network`
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain') chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
# get available amount in on-chain wallet # get available amount in on-chain wallet
maxAmount=$(lncli walletbalance | grep '"confirmed_balance"' | cut -d '"' -f4) maxAmount=$(lncli --chain=${network} walletbalance | grep '"confirmed_balance"' | cut -d '"' -f4)
# TODO: pre-check if channels are open or are still in closing # TODO: pre-check if channels are open or are still in closing
# and let user know not all funds are available yet (just info Dialoge) # and let user know not all funds are available yet (just info Dialoge)
@ -44,7 +44,7 @@ fi
# TODO: check if fees are getting done right so that transaction will get processed # TODO: check if fees are getting done right so that transaction will get processed
command="lncli sendcoins --conf_target 3 ${address} ${amount}" command="lncli --chain=${network} --conf_target 3 sendcoins ${address} ${amount}"
clear clear
echo "******************************" echo "******************************"

4
home.admin/BBcloseAllChannels.sh

@ -4,7 +4,7 @@
network=`cat .network` network=`cat .network`
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain') chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
command="lncli closeallchannels --force" command="lncli --chain=${network} --force closeallchannels "
clear clear
echo "***********************************" echo "***********************************"
@ -17,7 +17,7 @@ echo ""
echo "RESULT:" echo "RESULT:"
# PRECHECK) check if chain is in sync # PRECHECK) check if chain is in sync
chainInSync=$(lncli getinfo | grep '"synced_to_chain": true' -c) chainInSync=$(lncli --chain=${network} getinfo | grep '"synced_to_chain": true' -c)
if [ ${chainInSync} -eq 0 ]; then if [ ${chainInSync} -eq 0 ]; then
command="" command=""
result="FAIL PRECHECK - lncli getinfo shows 'synced_to_chain': false - wait until chain is sync " result="FAIL PRECHECK - lncli getinfo shows 'synced_to_chain': false - wait until chain is sync "

4
home.admin/BBconnectPeer.sh

@ -29,7 +29,7 @@ if [ ${#_input} -eq 0 ]; then
fi fi
# build command # build command
command="lncli connect ${_input}" command="lncli --chain=${network} connect ${_input}"
# info output # info output
clear clear
@ -88,7 +88,7 @@ else
# check if the node is now in peer list # check if the node is now in peer list
pubkey=$(echo $_input | cut -d '@' -f1) pubkey=$(echo $_input | cut -d '@' -f1)
isPeer=$(lncli listpeers 2>/dev/null| grep "${pubkey}" -c) isPeer=$(lncli --chain=${network} listpeers 2>/dev/null| grep "${pubkey}" -c)
if [ ${isPeer} -eq 0 ]; then if [ ${isPeer} -eq 0 ]; then
# basic error message # basic error message

8
home.admin/BBcreateInvoice.sh

@ -10,7 +10,7 @@ echo ""
echo "*** Precheck ***" echo "*** Precheck ***"
# check if chain is in sync # check if chain is in sync
chainInSync=$(lncli getinfo | grep '"synced_to_chain": true' -c) chainInSync=$(lncli --chain=${network} getinfo | grep '"synced_to_chain": true' -c)
if [ ${chainInSync} -eq 0 ]; then if [ ${chainInSync} -eq 0 ]; then
echo "!!!!!!!!!!!!!!!!!!!" echo "!!!!!!!!!!!!!!!!!!!"
echo "FAIL - 'lncli getinfo' shows 'synced_to_chain': false" echo "FAIL - 'lncli getinfo' shows 'synced_to_chain': false"
@ -22,7 +22,7 @@ fi
# check number of connected peers # check number of connected peers
echo "check for open channels" echo "check for open channels"
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli listchannels 2>/dev/null | grep chan_id -c) openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} listchannels 2>/dev/null | grep chan_id -c)
if [ ${openChannels} -eq 0 ]; then if [ ${openChannels} -eq 0 ]; then
echo "" echo ""
echo "!!!!!!!!!!!!!!!!!!!" echo "!!!!!!!!!!!!!!!!!!!"
@ -45,7 +45,7 @@ if [ ${#amount} -eq 0 ]; then
fi fi
# build command # build command
command="lncli addinvoice ${amount}" command="lncli --chain=${network} addinvoice ${amount}"
# info output # info output
clear clear
@ -83,7 +83,7 @@ else
echo "" echo ""
echo ${payReq} echo ${payReq}
echo "" echo ""
echo "You can use 'lncli lookupinvoice ${rhash}' to check the payment. " echo "You can use 'lncli --chain=${network} lookupinvoice ${rhash}' to check the payment. "
# TODO: Offer to go into monitor for incommin payment loop. # TODO: Offer to go into monitor for incommin payment loop.

4
home.admin/BBfundWallet.sh

@ -4,7 +4,7 @@
network=`cat .network` network=`cat .network`
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain') chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain')
command="lncli newaddress np2wkh" command="lncli --chain=${network} newaddress np2wkh"
clear clear
echo "******************************" echo "******************************"
@ -17,7 +17,7 @@ echo ""
echo "RESULT:" echo "RESULT:"
# PRECHECK) check if chain is in sync # PRECHECK) check if chain is in sync
chainInSync=$(lncli getinfo | grep '"synced_to_chain": true' -c) chainInSync=$(lncli --chain=${network} getinfo | grep '"synced_to_chain": true' -c)
if [ ${chainInSync} -eq 0 ]; then if [ ${chainInSync} -eq 0 ]; then
command="" command=""
result="FAIL PRECHECK - lncli getinfo shows 'synced_to_chain': false - wait until chain is sync " result="FAIL PRECHECK - lncli getinfo shows 'synced_to_chain': false - wait until chain is sync "

12
home.admin/BBopenChannel.sh

@ -10,7 +10,7 @@ echo ""
echo "*** Precheck ***" echo "*** Precheck ***"
# check if chain is in sync # check if chain is in sync
chainInSync=$(lncli getinfo | grep '"synced_to_chain": true' -c) chainInSync=$(lncli --chain=${network} getinfo | grep '"synced_to_chain": true' -c)
if [ ${chainInSync} -eq 0 ]; then if [ ${chainInSync} -eq 0 ]; then
echo "FAIL - 'lncli getinfo' shows 'synced_to_chain': false" echo "FAIL - 'lncli getinfo' shows 'synced_to_chain': false"
echo "Wait until chain is sync with LND and try again." echo "Wait until chain is sync with LND and try again."
@ -19,7 +19,7 @@ if [ ${chainInSync} -eq 0 ]; then
fi fi
# check available funding # check available funding
confirmedBalance=$(lncli walletbalance | grep '"confirmed_balance"' | cut -d '"' -f4) confirmedBalance=$(lncli --chain=${network} walletbalance | grep '"confirmed_balance"' | cut -d '"' -f4)
if [ ${confirmedBalance} -eq 0 ]; then if [ ${confirmedBalance} -eq 0 ]; then
echo "FAIL - You have 0 SATOSHI in your confirmed LND On-Chain Wallet." echo "FAIL - You have 0 SATOSHI in your confirmed LND On-Chain Wallet."
echo "Please fund your on-chain wallet first and wait until confirmed." echo "Please fund your on-chain wallet first and wait until confirmed."
@ -28,7 +28,7 @@ if [ ${confirmedBalance} -eq 0 ]; then
fi fi
# check number of connected peers # check number of connected peers
numConnectedPeers=$(lncli listpeers | grep pub_key -c) numConnectedPeers=$(lncli --chain=${network} listpeers | grep pub_key -c)
if [ ${numConnectedPeers} -eq 0 ]; then if [ ${numConnectedPeers} -eq 0 ]; then
echo "FAIL - no peers connected on lightning network" echo "FAIL - no peers connected on lightning network"
echo "You can only open channels to peer nodes to connected to first." echo "You can only open channels to peer nodes to connected to first."
@ -44,7 +44,7 @@ do
pubKey=$(echo ${grepLine} | cut -d '"' -f4) pubKey=$(echo ${grepLine} | cut -d '"' -f4)
#echo "grepLine(${pubKey})" #echo "grepLine(${pubKey})"
OPTIONS+=(${pubKey} "") OPTIONS+=(${pubKey} "")
done < <(lncli listpeers | grep pub_key) done < <(lncli --chain=${network} listpeers | grep pub_key)
TITLE="Open (Payment) Channel" TITLE="Open (Payment) Channel"
MENU="\nChoose a peer you connected to, to open the channel with: \n " MENU="\nChoose a peer you connected to, to open the channel with: \n "
pubKey=$(dialog --clear \ pubKey=$(dialog --clear \
@ -69,7 +69,7 @@ if [ "${network}" = "bitcoin" ]; then
minSat=250000 minSat=250000
fi fi
_error="./.error.out" _error="./.error.out"
lncli openchannel ${CHOICE} 1 0 2>$_error lncli --chain=${network} openchannel ${CHOICE} 1 0 2>$_error
error=`cat ${_error}` error=`cat ${_error}`
if [ $(echo "${error}" | grep "channel is too small" -c) -eq 1 ]; then if [ $(echo "${error}" | grep "channel is too small" -c) -eq 1 ]; then
minSat=$(echo "${error}" | tr -dc '0-9') minSat=$(echo "${error}" | tr -dc '0-9')
@ -89,7 +89,7 @@ if [ ${#amount} -eq 0 ]; then
fi fi
# build command # build command
command="lncli openchannel ${pubKey} ${amount} 0" command="lncli --chain=${network} openchannel ${pubKey} ${amount} 0"
# info output # info output
clear clear

6
home.admin/BBpayInvoice.sh

@ -10,7 +10,7 @@ echo ""
echo "*** Precheck ***" echo "*** Precheck ***"
# check if chain is in sync # check if chain is in sync
chainInSync=$(lncli getinfo | grep '"synced_to_chain": true' -c) chainInSync=$(lncli --chain=${network} getinfo | grep '"synced_to_chain": true' -c)
if [ ${chainInSync} -eq 0 ]; then if [ ${chainInSync} -eq 0 ]; then
echo "!!!!!!!!!!!!!!!!!!!" echo "!!!!!!!!!!!!!!!!!!!"
echo "FAIL - 'lncli getinfo' shows 'synced_to_chain': false" echo "FAIL - 'lncli getinfo' shows 'synced_to_chain': false"
@ -23,7 +23,7 @@ fi
# check number of connected peers # check number of connected peers
echo "check for open channels" echo "check for open channels"
openChannels=$(sudo -u bitcoin /usr/local/bin/lncli listchannels 2>/dev/null | grep chan_id -c) openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} listchannels 2>/dev/null | grep chan_id -c)
if [ ${openChannels} -eq 0 ]; then if [ ${openChannels} -eq 0 ]; then
echo "" echo ""
echo "!!!!!!!!!!!!!!!!!!!" echo "!!!!!!!!!!!!!!!!!!!"
@ -71,7 +71,7 @@ fi
# TODO: maybe try/show the decoded info first by using https://api.lightning.community/#decodepayreq # TODO: maybe try/show the decoded info first by using https://api.lightning.community/#decodepayreq
# build command # build command
command="lncli sendpayment --pay_req=${invoice}" command="lncli --chain=${network} sendpayment --pay_req=${invoice}"
# info output # info output
clear clear

Loading…
Cancel
Save