[Infra] Auto-Sweep to Cold Storage #51

Closed
opened 2026-03-21 00:42:13 +00:00 by replit · 1 comment
Owner

What & Why

Add an automatic sweep script to the node infrastructure that monitors the LND on-chain wallet balance and sends any excess above a configurable threshold to a user-provided cold Bitcoin address. Every sweep also triggers a channel state backup.

Done looks like

  • infrastructure/sweep.sh exists and can be run manually or by cron
  • sweep.conf holds: cold address, keep threshold (default 300 K sats), minimum sweep floor (default 50 K sats)
  • infrastructure/lnd-init.sh prompts for a cold address during node setup and writes it into sweep.conf
  • infrastructure/setup.sh installs two cron jobs: daily sweep at 3am, daily backup at 4am
  • infrastructure/ops.sh gains a sweep command showing current config, wallet balance, and last sweep log
  • All sweep transactions appended to /var/log/timmy-sweep.log with timestamp, amount, txid
  • If no cold address configured, sweep.sh exits cleanly with a warning

Out of scope

  • Lightning channel balance rebalancing
  • Fee estimation tuning (uses LND default fee rate)
  • Multi-address sweep targets
  • Web UI for configuring sweep

Tasks

  1. Write sweep.sh — Read sweep.conf, query LND on-chain balance via lncli walletbalance, calculate sweep amount, send via lncli sendcoins, log txid. Trigger ops.sh backup after successful sweep.
  2. Wire into setup and init — Update lnd-init.sh to prompt for cold address + write sweep.conf. Update setup.sh to install both cron jobs and copy sweep.sh to /opt/timmy-node/.
  3. Add sweep command to ops.shbash ops.sh sweep: show config (address, thresholds), current on-chain balance, last 5 lines of sweep log.

Relevant files

  • infrastructure/setup.sh
  • infrastructure/lnd-init.sh
  • infrastructure/ops.sh
## What & Why Add an automatic sweep script to the node infrastructure that monitors the LND on-chain wallet balance and sends any excess above a configurable threshold to a user-provided cold Bitcoin address. Every sweep also triggers a channel state backup. ## Done looks like - `infrastructure/sweep.sh` exists and can be run manually or by cron - `sweep.conf` holds: cold address, keep threshold (default 300 K sats), minimum sweep floor (default 50 K sats) - `infrastructure/lnd-init.sh` prompts for a cold address during node setup and writes it into `sweep.conf` - `infrastructure/setup.sh` installs two cron jobs: daily sweep at 3am, daily backup at 4am - `infrastructure/ops.sh` gains a `sweep` command showing current config, wallet balance, and last sweep log - All sweep transactions appended to `/var/log/timmy-sweep.log` with timestamp, amount, txid - If no cold address configured, `sweep.sh` exits cleanly with a warning ## Out of scope - Lightning channel balance rebalancing - Fee estimation tuning (uses LND default fee rate) - Multi-address sweep targets - Web UI for configuring sweep ## Tasks 1. **Write sweep.sh** — Read `sweep.conf`, query LND on-chain balance via `lncli walletbalance`, calculate sweep amount, send via `lncli sendcoins`, log txid. Trigger `ops.sh backup` after successful sweep. 2. **Wire into setup and init** — Update `lnd-init.sh` to prompt for cold address + write `sweep.conf`. Update `setup.sh` to install both cron jobs and copy `sweep.sh` to `/opt/timmy-node/`. 3. **Add sweep command to ops.sh** — `bash ops.sh sweep`: show config (address, thresholds), current on-chain balance, last 5 lines of sweep log. ## Relevant files - `infrastructure/setup.sh` - `infrastructure/lnd-init.sh` - `infrastructure/ops.sh`
replit added the lightning label 2026-03-21 00:42:13 +00:00
claude was assigned by Rockachopa 2026-03-22 23:37:26 +00:00
Collaborator

PR #76 created. All issue requirements were already implemented in the codebase (sweep.sh with static/xpub/list modes, lnd-init.sh cold address prompt, setup.sh cron jobs, ops.sh sweep command). This PR adds a sweep.conf.example template for documentation, copies it during setup, and removes a redundant state file reload in sweep.sh.

PR #76 created. All issue requirements were already implemented in the codebase (sweep.sh with static/xpub/list modes, lnd-init.sh cold address prompt, setup.sh cron jobs, ops.sh sweep command). This PR adds a `sweep.conf.example` template for documentation, copies it during setup, and removes a redundant state file reload in sweep.sh.
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: replit/timmy-tower#51