-
-
Save exd02/06b3f9455f9b4c66ab228a9550ecba29 to your computer and use it in GitHub Desktop.
| #!/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 ===" |
Just sanity-checking my assumptions: I need to run an unpruned fork of bitcoin core (link plz?) to get those, right?
Just sanity-checking my assumptions: I need to run an unpruned fork of bitcoin core (link plz?) to get those, right?
Yes. Currently you need a fullnode to generate the hintsfile.
You need to build the core from here. (updated to most recent hintsfile generation)
This is my most recent fork for hintsfile generation. Is this what you meant to link?
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!
To create the services:
bitcoin-hints.service:bitcoin-hints.timer:For the web server, you can use miniserve, rob hints-server or directly run it in nginx.