-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathlistchannels
executable file
·50 lines (46 loc) · 1.19 KB
/
listchannels
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
SHORT=s:
LONG=public,private,open,sortby:
OPTS=$(getopt --options $SHORT --longoptions $LONG -- "$@")
eval set -- "$OPTS"
while :
do
case "$1" in
--public )
filter="| select( .data.commitments.channelFlags.announceChannel == true )"
shift 1
;;
--private )
filter="| select( .data.commitments.channelFlags.announceChannel == false )"
shift 1
;;
--open )
# for getbalance.
# fixme: we need to filter closes that have been swept
filter2="| select( .state != \"ERR_INFORMATION_LEAK\" )"
shift 1
;;
-s | --sortby )
sortby=$2
shift 2
;;
--)
shift;
break
;;
*)
echo "Unexpected option: $1"
;;
esac
done
if [ "$sortby" == "nodeId" ]; then
sort="sort_by( .nodeId ) |"
elif [ "$sortby" == "shortChannelId" ]; then
sort="sort_by( .data.shortIds.real.realScid ) |"
elif [ "$sortby" == "toLocal" ]; then
sort="sort_by( .data.commitments.localCommit.spec.toLocal ) |"
elif [ "$sortby" == "toRemote" ]; then
sort="sort_by( .data.commitments.localCommit.spec.toRemote ) |"
fi
cmd="jq '$sort .[] $filter $filter2'"
$MAINNET_ECLAIR channels | eval $cmd | jq -s