#2552 adding electrum sync progress to infoscreen (#4603)

* #2552 getting the synced blockheight with nc
* feat: Add blockheight information to electrs status command
* add info in CHANGES
This commit is contained in:
/rootzoll 2024-06-09 22:24:02 +02:00 committed by GitHub
parent 20650fd3e7
commit 0516aa5971
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 31 additions and 19 deletions

View file

@ -5,6 +5,7 @@
- Update: Specter Desktop 2.0.4 with reactivated UPDATE option [details](https://github.com/cryptoadvance/specter-desktop/releases/tag/v2.0.4)
- Update: BTCPayServer 1.13.0 [details](https://github.com/btcpayserver/btcpayserver/releases/tag/v1.13.0)
- Update: acme.sh 3.0.7 (repair duckdns.org dyndns)
- Update: show progress of electrs building index on LCD
- Update: lndmanage 0.16.0 [details](https://github.com/bitromortac/lndmanage)
- Experimental: charge-lnd install script [details](https://github.com/raspiblitz/raspiblitz/discussions/3955)
- Experimental: config.scripts/lnd.signaddress.sh to easy sign messages on addresses on LND [details](https://github.com/raspiblitz/raspiblitz/issues/4540)

View file

@ -355,7 +355,8 @@ else
appInfoLine=""
# Electrum Server - electrs
if [ "${ElectRS}" == "on" ]; then
fileFlagExists=$(sudo ls /mnt/hdd/app-storage/electrs/initial-sync.done 2>/dev/null | grep -c 'initial-sync.done')
if [ "${ElectRS}" == "on" ] && [ $fileFlagExists -eq 0 ]; then
error=""
source <(sudo /home/admin/config.scripts/bonus.electrs.sh status-sync 2>/dev/null)
if [ ${#infoSync} -gt 0 ]; then
@ -364,7 +365,8 @@ else
fi
# Electrum Server - fulcrum
if [ "${fulcrum}" == "on" ]; then
fileFlagExists=$(sudo ls /mnt/hdd/app-storage/fulcrum/initial-sync.done 2>/dev/null | grep -c 'initial-sync.done')
if [ "${fulcrum}" == "on" ] && [ $fileFlagExists -eq 0 ]; then
error=""
source <(sudo /home/admin/config.scripts/bonus.fulcrum.sh status-sync 2>/dev/null)
if [ ${#infoSync} -gt 0 ]; then

View file

@ -105,22 +105,6 @@ if [ "$1" = "status-sync" ]; then
echo "serviceRunning=${serviceRunning}"
if [ ${serviceRunning} -eq 1 ]; then
# Experimental try to get sync Info (electrs debug info would need more details)
#source <(/home/admin/_cache.sh get btc_mainnet_blocks_headers)
#blockchainHeight="${btc_mainnet_blocks_headers}"
#lastBlockchainHeight=$(($blockchainHeight -1))
#syncedToBlock=$(sudo journalctl -u electrs --no-pager -n2000 | grep "height=" | tail -n1| cut -d= -f3)
#syncProgress=0
#if [ "${syncedToBlock}" != "" ] && [ "${blockchainHeight}" != "" ] && [ "${blockchainHeight}" != "0" ]; then
# syncProgress="$(echo "$syncedToBlock" "$blockchainHeight" | awk '{printf "%.2f", $1 / $2 * 100}')"
#fi
#echo "syncProgress=${syncProgress}%"
#if [ "${syncedToBlock}" = "${blockchainHeight}" ] || [ "${syncedToBlock}" = "${lastBlockchainHeight}" ]; then
# echo "tipSynced=1"
#else
# echo "tipSynced=0"
#fi
# check if initial sync was done, by setting a file as once electrs is the first time responding on port 50001
electrumResponding=$(echo '{"jsonrpc":"2.0","method":"server.ping","params":[],"id":"electrs-check"}' | netcat -w 2 127.0.0.1 50001 | grep -c "result")
if [ ${electrumResponding} -gt 1 ]; then
@ -128,6 +112,27 @@ if [ "$1" = "status-sync" ]; then
fi
echo "electrumResponding=${electrumResponding}"
blockheight=0
blockheightPercent=0
if [ ${electrumResponding} -eq 0 ]; then
# get the synced blockheight
syncedBlock=$(echo '{"id": 1, "method": "blockchain.headers.subscribe", "params": []}' | nc -w 20 -q 1 localhost 50001 | jq '.result.height')
if [ "$syncedBlock" -eq "$syncedBlock" ] 2>/dev/null; then
blockheight=${syncedBlock}
# calculate the progress
source <(/home/admin/_cache.sh get btc_mainnet_blocks_verified)
if [ "$btc_mainnet_blocks_verified" -eq "$btc_mainnet_blocks_verified" ] 2>/dev/null; then
blockheightPercent=$(echo "scale=2; $syncedBlock / $btc_mainnet_blocks_verified * 100" | bc)
blockheightPercent=$(printf "%.0f\n" $blockheightPercent)
fi
fi
fi
echo "blockheight='${blockheight}'"
echo "blockheightPercent='${blockheightPercent}'"
fileFlagExists=$(sudo ls /mnt/hdd/app-storage/electrs/initial-sync.done 2>/dev/null | grep -c 'initial-sync.done')
if [ ${fileFlagExists} -eq 0 ] && [ ${electrumResponding} -gt 0 ]; then
# set file flag for the future
@ -137,7 +142,11 @@ if [ "$1" = "status-sync" ]; then
fi
if [ ${fileFlagExists} -eq 0 ]; then
echo "initialSynced=0"
echo "infoSync='Building Index (please wait)'"
if [ "${blockheightPercent}" != "0" ]; then
echo "infoSync='Building Index ${blockheightPercent}% (please wait)'"
else
echo "infoSync='Building Index (please wait)'"
fi
else
echo "initialSynced=1"
fi