-
Notifications
You must be signed in to change notification settings - Fork 10
/
check-synced.sh
30 lines (27 loc) · 1.17 KB
/
check-synced.sh
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
#!/bin/bash
b_type=$(yq e '.bitcoind.type' /root/.lightning/start9/config.yaml)
b_host="bitcoind.embassy"
b_username=$(yq e '.bitcoin-user' /root/.lightning/start9/config.yaml)
b_password=$(yq e '.bitcoin-password' /root/.lightning/start9/config.yaml)
c_username=$(yq e '.rpc.user' /root/.lightning/start9/config.yaml)
c_password=$(yq e '.rpc.password' /root/.lightning/start9/config.yaml)
b_gbc_result=$(bitcoin-cli -rpcconnect=$b_host -rpcuser=$b_username -rpcpassword=$b_password getblockcount)
error_code=$?
if [ $error_code -ne 0 ]; then
echo $b_gbc_result >&2
exit $error_code
fi
c_gi_result=$(lightning-cli getinfo)
error_code=$?
if [ $error_code -ne 0 ]; then
exit 60
fi
warning_lightningd_sync=$(echo "$c_gi_result" | yq e '.warning_lightningd_sync' -)
if [ "$warning_lightningd_sync" = "null" ]; then
exit 0
else
# blockheight=$(echo "$c_gi_result" | yq e '.blockheight' -)
blockheight=$(lightning-cli getlog debug | yq '.log[] | select (.log == "Adding block*")' - | tail -n1 | yq '.log' | cut -d " " -f 3 | tr -d ':')
echo "Catching up to blocks from bitcoind. This may take several hours. Progress: $blockheight of $b_gbc_result blocks" >&2
exit 61
fi