1 Comment
LIGHTNING2 wrote over 4 years ago
I wrote this script to make channel openings quick and easy. It'll use socat to allow a clearnet lnd to connect to tor nodes.
You need to
You need to
apt-get install socat
before using it.
Also useful for quickly pasting a node address and satoshi amount, instead of connecting and then opening a channel.
ezopen.sh:
ezopen.sh:
is_tor_node() {
echo $1 | grep -q onion
}
connect_tor () {
addr=$(echo $1 | egrep -o '[a-z0-9]+\.onion:[0-9]+')
port=$((10000 + ($RANDOM * $RANDOM) % 55535))
socat tcp-listen:$port socks4a:127.0.0.1:$addr,socksport=9050 &
pid=$!
node=$(echo $1 | egrep -o '[0-9a-f]{66}')
lncli connect $node@127.0.0.1:$port
}
open_channel () {
node=$(echo $1 | egrep -o '[0-9a-f]{66}')
lncli openchannel $node $2 --min_confs 0
}
if is_tor_node $1; then
connect_tor $1
else
lncli connect $1
fi
open_channel $1 $2
if is_tor_node $1; then
sleep 5
kill $pid
fiUsage: ./ezopen.sh [node@address:port] [satoshis]
Please login to post comments.