aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorpablomartin4btc <pablomartin4btc@gmail.com>2024-08-21 12:52:52 -0300
committerpablomartin4btc <pablomartin4btc@gmail.com>2024-08-21 12:52:52 -0300
commit5b4f34006dbd76223b55b156421f87d2241ac296 (patch)
tree8e14a0643d1e05eef528c385cac8118443df7719 /contrib
parent60b816439eb4bd837778d424628cd3978e0856d9 (diff)
devtools, utxo-snapshot: Fix block height out of range
Handle the Block height out of range error gracefully by checking if the node has synchronized to or beyond the required block height, otherwise without this validation the node would keep the network disabled if the user selected that option. Provide a user-friendly message if the block height is out of range and exit the script cleanly.
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/devtools/utxo_snapshot.sh10
1 files changed, 10 insertions, 0 deletions
diff --git a/contrib/devtools/utxo_snapshot.sh b/contrib/devtools/utxo_snapshot.sh
index fbb8591965..e8781d94d9 100755
--- a/contrib/devtools/utxo_snapshot.sh
+++ b/contrib/devtools/utxo_snapshot.sh
@@ -36,6 +36,16 @@ if (( GENERATE_AT_HEIGHT < PRUNED )); then
exit 1
fi
+# Check current block height to ensure the node has synchronized past the required block
+CURRENT_BLOCK_HEIGHT=$(${BITCOIN_CLI_CALL} getblockcount)
+PIVOT_BLOCK_HEIGHT=$(( GENERATE_AT_HEIGHT + 1 ))
+
+if (( PIVOT_BLOCK_HEIGHT > CURRENT_BLOCK_HEIGHT )); then
+ (>&2 echo "Error: The node has not yet synchronized to block height ${PIVOT_BLOCK_HEIGHT}.")
+ (>&2 echo "Please wait until the node has synchronized past this block height and try again.")
+ exit 1
+fi
+
# Early exit if file at OUTPUT_PATH already exists
if [[ -e "$OUTPUT_PATH" ]]; then
(>&2 echo "Error: $OUTPUT_PATH already exists or is not a valid path.")