Last active
March 10, 2026 17:55
-
-
Save exd02/06b3f9455f9b4c66ab228a9550ecba29 to your computer and use it in GitHub Desktop.
This script is intended to run periodically via a systemd timer (e.g., once per week) to generate updated Bitcoin UTXO hints.
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
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| umask 022 | |
| BITCOINCLI="$HOME/dev/bitcoin/build/bin/bitcoin-cli" | |
| HINT_DIR="$HOME/hints" | |
| NEW_HINT_DIR="$HOME/hints_new" | |
| echo "=== $(date) starting generatetxohints ===" | |
| # 1) Check RPC and extract blockchain info | |
| BLOCKCHAININFO_OUTPUT=$("$BITCOINCLI" getblockchaininfo 2>&1) || { | |
| echo "ERROR: bitcoind not reachable via RPC" >&2 | |
| exit 1 | |
| } | |
| CHAIN_NAME=$(echo "$BLOCKCHAININFO_OUTPUT" | grep '"chain"' | sed 's/.*"chain": *"\([^"]*\)".*/\1/') | |
| BLOCK_HEIGHT=$(echo "$BLOCKCHAININFO_OUTPUT" | grep '"blocks"' | sed 's/.*"blocks": *\([0-9]*\).*/\1/') | |
| BEST_BLOCK_HASH=$(echo "$BLOCKCHAININFO_OUTPUT" | grep '"bestblockhash"' | sed 's/.*"bestblockhash": *"\([^"]*\)".*/\1/') | |
| HASH_SUFFIX="${BEST_BLOCK_HASH: -8}" | |
| FINAL_HINT="$NEW_HINT_DIR/${CHAIN_NAME}_${BLOCK_HEIGHT}_${HASH_SUFFIX}.hints" | |
| VERSIONED_HINT_GZ="$HINT_DIR/${CHAIN_NAME}_${BLOCK_HEIGHT}_${HASH_SUFFIX}.hints.gz" | |
| LATEST_HINT_GZ="$HINT_DIR/${CHAIN_NAME}.hints.gz" | |
| echo "Chain: $CHAIN_NAME | Block: $BLOCK_HEIGHT | Hash suffix: $HASH_SUFFIX" | |
| # 2) Ensure new hints directory exists | |
| rm -rf "$NEW_HINT_DIR" | |
| mkdir -p "$NEW_HINT_DIR" | |
| chmod 755 "$NEW_HINT_DIR" | |
| echo "Cleaned up $NEW_HINT_DIR" | |
| # 3) Generate hints in hints_new directory | |
| if "$BITCOINCLI" --rpcclienttimeout=0 generatetxohints "$FINAL_HINT"; then | |
| echo "Generation finished successfully" | |
| # 4) Ensure hints directory exists | |
| mkdir -p "$HINT_DIR" | |
| chmod 755 "$HINT_DIR" | |
| # 5) Create versioned copy | |
| gzip -c "$FINAL_HINT" > "$VERSIONED_HINT_GZ" | |
| chmod 644 "$VERSIONED_HINT_GZ" | |
| echo "Created versioned hints: $VERSIONED_HINT_GZ" | |
| # 6) Replace latest copy | |
| rm -f "$LATEST_HINT_GZ" | |
| cp "$VERSIONED_HINT_GZ" "$LATEST_HINT_GZ" | |
| chmod 644 "$LATEST_HINT_GZ" | |
| echo "Updated latest hints: $LATEST_HINT_GZ" | |
| else | |
| echo "ERROR: Hints generation failed" >&2 | |
| exit 1 | |
| fi | |
| echo "=== $(date) finished ===" |
Author
This is my most recent fork for hintsfile generation. Is this what you meant to link?
Author
This is my most recent fork for hintsfile generation. Is this what you meant to link?
@rustaceanrob Currently I'm generating the hintsfile from the SwiftSync PR. I assumed Floresta was still using that hintsfile format for experiments, so I linked that one.
Do you think I should generate the hintsfile using the newer version you linked instead?
Oh I see, certainly do what is best for Floresta, I was just making sure you had the most up to date branch!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes. Currently you need a fullnode to generate the hintsfile.
You need to build the core from here. (updated to most recent hintsfile generation)