rootzoll
7 years ago
9 changed files with 453 additions and 60 deletions
@ -0,0 +1,122 @@ |
|||
#!/bin/sh |
|||
_temp="./download/dialog.$$" |
|||
_error="./.error.out" |
|||
|
|||
# load network and chain info |
|||
network=`cat .network` |
|||
chain=$(sudo -bitcoin ${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain') |
|||
|
|||
# set ntwork map info |
|||
networkMap="https://lnmainnet.gaben.win" |
|||
if [ "$network" = "litecoin" ]; then |
|||
networkMap="https://lnexplorer.hcwong.me" |
|||
fi |
|||
if [ "$chain" = "test" ]; then |
|||
networkMap="https://explorer.acinq.co" |
|||
fi |
|||
|
|||
# let user enter a <pubkey>@host |
|||
l1="Enter the node pubkey address with host information:" |
|||
l2="example -----> 024ddf33[...]1f5f9f3@91.65.1.38:9735" |
|||
l3="network map -> ${networkMap}" |
|||
dialog --title "Open a Connection to a Peer" \ |
|||
--backtitle "Lightning ( ${network} | ${chain} )" \ |
|||
--inputbox "$l1\n$l2\n$l3" 10 60 2>$_temp |
|||
_input=$(cat $_temp | xargs ) |
|||
shred $_temp |
|||
if [ ${#_input} -eq 0 ]; then |
|||
exit 1 |
|||
fi |
|||
|
|||
# build command |
|||
command="lncli connect ${_input}" |
|||
|
|||
# info output |
|||
clear |
|||
echo "******************************" |
|||
echo "Connect to A Lightning Node" |
|||
echo "******************************" |
|||
echo "" |
|||
echo "COMMAND LINE: " |
|||
echo $command |
|||
echo "" |
|||
echo "RESULT:" |
|||
|
|||
win=1 |
|||
info="" |
|||
|
|||
# check if input is available |
|||
if [ ${#_input} -lt 10 ]; then |
|||
win=0 |
|||
info="node pubkey@host info is too short" |
|||
else |
|||
gotAt=$(echo $_input | grep '@' -c) |
|||
if [ ${gotAt} -eq 0 ]; then |
|||
win=0 |
|||
info="format is not pubkey@host - @ is missing" |
|||
fi |
|||
fi |
|||
|
|||
# execute command |
|||
sleep 2 |
|||
result="$info" |
|||
if [ ${win} -eq 1 ]; then |
|||
result=$($command 2>$_error) |
|||
fi |
|||
|
|||
# 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 |
|||
|
|||
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 "" |
|||
echo "Whats next? --> Open a channel with that node." |
|||
else |
|||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
|||
echo "FAIL" |
|||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" |
|||
echo "${info}" |
|||
fi |
|||
|
|||
echo "" |
@ -0,0 +1,54 @@ |
|||
#!/bin/bash |
|||
|
|||
# load network and chain info |
|||
network=`cat .network` |
|||
chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo 2>/dev/null | jq -r '.chain') |
|||
|
|||
command="lncli newaddress np2wkh" |
|||
|
|||
clear |
|||
echo "******************************" |
|||
echo "Fund your Blockchain Wallet" |
|||
echo "******************************" |
|||
echo "" |
|||
echo "COMMAND LINE: " |
|||
echo $command |
|||
echo "" |
|||
echo "RESULT:" |
|||
|
|||
# execute command |
|||
result=$($command) |
|||
|
|||
# on no result |
|||
if [ ${#result} -eq 0 ]; then |
|||
echo "Sorry something went wrong - thats unusual." |
|||
echo "" |
|||
exit 1 |
|||
fi |
|||
|
|||
# when result is available |
|||
echo "$result" |
|||
|
|||
# get address from result |
|||
address=$( echo "$result" | grep "address" | cut -d '"' -f4) |
|||
|
|||
# prepare coin info |
|||
coininfo="REAL Bitcoin" |
|||
if [ "$network" = "litecoin" ]; then |
|||
coininfo="REAL Litecoin" |
|||
fi |
|||
if [ "$chain" = "test" ]; then |
|||
coininfo="TESTNET Bitcoin" |
|||
fi |
|||
|
|||
# output info |
|||
echo "" |
|||
echo "******************************" |
|||
echo "TODO" |
|||
echo "******************************" |
|||
echo "Send ${coininfo} to address --> ${address}" |
|||
if [ "$chain" = "test" ]; then |
|||
echo "get some testnet coins from https://testnet.manu.backend.hamburg/faucet" |
|||
fi |
|||
echo "Whats next? --> Wait for confirmations. You can use lnbalance for main menu or info on LCD to check if funds have arrived." |
|||
echo "" |
Loading…
Reference in new issue