From 56ad6ac11a4bc058bb1fb65a938b8369edf6e623 Mon Sep 17 00:00:00 2001 From: rootzoll Date: Mon, 27 Aug 2018 11:08:04 +0200 Subject: [PATCH] added chain parameter to lncli --- home.admin/00infoLCD.sh | 2 +- home.admin/00mainMenu.sh | 2 +- home.admin/10setupBlitz.sh | 2 +- home.admin/70initLND.sh | 8 ++++---- home.admin/95switchMainTest.sh | 4 ++-- home.admin/AAunlockLND.sh | 4 ++-- home.admin/BBcashoutWallet.sh | 4 ++-- home.admin/BBcloseAllChannels.sh | 4 ++-- home.admin/BBconnectPeer.sh | 4 ++-- home.admin/BBcreateInvoice.sh | 8 ++++---- home.admin/BBfundWallet.sh | 4 ++-- home.admin/BBopenChannel.sh | 12 ++++++------ home.admin/BBpayInvoice.sh | 6 +++--- 13 files changed, 32 insertions(+), 32 deletions(-) diff --git a/home.admin/00infoLCD.sh b/home.admin/00infoLCD.sh index 72fd9fe..50767e7 100755 --- a/home.admin/00infoLCD.sh +++ b/home.admin/00infoLCD.sh @@ -70,7 +70,7 @@ if [ "$USER" = "pi" ]; then # get chain if not available before chain=$(sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 2>/dev/null | jq -r '.chain') 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) if [ ${locked} -gt 0 ]; then diff --git a/home.admin/00mainMenu.sh b/home.admin/00mainMenu.sh index 445e63c..fe1dd90 100755 --- a/home.admin/00mainMenu.sh +++ b/home.admin/00mainMenu.sh @@ -95,7 +95,7 @@ else MOBILE "Connect Mobile Wallet") # 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 OPTIONS+=(CLOSEALL "Close all open Channels") fi diff --git a/home.admin/10setupBlitz.sh b/home.admin/10setupBlitz.sh index b7a5276..a6045dd 100755 --- a/home.admin/10setupBlitz.sh +++ b/home.admin/10setupBlitz.sh @@ -67,7 +67,7 @@ if [ ${lndRunning} -eq 1 ]; then fi # 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 if [ ${#lndInfo} -gt 0 ];then lndSyncing=$(echo "${chainInfo}" | grep "false" -c) diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 894127f..bfba44d 100755 --- a/home.admin/70initLND.sh +++ b/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 "****************************************************************************" echo "" - echo "lncli create" + echo "lncli --chain=${network} create" # execute command and monitor error _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}` if [ ${#error} -gt 0 ]; then @@ -209,7 +209,7 @@ fi echo "" echo "*** Check LND Sync ***" 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 echo "OK - wait for LND to be synced" while : @@ -220,7 +220,7 @@ if [ ${lndSyncing} -eq 0 ]; then sleep 15 # 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 break fi diff --git a/home.admin/95switchMainTest.sh b/home.admin/95switchMainTest.sh index 733941b..0548be0 100755 --- a/home.admin/95switchMainTest.sh +++ b/home.admin/95switchMainTest.sh @@ -61,11 +61,11 @@ lndInstalled=$(systemctl status lnd.service | grep loaded -c) if [ ${lndInstalled} -gt 0 ]; then 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 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 "!!!!!!!!!!!!!!!!!!!" exit 1 else diff --git a/home.admin/AAunlockLND.sh b/home.admin/AAunlockLND.sh index c09bb85..3177694 100755 --- a/home.admin/AAunlockLND.sh +++ b/home.admin/AAunlockLND.sh @@ -5,14 +5,14 @@ network=`cat .network` echo "" echo "****************************************************************************" -echo "Unlock LND Wallet --> lncli unlock" +echo "Unlock LND Wallet --> lncli --chain=${network} unlock" echo "****************************************************************************" echo "HELP: Enter your PASSWORD C" echo "****************************************************************************" while : do 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 locked=$(sudo tail -n 1 /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log | grep -c unlock) if [ ${locked} -eq 0 ]; then diff --git a/home.admin/BBcashoutWallet.sh b/home.admin/BBcashoutWallet.sh index bc3ad69..7d71d8f 100755 --- a/home.admin/BBcashoutWallet.sh +++ b/home.admin/BBcashoutWallet.sh @@ -7,7 +7,7 @@ network=`cat .network` chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain') # 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 # 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 -command="lncli sendcoins --conf_target 3 ${address} ${amount}" +command="lncli --chain=${network} --conf_target 3 sendcoins ${address} ${amount}" clear echo "******************************" diff --git a/home.admin/BBcloseAllChannels.sh b/home.admin/BBcloseAllChannels.sh index c1fa0d3..3543d8d 100755 --- a/home.admin/BBcloseAllChannels.sh +++ b/home.admin/BBcloseAllChannels.sh @@ -4,7 +4,7 @@ network=`cat .network` chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain') -command="lncli closeallchannels --force" +command="lncli --chain=${network} --force closeallchannels " clear echo "***********************************" @@ -17,7 +17,7 @@ echo "" echo "RESULT:" # 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 command="" result="FAIL PRECHECK - lncli getinfo shows 'synced_to_chain': false - wait until chain is sync " diff --git a/home.admin/BBconnectPeer.sh b/home.admin/BBconnectPeer.sh index 8900335..ac29894 100755 --- a/home.admin/BBconnectPeer.sh +++ b/home.admin/BBconnectPeer.sh @@ -29,7 +29,7 @@ if [ ${#_input} -eq 0 ]; then fi # build command -command="lncli connect ${_input}" +command="lncli --chain=${network} connect ${_input}" # info output clear @@ -88,7 +88,7 @@ else # check if the node is now in peer list 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 # basic error message diff --git a/home.admin/BBcreateInvoice.sh b/home.admin/BBcreateInvoice.sh index a1eba2d..018f0c0 100755 --- a/home.admin/BBcreateInvoice.sh +++ b/home.admin/BBcreateInvoice.sh @@ -10,7 +10,7 @@ echo "" echo "*** 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 echo "!!!!!!!!!!!!!!!!!!!" echo "FAIL - 'lncli getinfo' shows 'synced_to_chain': false" @@ -22,7 +22,7 @@ fi # check number of connected peers 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 echo "" echo "!!!!!!!!!!!!!!!!!!!" @@ -45,7 +45,7 @@ if [ ${#amount} -eq 0 ]; then fi # build command -command="lncli addinvoice ${amount}" +command="lncli --chain=${network} addinvoice ${amount}" # info output clear @@ -83,7 +83,7 @@ else echo "" echo ${payReq} 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. diff --git a/home.admin/BBfundWallet.sh b/home.admin/BBfundWallet.sh index 0322248..ea52d2c 100755 --- a/home.admin/BBfundWallet.sh +++ b/home.admin/BBfundWallet.sh @@ -4,7 +4,7 @@ network=`cat .network` chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain') -command="lncli newaddress np2wkh" +command="lncli --chain=${network} newaddress np2wkh" clear echo "******************************" @@ -17,7 +17,7 @@ echo "" echo "RESULT:" # 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 command="" result="FAIL PRECHECK - lncli getinfo shows 'synced_to_chain': false - wait until chain is sync " diff --git a/home.admin/BBopenChannel.sh b/home.admin/BBopenChannel.sh index 47e1661..649241d 100755 --- a/home.admin/BBopenChannel.sh +++ b/home.admin/BBopenChannel.sh @@ -10,7 +10,7 @@ echo "" echo "*** 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 echo "FAIL - 'lncli getinfo' shows 'synced_to_chain': false" echo "Wait until chain is sync with LND and try again." @@ -19,7 +19,7 @@ if [ ${chainInSync} -eq 0 ]; then fi # 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 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." @@ -28,7 +28,7 @@ if [ ${confirmedBalance} -eq 0 ]; then fi # 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 echo "FAIL - no peers connected on lightning network" echo "You can only open channels to peer nodes to connected to first." @@ -44,7 +44,7 @@ do pubKey=$(echo ${grepLine} | cut -d '"' -f4) #echo "grepLine(${pubKey})" OPTIONS+=(${pubKey} "") -done < <(lncli listpeers | grep pub_key) +done < <(lncli --chain=${network} listpeers | grep pub_key) TITLE="Open (Payment) Channel" MENU="\nChoose a peer you connected to, to open the channel with: \n " pubKey=$(dialog --clear \ @@ -69,7 +69,7 @@ if [ "${network}" = "bitcoin" ]; then minSat=250000 fi _error="./.error.out" -lncli openchannel ${CHOICE} 1 0 2>$_error +lncli --chain=${network} openchannel ${CHOICE} 1 0 2>$_error error=`cat ${_error}` if [ $(echo "${error}" | grep "channel is too small" -c) -eq 1 ]; then minSat=$(echo "${error}" | tr -dc '0-9') @@ -89,7 +89,7 @@ if [ ${#amount} -eq 0 ]; then fi # build command -command="lncli openchannel ${pubKey} ${amount} 0" +command="lncli --chain=${network} openchannel ${pubKey} ${amount} 0" # info output clear diff --git a/home.admin/BBpayInvoice.sh b/home.admin/BBpayInvoice.sh index 2b1540c..3e38c78 100755 --- a/home.admin/BBpayInvoice.sh +++ b/home.admin/BBpayInvoice.sh @@ -10,7 +10,7 @@ echo "" echo "*** 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 echo "!!!!!!!!!!!!!!!!!!!" echo "FAIL - 'lncli getinfo' shows 'synced_to_chain': false" @@ -23,7 +23,7 @@ fi # check number of connected peers 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 echo "" echo "!!!!!!!!!!!!!!!!!!!" @@ -71,7 +71,7 @@ fi # TODO: maybe try/show the decoded info first by using https://api.lightning.community/#decodepayreq # build command -command="lncli sendpayment --pay_req=${invoice}" +command="lncli --chain=${network} sendpayment --pay_req=${invoice}" # info output clear