Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# --- Core ---
NODE_ENV=production
PORT=3000

# --- Database (MariaDB) ---
JAWSDB_MARIA_URL=mysql://gc:CHANGE_ME@127.0.0.1:3306/groundcontrol

# --- JWT (frei wählen, aber lang!) ---
GC_JWT_SECRET=CHANGE_ME_to_super_long_password

# --- Firebase ---
GOOGLE_KEY_FILE=/etc/groundcontrol/firebase-key.json
GOOGLE_PROJECT_ID=bluewallet-gc

# --- Apple Push (DUMMY, aber nötig!) ---
APNS_P8=dummy
APNS_P8_KID=dummy
APPLE_TEAM_ID=dummy
APNS_TOPIC=dummy

# --- Bitcoin Core RPC ---
BITCOIN_RPC=http://<RPC_USERNAME>:<RPC_Password>@<IP>:9332

# optional
VERBOSE=1
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ temp/
# local backups
src/*.bak.*
src/index.ts.bak.*
.env
backups/
*.bak.*
groundcontrol@*
ts-node
22 changes: 22 additions & 0 deletions docs/ops.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# GroundControl Ops Notes

## systemd services
- groundcontrol-api
- groundcontrol-sender
- groundcontrol-mempool
- groundcontrol-blockprocessor

Restart all:
sudo systemctl restart groundcontrol-api groundcontrol-sender groundcontrol-mempool groundcontrol-blockprocessor

Follow logs:
sudo journalctl -u groundcontrol-api -f
sudo journalctl -u groundcontrol-sender -f
sudo journalctl -u groundcontrol-mempool -f
sudo journalctl -u groundcontrol-blockprocessor -f

## DB state
Key used by blockprocessor:
- key_value.LAST_PROCESSED_BLOCK

If confirmations stop, verify it's not ahead of chain tip.
40 changes: 40 additions & 0 deletions scripts/set-last-processed-block.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
set -euo pipefail

MODE="${1:-}"
if [[ -z "$MODE" ]]; then
echo "Usage: $0 tip-2 | <height>"
exit 1
fi

BITCOIN_RPC="$(grep '^BITCOIN_RPC=' .env | cut -d= -f2-)"
if [[ -z "$BITCOIN_RPC" ]]; then
echo "BITCOIN_RPC not found in .env"
exit 1
fi

read -r RPC_USER RPC_PASS RPC_HOST RPC_PORT < <(python3 - <<'PY'
import os
from urllib.parse import urlparse, unquote
u = urlparse(os.environ["BITCOIN_RPC"])
print(unquote(u.username or ""), unquote(u.password or ""), u.hostname or "", str(u.port or 8332))
PY
)

if [[ "$MODE" == "tip-2" ]]; then
H=$(curl -sS --user "$RPC_USER:$RPC_PASS" \
-H 'content-type: text/plain;' \
--data-binary '{"jsonrpc":"1.0","id":"gc","method":"getblockcount","params":[]}' \
"http://$RPC_HOST:$RPC_PORT/" | python3 -c "import sys,json; print(json.load(sys.stdin)['result'])")
TARGET=$((H-2))
else
TARGET="$MODE"
fi

echo "Setting LAST_PROCESSED_BLOCK = $TARGET"
mysql -u gc -p groundcontrol -e "
INSERT INTO key_value (\`key\`, \`value\`)
VALUES ('LAST_PROCESSED_BLOCK', '$TARGET')
ON DUPLICATE KEY UPDATE \`value\`=VALUES(\`value\`);
"
echo "Done."
17 changes: 17 additions & 0 deletions scripts/show-state.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -euo pipefail

echo "== services =="
systemctl --no-pager --full status groundcontrol-api groundcontrol-sender groundcontrol-mempool groundcontrol-blockprocessor | sed -n '1,18p'

echo
echo "== key_value =="
mysql -u gc -p groundcontrol -e "SELECT \`key\`, \`value\` FROM key_value;" || true

echo
echo "== token counts =="
mysql -u gc -p groundcontrol -e "
SELECT 'token_to_address' t, COUNT(*) c FROM token_to_address
UNION ALL SELECT 'token_to_txid' t, COUNT(*) c FROM token_to_txid
UNION ALL SELECT 'token_to_hash' t, COUNT(*) c FROM token_to_hash;
" || true
Loading
Loading