**Motivations:** - Export Signet and mining wallet backups to git with only 2 versions kept - Document and add backup/restore scripts for signet and mining wallet **Correctifs:** - Backup-to-git uses SSH URL for passwordless cron; copy timestamped files only; prune to 2 versions; remove *-latest from backup repo **Evolutions:** - data/backup-to-git-cron.sh: daily export to git.4nkweb.com/4nk/backup - save-signet-datadir-backup.sh, restore-signet-from-backup.sh, export-mining-wallet.sh, import-mining-wallet.sh - features/backup-to-git-daily-cron.md, docs/MAINTENANCE.md backup section - .gitignore: data/backup-to-git.log **Pages affectées:** - .gitignore, data/backup-to-git-cron.sh, docs/MAINTENANCE.md, features/backup-to-git-daily-cron.md - save-signet-datadir-backup.sh, restore-signet-from-backup.sh, export-mining-wallet.sh, import-mining-wallet.sh - Plus autres fichiers modifiés ou non suivis déjà présents dans le working tree
92 lines
3.0 KiB
Bash
Executable File
92 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Fix dashboard wrong chain and anchor API "Insufficient Balance".
|
|
# Run on the bitcoin machine (192.168.1.105) from the project root.
|
|
#
|
|
# Usage:
|
|
# ./fix-dashboard-anchor-chain.sh
|
|
# Verify, restart Dashboard and Anchor API, run alignment check.
|
|
# ./fix-dashboard-anchor-chain.sh backups/signet-datadir-YYYYMMDD-HHMMSS.tar.gz
|
|
# Restore chain from backup, then verify and restart services.
|
|
#
|
|
# Author: 4NK Team
|
|
# Date: 2026-02-02
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
cd "$SCRIPT_DIR"
|
|
|
|
if [[ ! -f .env ]]; then
|
|
echo "Error: .env not found. Run from project root: $SCRIPT_DIR"
|
|
exit 1
|
|
fi
|
|
|
|
BACKUP_PATH="${1:-}"
|
|
|
|
echo "=== Fix Dashboard / Anchor API chain and balance ==="
|
|
echo "Project root: $SCRIPT_DIR"
|
|
echo ""
|
|
|
|
echo ">>> Testing RPC config (same node as Mempool: 127.0.0.1:38332)..."
|
|
if ! ./test-mempool-rpc-config.sh 127.0.0.1 38332; then
|
|
echo "Error: Node at 127.0.0.1:38332 does not have ~11535 blocks."
|
|
echo "Run this script on the machine where Mempool runs (bitcoin 192.168.1.105)."
|
|
exit 1
|
|
fi
|
|
echo ""
|
|
|
|
if [[ -n "$BACKUP_PATH" ]]; then
|
|
if [[ ! -f "$BACKUP_PATH" ]]; then
|
|
echo "Error: Backup file not found: $BACKUP_PATH"
|
|
exit 1
|
|
fi
|
|
echo ">>> Restoring chain from backup: $BACKUP_PATH"
|
|
./restore-signet-from-backup.sh "$BACKUP_PATH"
|
|
echo ""
|
|
fi
|
|
|
|
echo ">>> Checking Bitcoin Signet container..."
|
|
CONTAINER_NAME="bitcoin-signet-instance"
|
|
if ! docker ps --format "{{.Names}}" | grep -q "^${CONTAINER_NAME}$"; then
|
|
echo "Error: Container $CONTAINER_NAME is not running."
|
|
echo "Start it with the persistent volume (see docs/MAINTENANCE.md)."
|
|
exit 1
|
|
fi
|
|
echo "Container is running."
|
|
echo ""
|
|
|
|
echo ">>> Restarting signet-dashboard and anchorage-api..."
|
|
if systemctl is-active --quiet signet-dashboard 2>/dev/null; then
|
|
sudo systemctl restart signet-dashboard
|
|
echo "signet-dashboard restarted."
|
|
else
|
|
echo "signet-dashboard not managed by systemctl (skip restart)."
|
|
fi
|
|
if systemctl is-active --quiet anchorage-api 2>/dev/null; then
|
|
sudo systemctl restart anchorage-api
|
|
echo "anchorage-api restarted."
|
|
else
|
|
echo "anchorage-api not managed by systemctl (skip restart)."
|
|
fi
|
|
echo ""
|
|
|
|
echo ">>> Waiting 5s for services to start..."
|
|
sleep 5
|
|
echo ""
|
|
|
|
echo ">>> Running chain alignment check..."
|
|
./verify-chain-alignment.sh
|
|
echo ""
|
|
|
|
echo ">>> Node wallet info (check balance):"
|
|
BITCOIN_DATADIR=$(docker exec "$CONTAINER_NAME" printenv BITCOIN_DIR 2>/dev/null || echo "/root/.bitcoin")
|
|
sudo docker exec "$CONTAINER_NAME" bitcoin-cli -datadir="$BITCOIN_DATADIR" getwalletinfo 2>/dev/null | grep -E '"walletname"|"balance"|"immature_balance"' || echo "(could not get walletinfo)"
|
|
echo ""
|
|
|
|
echo "Done. If the dashboard still shows wrong chain or anchor API returns Insufficient Balance:"
|
|
echo " - Ensure Dashboard and Anchor API run on the bitcoin machine (192.168.1.105)."
|
|
echo " - If chain was lost, restore from backup: ./fix-dashboard-anchor-chain.sh backups/signet-datadir-YYYYMMDD-HHMMSS.tar.gz"
|
|
echo " - See fixKnowledge/dashboard-anchor-wrong-chain-insufficient-balance.md"
|
|
echo ""
|