Created
October 11, 2024 15:03
-
-
Save obycode/6daf5c1258ae33fc01910ca6dd778680 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Set your node's API endpoints | |
INFO_URL="http://localhost:20443/v2/info" | |
ACCOUNT_URL="http://localhost:20443/v2/accounts/ST34CYSTX9853GG3TDY4FQZ9FM6F386MT0FHM0DMS?proof=0" | |
# Function to get the current block height | |
get_current_block_height() { | |
curl -s -X GET "$INFO_URL" | jq .burn_block_height | |
} | |
# Function to get the unlock block height | |
get_unlock_block_height() { | |
curl -s -X GET "$ACCOUNT_URL" | jq .unlock_height | |
} | |
# Main loop | |
while true; do | |
current_block=$(get_current_block_height) | |
unlock_block=$(get_unlock_block_height) | |
if [[ -z "$current_block" || -z "$unlock_block" ]]; then | |
echo "Failed to retrieve block heights. Beeping as a warning..." | |
beep -f 1000 -l 500 # Beep with frequency 1000 Hz for 500 ms | |
sleep 60 # Wait for 1 minute before trying again | |
continue | |
fi | |
echo "Current block height: $current_block" | |
echo "Unlock block height: $unlock_block" | |
blocks_remaining=$((unlock_block - current_block)) | |
if [[ $blocks_remaining -le 1000 ]]; then | |
echo "Within 1000 blocks of the unlock block. Starting beep..." | |
echo "Visit https://lockstacks.com/signer/generate-signature?chain=testnet to create signature, then https://lockstacks.com/direct-stacking-info?chain=testnet to stack-extend." | |
while [[ $blocks_remaining -le 1000 ]]; do | |
beep -f 1000 -l 500 # Beep with frequency 1000 Hz for 500 ms | |
sleep 60 # Beep every minute | |
current_block=$(get_current_block_height) | |
unlock_block=$(get_unlock_block_height) | |
blocks_remaining=$((unlock_block - current_block)) | |
done | |
else | |
echo "More than 1000 blocks away from the unlock block. Checking again in 10 minutes..." | |
sleep 60 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment