#!/bin/bash # # Test the RPC configuration that Mempool uses (host.docker.internal:38332 # = host's 127.0.0.1:38332 when Mempool runs in Docker on that host). # Run on the machine where Mempool runs to verify the node has ~11535 blocks; # then align Dashboard, Anchorage and Faucet to the same host:port. # # Usage: ./test-mempool-rpc-config.sh [RPC_HOST] [RPC_PORT] # Default: 127.0.0.1 38332 # Example (node on another machine): ./test-mempool-rpc-config.sh 192.168.1.105 38332 # # Author: 4NK Team # Date: 2026-02-02 set -e RPC_HOST="${1:-127.0.0.1}" RPC_PORT="${2:-38332}" RPC_USER="${BITCOIN_RPC_USER:-bitcoin}" RPC_PASS="${BITCOIN_RPC_PASSWORD:-bitcoin}" EXPECTED_MIN="${EXPECTED_HEIGHT_MIN:-11000}" EXPECTED_MAX="${EXPECTED_HEIGHT_MAX:-12000}" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" TMP_JSON="$SCRIPT_DIR/.test-mempool-rpc-$$.json" trap 'rm -f "$TMP_JSON"' EXIT echo "=== Test Mempool RPC config (same node as Mempool uses) ===" echo "Host: $RPC_HOST Port: $RPC_PORT" echo "" # JSON-RPC getblockchaininfo HTTP_CODE=$(curl -s -o "$TMP_JSON" -w "%{http_code}" \ --user "$RPC_USER:$RPC_PASS" \ --data-binary '{"jsonrpc":"1.0","id":"test","method":"getblockchaininfo","params":[]}' \ -H "content-type: text/plain;" \ "http://${RPC_HOST}:${RPC_PORT}/" 2>/dev/null || echo "000") if [ "$HTTP_CODE" != "200" ]; then echo "FAIL: RPC returned HTTP $HTTP_CODE (node unreachable or auth failed)." exit 1 fi if [ ! -f "$TMP_JSON" ] || ! grep -q '"result"' "$TMP_JSON" 2>/dev/null; then echo "FAIL: RPC response missing result." exit 1 fi CHAIN=$(grep -o '"chain"[[:space:]]*:[[:space:]]*"[^"]*"' "$TMP_JSON" | sed 's/.*:[[:space:]]*"\([^"]*\)".*/\1/') BLOCKS=$(grep -o '"blocks"[[:space:]]*:[[:space:]]*[0-9]*' "$TMP_JSON" | head -1 | grep -o '[0-9]*$') if [ -z "$BLOCKS" ]; then echo "FAIL: Could not parse 'blocks' from getblockchaininfo." exit 1 fi echo "Node: chain=$CHAIN blocks=$BLOCKS" if [ "$CHAIN" != "signet" ]; then echo "WARN: chain is not 'signet' (got '$CHAIN')." fi if [ "$BLOCKS" -ge "$EXPECTED_MIN" ] && [ "$BLOCKS" -le "$EXPECTED_MAX" ]; then echo "OK: Height $BLOCKS is in expected range [$EXPECTED_MIN..$EXPECTED_MAX] (same as Mempool)." echo "" echo "Align Dashboard, Anchorage and Faucet to this node: BITCOIN_RPC_HOST=$RPC_HOST BITCOIN_RPC_PORT=$RPC_PORT" exit 0 else echo "WARN: Height $BLOCKS is outside expected range [$EXPECTED_MIN..$EXPECTED_MAX]." echo " This may not be the node Mempool uses, or the chain is not synced." exit 1 fi