Automate bitcoin sweeps to secure cold storage addresses

Fix cron job redirection to prevent log duplication and ensure transaction sending commands are handled correctly with error checking.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 418bf6f8-212b-4bb0-a7a5-8231a061da4e
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: eebfeaae-fd85-413b-a84e-99224a9b6b98
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/9f85e954-647c-46a5-90a7-396e495a805a/418bf6f8-212b-4bb0-a7a5-8231a061da4e/sPDHkg8
Replit-Helium-Checkpoint-Created: true
This commit is contained in:
alexpaynex
2026-03-18 18:32:15 +00:00
parent 12db06cc26
commit c45625fc98
2 changed files with 8 additions and 3 deletions

View File

@@ -138,7 +138,8 @@ info "Installing cron jobs (daily sweep + daily backup)..."
crontab -l 2>/dev/null | grep -v "timmy-node" | crontab - || true
(crontab -l 2>/dev/null; cat <<'CRON'
# Timmy Node — auto-sweep hot wallet to cold storage (3am UTC daily)
0 3 * * * bash /opt/timmy-node/sweep.sh >> /var/log/timmy-sweep.log 2>&1
# sweep.sh manages its own logging to /var/log/timmy-sweep.log via tee
0 3 * * * bash /opt/timmy-node/sweep.sh > /dev/null 2>&1
# Timmy Node — LND channel state backup (4am UTC daily)
0 4 * * * bash /opt/timmy-node/ops.sh backup >> /var/log/timmy-backup.log 2>&1
CRON

View File

@@ -58,15 +58,19 @@ fi
# ── Send to cold address ─────────────────────────────────────
log "SWEEP — sending ${SWEEP_AMT} sats to ${COLD_ADDRESS}..."
SEND_RESULT=$(docker exec lnd lncli --network=mainnet sendcoins \
if ! SEND_RESULT=$(docker exec lnd lncli --network=mainnet sendcoins \
--addr "$COLD_ADDRESS" \
--amt "$SWEEP_AMT" \
2>&1)
then
log "ERROR — sendcoins failed: $SEND_RESULT"
exit 1
fi
TXID=$(echo "$SEND_RESULT" | jq -r '.txid // empty' 2>/dev/null || echo "")
if [[ -z "$TXID" ]]; then
log "ERROR — sendcoins failed: $SEND_RESULT"
log "ERROR — sendcoins returned no txid: $SEND_RESULT"
exit 1
fi