# Bitcoin Wallet Project

## Services (systemd user, auto-start)

| Service | Port | Description |
|---|---|---|
| `btc-rpc-tunnel` | 8332 | SSH tunnel to Bitcoin Core on 10.0.0.60 |
| `btc-wallet-api` | 14195 | Python API backend |
| `btc-wallet-frontend` | 1420 | Vite dev server |

All in `~/.config/systemd/user/`. Enabled on boot. Restart on failure.

## Paths
- Venv: `./wallet-engine/.venv` (Python 3.11)
- Scripts: `scripts/tunnel.sh`, `scripts/api.sh`, `scripts/vite.sh`
- API entry: `wallet-engine/api_server.py`
- Core wallet: `wallet-engine/wallet.py`
- Frontend API: `src/api.ts`

## Network
- Tailscale IP: `100.90.189.104`
- UFW: allows `100.64.0.0/10` to ports `14195`, `1420`
- API binds `0.0.0.0`, CORS enabled (`*`)
- Frontend uses dynamic `getApiUrl()` — no hardcoded `127.0.0.1`

## SSH Tunnel
- Forwards `localhost:8332` → `10.0.0.60:8332` (Bitcoin Core RPC)
- User: `grepples`, password in `scripts/tunnel.sh`
- Uses `sshpass`, auto-reconnect via systemd `Restart=always`

## Key pitfalls
- API depends on SSH tunnel being up first (systemd `After=btc-rpc-tunnel.service`)
- Frontend depends on API (systemd `After=btc-wallet-api.service`)
- Never bind to `127.0.0.1` — always `0.0.0.0` for Tailscale access
- CORS headers required because frontend (1420) ≠ API (14195) ports
- Vite build via terminal falsely detects as long-lived — use `node node_modules/vite/bin/vite.js build`
- Python 3.11 venv required (not 3.13 system Python)