GNAI-024: Litecoin Cold-Wallet-LXC CT 114 (ltc-node) — Ansible-Projekt, Doku, Restore-Test PASS #23

Open
spektr wants to merge 13 commits from lxc/ct-114-gnai-024-litecoin-wallet into main
5 changed files with 385 additions and 33 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ jeweiligen Fachdokumenten. Die priorisierte weitere Umsetzung beschreibt der
| [CT 101 / GNAI-017](platform/proxmox-server/lxc/ct-101-samba/GNAI-017-PLAN_Samba-NFS-Export.md) | Samba-Dateiserver `10.0.0.9`: Aufnahme ins Repository, NFS-Export und Encoding-Shares |
| [CT 101 / GNAI-018](platform/proxmox-server/lxc/ct-101-samba/GNAI-018-REQ_Encoding-Pipeline-Integration.md) | Requirements der Encoding-Pipeline an CT 101 — Übergabe an den Ansible-Rebuild |
| [CT 101 / GNAI-019](platform/proxmox-server/lxc/ct-101-samba/GNAI-019-DEC_Ansible-Migration.md) | Entwurfsentscheidungen der CT-101-Ansible-Migration: natives Samba, NFS-Ganesha als Quadlet, Fresh-State-Rebuild |
| [CT 114 / GNAI-024](platform/proxmox-server/lxc/ct-114-litecoin-wallet/GNAI-024-PLAN_Litecoin-Wallet-LXC.md) | geplanter Litecoin-Wallet-LXC `ltc-node` (`10.0.0.61`): Prüfung der Research-Dokumente, Tor-only Cold Node, Ansible-Projekt und Provisioning — noch nicht angelegt (Plan 25.11.2026) |
| [CT 114 / GNAI-024](platform/proxmox-server/lxc/ct-114-litecoin-wallet/GNAI-024-PLAN_Litecoin-Wallet-LXC.md) | Litecoin-Wallet-LXC `ltc-node` (`10.0.0.61`): live seit 2026-11-27, Vollsync + Phase 0/1 PASS, PR #23 offen; Bedienung siehe [GNAI-024 HowTo](platform/proxmox-server/lxc/ct-114-litecoin-wallet/GNAI-024-HOWTO_Litecoin-Node-Bedienung.md) |
### KI und Deployment
@@ -0,0 +1,142 @@
# GNAI-024 HowTo: Litecoin-Node CT 114 (`ltc-node`) bedienen
Nachschlage-Anleitung für den Betreiber. **Keine Secrets** — Passphrasen, restic-Passwort
und Private Keys gehören ausschließlich in den Bitwarden/Vaultwarden, niemals in dieses
Repo, in Logs oder in Chat.
- Node: CT 114 `ltc-node`, `10.0.0.61`, litecoind v0.21.5.8, Wallet `cold` (verschlüsselt)
- Plan/Hintergründe: [GNAI-024-PLAN_Litecoin-Wallet-LXC.md](GNAI-024-PLAN_Litecoin-Wallet-LXC.md)
- Alle Befehle mit `<...>`-Platzhaltern einsetzen; Passphrasen **immer via `-stdin`**
(nie als Kommandozeilen-Argument, sonst landet sie in Host-`ps`/Logs).
## 1. Zugang — wer darf was
| Zweck | Zugang | Beispiel |
|---|---|---|
| Read-only-Abfragen (Agent) | `ssh -F ~/.ssh/config ghostnet-ct114-agent 'sudo /usr/local/bin/ltc-readonly <cmd>'` | `... ltc-readonly getbalance` |
| Wallet-Operationen (Betreiber) | als root@pve: `pct exec 114 -- sudo -u litecoin /opt/litecoin/bin/litecoin-cli -conf=/etc/litecoin/litecoin.conf <cmd>` | siehe unten |
| Admin/Logs (Betreiber) | `pct exec 114 -- systemctl status litecoind` / `journalctl -u litecoind -n 50` | |
| PVE-Side (Snapshots/Storage) | `ssh -F ~/.ssh/config ghostnet-pve-ansible-deploy 'sudo -n pct listsnapshot 114'` | |
RPC läuft **nur auf 127.0.0.1:9332** mit Cookie-Auth und ist nur per SSH-Exec erreichbar —
kein Port-Forwarding (ist eh deaktiviert), kein Öffnen von 9332/9333 nach außen.
## 2. Häufig genutzte Befehle
### 2.1 Status (read-only, als Agent von der Workstation)
```bash
R='ssh -F ~/.ssh/config ghostnet-ct114-agent sudo /usr/local/bin/ltc-readonly'
$R getblockchaininfo # Sync-Status (initialblockdownload, blocks, headers)
$R getblockcount # aktueller Block
$R getbalance # Guthaben (gelocktes Wallet reicht)
$R getwalletinfo # unlocked_until: 0 = gelockt
$R listtransactions # eigene Tx (nie öffentliche Explorer nutzen!)
$R getpeerinfo # Peers (alle outbound via Tor, 0 inbound)
$R getnetworkinfo # Netze: alle proxy=127.0.0.1:9050, localaddresses leer
```
### 2.2 Empfangsadresse erzeugen (frische Adresse pro Einzahlung!)
```bash
pct exec 114 -- sudo -u litecoin /opt/litecoin/bin/litecoin-cli -conf=/etc/litecoin/litecoin.conf getnewaddress "<label>" "bech32"
# Label ist lokal (z. B. "Bitpanda-Test 2026-12-01") und landet NICHT on-chain.
```
### 2.3 Senden (Betreiber, als root@pve — Passphrase via stdin)
```bash
CLI='pct exec 114 -- sudo -u litecoin /opt/litecoin/bin/litecoin-cli -conf=/etc/litecoin/litecoin.conf'
# WICHTIG: litecoin-cli 0.21.5.8 liest -stdin als ROHZEILEN (kein JSON!) —
# Args ohne Anführungszeichen übergeben (Befund o). Ausnahme: eine Passphrase,
# die früher mit Quotes gespeichert wurde (s. u.).
# 1) Wallet kurz öffnen (Passphrase + Timeout in Sekunden, Rohzeilen)
printf '%s\n60\n' '<PASSPHRASE>' | $CLI -stdin walletpassphrase
# 2) Gebühr schätzen (optional)
$CLI estimatesmartfee 6
# 3) Senden (Adresse + Betrag als Rohzeilen)
printf '%s\n%s\n' '<empfaenger-adresse>' '<betrag>' | $CLI -stdin sendtoaddress
# 4) Sofort wieder sperren
$CLI walletlock
```
### 2.4 Passphrase ändern (Rotation)
```bash
printf '%s\n%s\n' '<ALT>' '<NEU>' | pct exec 114 -- sudo -u litecoin /opt/litecoin/bin/litecoin-cli -conf=/etc/litecoin/litecoin.conf -stdin walletpassphrasechange
# danach: neues Passwort in Bitwarden speichern, altes löschen; Lock-Status prüfen:
ssh -F ~/.ssh/config ghostnet-ct114-agent 'sudo /usr/local/bin/ltc-readonly getwalletinfo' # unlocked_until: 0
```
**Hinweis Passphrase (Befund o):** `-stdin` liest Rohzeilen. Wurde die Passphrase
früher mit `"..."` eingegeben, ist sie **inkl. Anführungszeichen** gespeichert —
dann einmalig rotieren: `printf '%s\n%s\n' '"ALT-mit-quotes"' 'NEU-ohne-quotes' | ... -stdin walletpassphrasechange`,
danach Bitwarden auf `NEU-ohne-quotes` aktualisieren und immer Rohzeilen nutzen.
### 2.5 Manuelles Wallet-Backup + restic (normalerweise Timer täglich 03:00)
```bash
pct exec 114 -- systemctl start litecoin-wallet-backup.service # backupwallet + restic push
# restic-Snapshots ansehen (als root im CT):
pct exec 114 -- /usr/bin/restic snapshots -r sftp:gn-backup@10.0.0.90:/var/lib/ghostnet-ai-backup/ct114/restic \
-o 'sftp.command=ssh -F /etc/litecoin-backup/ssh_config gn-backup@10.0.0.90 -s sftp' \
--password-file /etc/litecoin-backup/restic-password
```
### 2.6 Betrieb/Monitoring
```bash
pct exec 114 -- systemctl list-timers # backup 03:00, snapshot 04:00 (PVE), restic check monatlich
pct exec 114 -- systemctl status litecoind tor fail2ban
pct exec 114 -- df -h / # daten4-Füllstand
ssh -F ~/.ssh/config ghostnet-pve-ansible-deploy 'sudo -n pct listsnapshot 114'
ssh -F ~/.ssh/config ghostnet-pve-ansible-deploy 'sudo -n pvesm status daten4'
ssh -F ~/.ssh/config ghostnet-pve-ansible-deploy 'sudo -n lvs -o lv_name,data_percent pve/data' # NVMe-Pool
```
## 3. Best Practices: sicher mit LTC umgehen
- **Frische Adresse pro Einzahlung:** `getnewaddress` vor jedem Empfang. Die Blockchain ist
öffentlich — wiederverwendete Adressen verknüpfen alle Tx einer Adresse dauerhaft.
- **Nie eigene Adressen in öffentlichen Blockexplorern nachschlagen** — nutze
`ltc-readonly listtransactions` / `getbalance` auf dem Node.
- **Adressen immer doppelt prüfen:** Beim Empfang an die eigene Node `getaddressinfo <adr>`
→ `ismine: true`. Beim Versand an externe Ziele Adresse visuell + per Copy aus vertrauenswürdiger
Quelle; erst kleiner Testbetrag an neue Empfänger, dann Rest.
- **Nur bech32 (`ltc1…`) an Exchanges** (Bitpanda etc.). **Nie MWEB-Adressen (`ltcmweb1…`)**
an Exchanges senden — MWEB nur zwischen eigenen Wallets (Cake Wallet peg-in/peg-out).
- **Wallet immer gelockt lassen** (`unlocked_until: 0`); nur zum Senden kurz via
`walletpassphrase <pass> <sekunden>` öffnen und sofort `walletlock`. Ohne Passphrase
kann niemand senden (Phase-4-Test: `walletlock` → `sendtoaddress` schlägt fehl).
- **Passphrase:** nur in Bitwarden/Vaultwarden; nie in Repo/Logs/Chat/Kommandozeile
(deshalb überall `-stdin`); ohne `"` und `\` wählen; bei Verdacht sofort rotieren
(`walletpassphrasechange`) und Backup-Passwort (restic) separat behandeln.
- **Backups (3-2-1):** restic täglich off-host nach ghostnet-ki (client-seitig verschlüsselt,
Passwort nur in Bitwarden, liegt als Datei nur root-only auf dem CT), PVE-Snapshot täglich
04:00 auf daten4 (Retention 7), Seed/Metall-Backup physisch. Restore regelmäßig testen:
`proxmox/lxc/ct-114-litecoin-wallet/scripts/phase1-restore-test.sh` (unattended, Log in /tmp).
- **Node-Härtung nicht aufweichen:** kein `listen=1`, keine Portfreigaben (auch nicht
„zum Debuggen"), kein Port-Forwarding, SSH nur per Key, Tor-only P2P. Der Node ist von außen
nicht als Litecoin-Node erkennbar (0 inbound, Exit-IP statt unserer IP).
- **Beträge:** immer mit kleinem Testbetrag starten; Gebühr vorher mit `estimatesmartfee` prüfen
(LTC-Gebühren sind winzig).
- **Notfall (Phase 4):** Server aus → Cake Wallet funktioniert unabhängig (eigener Seed).
Handy weg → Seed auf zweitem Gerät wiederherstellen. Wallet gelockt → Senden unmöglich.
## 4. Verbote (nie)
- Keine Secrets in Repo/Logs/Tickets/Chat — auch keine Passphrasen „zum Testen".
- Keine RPC-Ports öffnen, kein `rpcauth`/`rpcpassword` in Dateien, kein SSH-Tunnel.
- Keine eigenen Adressen in öffentlichen Exploern.
- Keine MWEB-Adressen an Exchanges.
- Nicht mit Root-Rechten auf dem CT arbeiten wo vermeidbar; Wallet-OPs als User `litecoin`.
## 5. Troubleshooting (Kurzfassung)
| Symptom | Check |
|---|---|
| `ltc-readonly` meldet „Could not locate RPC credentials" | `-conf=/etc/litecoin/litecoin.conf` fehlt — ohne sucht die cli in `$HOME/.litecoin` (Befund in GNAI-024) |
| Sync hängt | `getblockchaininfo.initialblockdownload`, Peers via Tor-Exit churnen normal; Tor `Bootstrapped 100%` prüfen |
| Platte voll | `df -h /` im CT; Chain wächst ~20 GiB/Jahr auf daten4 (2 TiB) — ausreichend |
| Backup-Timer rot | `systemctl status litecoin-wallet-backup.service` + `journalctl -u litecoin-wallet-backup.service` im CT |
| Wallet nach Reboot gesperrt | normal — `unlocked_until: 0` erwartet |
@@ -42,8 +42,12 @@ Backups, Secret-Regeln).
| f) | MWEB: Bitpanda und Rapidgator unterstützen keine MWEB-Adressen; `ltcmweb1…` an eine Exchange wäre Verlust. | Wallet erzeugt nur legacy/bech32-Adressen (`getnewaddress "" "bech32"` → `ltc1…`). MWEB bleibt lokal nutzbar (Cake Wallet), wird aber nie an Exchanges/Dienste adressiert. Dokumentiert in `litecoin.conf` und Abschnitt 8. |
| g) | Research nimmt einen „separaten Proxmox Backup Server im LAN“ an, dessen Zugangsdaten der Betreiber liefert. Im Repo existiert **kein PBS**; das etablierte hostunabhängige Backup-Ziel ist der `gn-backup`-Account auf `ghostnet-ki` (`10.0.0.90`, eigene Hardware, Rolle `pve_lxc_backup_sync` / `gn_backup_receiver`). | Default: restic-Repo `sftp:gn-backup@10.0.0.90:/var/lib/ghostnet-ai-backup/ct114/restic` (Inventar-Variable `litecoin_backup_repository`, clientseitig verschlüsselt — das Ziel sieht nur Ciphertext). Falls der Betreiber doch ein PBS betreibt, genügen die PBS-Zugangsdaten als Inventar-Override. **Offener Punkt 11.1.** |
| h) | Research: LXC-Backup „nur Snapshots, kein vzdump“. Repo-Konvention syncet alle `vzdump-lxc-*`-Archive nach ghostnet-ki (`pve_lxc_backup_sync`). | Bewusste, begründete Abweichung: CT 114 wird **nicht** in den vzdump-Job aufgenommen (150 GiB Chain, nächtlich ×4 Archive wären teuer; Chain ist per Neu-Sync rekonstruierbar; `wallet.dat` ist durch restic verschlüsselt **und** durch Snapshots geschützt). Umsetzung: Rolle `pve_lxc_snapshot` (täglich 04:00, 7 Snapshots Retention) + restic aus dem CT. **Operator-Schritt:** CT 114 im PVE-Backup-Job ausschließen (Abschnitt 6, Phase 0). |
| i) | Ressourcen 2 vCPU / 4 GiB / 150 GiB rootfs auf SSD/NVMe. | Übernommen; `local-lvm` (thin, snapshotfähig). Preflight im Provisioning-Skript: `local-lvm` aktiv und ≥ 214 GiB frei. Kein Nesting nötig (kein Podman; `litecoind` als systemd-Service unter User `litecoin`). |
| i) | Ressourcen 2 vCPU / 4 GiB / 150 GiB rootfs auf SSD/NVMe. | **Korrigiert:** Chain Ende 2026 real ~165 GiB (Befund l), daher rootfs auf `daten4` (7,3 TiB SSD) statt NVMe-thin-pool — entlastet `local-lvm` um ~144 GiB (Befund m). Provisioning: 300 GiB auf `daten4`, Preflight: Storage aktiv und ≥ 332 GiB frei. Kein Nesting nötig (kein Podman; `litecoind` als systemd-Service unter User `litecoin`). |
| k) | Research: `onlynet=onion` (P2P ausschließlich zu onion-Peers). Live geprüft 2026-11-27: die kompilierten onion-Seeds von v0.21.5.8 sind alle unerreichbar („host unreachable“ via Tor), während clearnet-via-Tor funktioniert (check.torproject.org via SOCKS: IsTor=true; duckduckgo-onion: HTTP 301). Der Node bliebe ohne Peers. | **Anpassung:** `onlynet=onion` entfällt; mit `proxy=127.0.0.1:9050` geht ALLER Verkehr (DNS-Seeds, clearnet-Peers via Tor-Exits, onion) durch Tor — unsere IP wird nie exponiert, `listen=0`/`discover=0` verhindern Inbound. Audit prüft: jedes Netzwerk hat proxy=127.0.0.1:9050, keine inbound Peers. |
| l) | Schätzung Chain ~60–90 GiB (2026-11-27). Live 2026-11-28: Platte voll bei 140/147 GiB, Node stoppte sauber („Disk space is too low!“). Chain bei Block 2,57 Mio bereits 132 GiB → real ~165 GiB am Tip. | **rootfs 150 → 300 GiB** (`pct resize 114 rootfs 300G` + `resize2fs` lief über pct automatisch), thin pool `pve/data` per `lvextend -l +100%FREE` auf 364,82 GiB (79 %). Backup-Lauf 03:00 fiel wegen Node-Down aus, manuell nachgeholt (restic: 2 Snapshots). Künftig: Pool-Füllstand im GNMON-Monitoring (Abschnitt 11), `thin_pool_autoextend_threshold` auf PVE lässt sich als Frühwarnung setzen. |
| m) | 2026-11-28: NVMe-thin-pool `local-lvm` bei 80 % (CT 103/107/304 bereits bei 98–99 %), CT-114-rootfs nach Befund l auf 300 GiB — Kette wächst aber weiter (~165 GiB + ~20 GiB/Jahr). Leer stehendes 8-TB-Volume `daten4` (7,3 TiB SSD, btrfs, PVE-Storage mit `content rootdir,images`) vorhanden. | **rootfs nach `daten4` verschoben:** CT gestoppt, `pct move-volume 114 rootfs daten4` (148,8 GiB via rsync, exit 0), `pct resize 114 rootfs 2T`, alte LVs (`vm-114-disk-0` + 2 Snap-LVs) nach Verifikation per `lvremove` freigegeben → Pool `pve/data` von 79 % auf **39 %** gefallen. Snapshot-Support auf daten4 verifiziert (`pct snapshot`/`delsnapshot` getestet; Timer-Rolle `pve_lxc_snapshot` unverändert). CT bootet von daten4, Node synct weiter (Block 2.503.309/3.220.549), Wallet gelockt. Provisioning-Skript: `CONTAINER_STORAGE='daten4'`. |
| n) | 2026-11-28: RAM (4 GiB) und Swap (1 GiB) des CT voll — litecoind RSS 3,8 GiB, Peak 3,9 GiB + ~1 GiB Swap während IBD (Ursache: `dbcache=2048` + UTXO-/Blockindex-Validierung; keine OOM-Kills, Node lief stabil). PVE-Host hat 22 GiB available. | **memory 4096 → 8192, swap 1024 → 2048** live via `pct set 114 -memory 8192 -swap 2048` (sofort wirksam, cgroup-Limit). danach 3,8 GiB RAM frei, 1 GiB Swap frei. Provisioning-Skript (var_ram/var_swap + Checks) und Doku aktualisiert. `dbcache=2048` bleibt während IBD (schnelle Validierung); nach Sync optional auf 1024 senken (Folgepunkt Abschnitt 11). |
| o) | 2026-12-01: `sendtoaddress` via `-stdin` mit JSON-gequoteten Args schlug fehl (-5 „Invalid Litecoin address: "MS8…"“). Live-Test am Node: litecoin-cli 0.21.5.8 liest `-stdin` als **Rohzeilen**, Quotes landen im Argument. | **Konsequenz:** alle `-stdin`-Args roh (`printf '%s\n…'`). Die früher mit `"%s"` gesetzte Wallet-Passphrase ist inkl. Quotes gespeichert — einmalig auf raw rotieren (HowTo §2.4), Bitwarden aktualisieren. HowTo §2.3/§2.4 korrigiert. Bitpanda-Einzahlungsadresse `MS8pbiT5…` ist valides P2SH (M-Präfix, `a914…`), vom Node per `getaddressinfo` bestätigt. |
| j) | Debian 13, unprivileged, Key-Only-SSH, fail2ban, unattended-upgrades, dedizierter User `litecoin`. | Übernommen nach Repo-Muster: frischer CT per gepinntem Community-Scripts-`debian.sh` + Bootstrap-Hook (wie CT 102, GNAI-016 Phase D), dann Ansible (`litecoin_lxc_baseline`, `litecoin_access`, `litecoin_fail2ban`, …). `unattended-upgrades` auf Debian-Security eingeschränkt (CT-100/101/102-Konvention). |
## 3. Zielarchitektur
@@ -53,7 +57,7 @@ Backups, Secret-Regeln).
| CT-ID / Hostname | `114` / `ltc-node` |
| IP | `10.0.0.61/24` (statischer Serverbereich bis `.99`; DHCP ab `.100`), GW `10.0.0.1`, DNS `10.0.0.14` (Pi-hole), vmbr0, IPv6 aus |
| OS / Typ | Debian 13, unprivileged, onboot, protection |
| Ressourcen | 2 vCPU, 4096 MiB RAM, 1024 MiB Swap, 150 GiB rootfs `local-lvm` |
| Ressourcen | 2 vCPU, **8192 MiB RAM, 2048 MiB Swap** (Befund n), rootfs auf **`daten4`** (7,3 TiB SSD, btrfs): 300 GiB bei Provisioning, live auf **2 TiB** gewachsen (Befund m) |
| Software | `litecoind` v0.21.5.8 in `/opt/litecoin` (Symlink), `tor` (Client-only, SOCKS 127.0.0.1:9050), nftables, fail2ban, unattended-upgrades, restic |
| Node-Konfig | `proxy=127.0.0.1:9050` (alle Netze, Befund k), `listen=0`, `dnsseed=0`, `upnp=0`, `natpmp=0`, RPC `127.0.0.1:9332` Cookie-Auth, `wallet=cold`, `dbcache=2048` |
| Firewall | nftables default-deny; nur SSH 22 aus LAN/WireGuard; kein Forwarding |
@@ -173,6 +177,8 @@ getnetworkinfo, getpeerinfo, getwalletinfo, listtransactions, …).
aus restic zurückspielen, `walletpassphrase` → fertig. Restore-Test
vor dem ersten nennenswerten Betrag (Abschnitt 10, Phase 1).
[HowTo Bedienung (häufige Befehle, Best Practices)](GNAI-024-HOWTO_Litecoin-Node-Bedienung.md)
## 10. Abnahmetests (aus `litecoin-lxc-tests.txt`, an Repo-Verfahren angepasst)
- **Phase 0 (vor dem ersten Euro):** Node gesynct (`initialblockdownload:
@@ -270,20 +276,20 @@ getnetworkinfo, getpeerinfo, getwalletinfo, listtransactions, …).
restic-Passwort wurde **on-target** generiert
(`/etc/litecoin-backup/restic-password`, 0600) — Operator holt es einmal
per Konsole und legt es im Vaultwarden ab.
- **Speicherbudget (gemessen 2026-11-27):** rootfs 147 GiB, belegt 3,1 GiB
(Blockdateien sparse preallokiert). Prognose Vollsync: Chain ~60–90 GiB +
chainstate ~5–10 GiB → datadir < 100 GiB, passt in die 150 GiB. restic
sichert nur `backups/` (wallet.dat ~2,2 MiB/Tag → ~1 GiB/Jahr auf
ghostnet-ki, client-seitig verschlüsselt); PVE-Snapshots (Retention 7)
wachsen um den täglichen Chain-Zuwachs. RAM: litecoind-Peak ~2,5 GiB
(dbcache=2048) innerhalb der 4 GiB.
- **Speicherbudget (final gemessen 2026-11-30 nach Vollsync, Befunde l+m):** rootfs
auf `daten4` (7,3 TiB SSD), live 2 TiB, datadir 253 GiB (`size_on_disk`)
→ daten4 gesamt 356 GiB / 7,3 TiB (5 %). Chain wächst ~20 GiB/Jahr →
Jahrzehnte Platz. NVMe-Pool `local-lvm` durch den Move von 79 % auf 39 %
entlastet. restic sichert nur `backups/` (wallet.dat ~2–5 MiB/Tag → ~1 GiB/Jahr
auf ghostnet-ki); PVE-Snapshots (Retention 7) liegen als btrfs-Subvolumes auf
daten4. RAM: 8 GiB (Befund n), litecoind-Peak ~3,9 GiB während IBD,
steady state nach Sync deutlich darunter.
- PVE-Host: `pve_lxc_snapshot` aktiv, erster Snapshot
`ghostnet-daily-20261127-072519`, Timer täglich 04:00 (Retention 7).
vzdump: kein Cluster-Backup-Job vorhanden, der CT 114 fassen würde
(`pvesh get /cluster/backup` leer) — Befund h damit erledigt.
- Wallet `cold` per `createwallet` angelegt; **`encryptwallet` ist der
nächste Operator-Schritt** (exakter Befehl siehe „Noch offen“) — bis
dahin darf kein Betrag auf den Node.
- Wallet `cold` per `createwallet` angelegt und per `encryptwallet`
verschlüsselt (Operator, 2026-11-27; verifiziert: `getwalletinfo.unlocked_until: 0`).
- Fixes unterwegs (alle gecommitt): awk-END-Falle im Storage-Gate, sed traf
die Hook-Guard-Zeile (Pin aktualisiert), delegate_to-Tasks brauchen
become: false, Debian 13 hat kein torctl (Journal statt Dateilog),
@@ -293,13 +299,49 @@ getnetworkinfo, getpeerinfo, getwalletinfo, listtransactions, …).
- **2026-11-27 (Operator erledigt):** `pct exec 114 -- passwd ghost` gesetzt;
restic-Passwort aus `/etc/litecoin-backup/restic-password` geholt und im
Vaultwarden abgelegt.
- **Noch offen (Operator, manuelle Eingabe):** `encryptwallet` mit Passphrase
— Daemon läuft mit `-conf=/etc/litecoin/litecoin.conf -datadir=/var/lib/litecoin`,
Cookie unter `/var/lib/litecoin/.cookie`; die cli braucht daher **explizit
`-conf=/etc/litecoin/litecoin.conf`** (sonst sucht sie in
`$HOME/.litecoin` und findet kein Cookie). Passphrase via `-stdin`, nie als
argv (sonst in Host-`ps`/Logs); `-stdin` liest eine JSON-gequotete Zeile:
`printf '"%s"\n' '<passphrase>' | pct exec 114 -- sudo -u litecoin /opt/litecoin/bin/litecoin-cli -conf=/etc/litecoin/litecoin.conf -stdin encryptwallet`
danach `pct exec 114 -- systemctl restart litecoind`. FRITZ!Box-Check (kein
Forward auf 10.0.0.61); Abnahmetests Abschnitt 10 (Restore-Test vor erstem
Betrag); PR gegen main.
- **2026-11-28 (erledigt):** `encryptwallet` via `-stdin` mit `-conf=/etc/litecoin/litecoin.conf`
(Daemon-datadir `/var/lib/litecoin`, Cookie `/var/lib/litecoin/.cookie`; ohne
`-conf` sucht die cli in `$HOME/.litecoin` und findet kein Cookie — Befund in
Doku), danach `systemctl restart litecoind`. Verifiziert: `unlocked_until: 0`.
Befunde l (Disk-full → rootfs 300 GiB), m (Move nach daten4, 2 TiB, Pool 79→39 %),
n (RAM/Swap voll während IBD → 8 GiB/2 GiB) umgesetzt und dokumentiert.
- **2026-11-30 — Vollsync abgeschlossen, Phase 0 (agent-seitig) grün:**
blocks = headers = 3.222.167, `initialblockdownload: false`, progress 1.0,
Chain on disk 253 GiB; 10 Peers, 0 inbound; Wallet gelockt, balance 0;
`verify-production.yml` ok=27 changed=0, `audit-production.yml` ok=23 changed=0;
restic 4 Snapshots auf ghostnet-ki (täglich 03:00); PVE-Timer-Snapshots als
btrfs-Subvolumes auf daten4 (20261129, 20261130); stale local-lvm-Snapshot-Metadata
aus `114.conf` entfernt (Backup `114.conf.bak-20261130`).
- **2026-11-30 (Operator + Agent):** FRITZ!Box-Check bestanden (keine Forwards auf
10.0.0.61). Portscan von der Workstation (10.0.0.155, LAN) gegen 10.0.0.61,
alle 65535 Ports: **nur 22 offen**, 0 refused, Rest filtered (nftables DROP) —
exakt wie konfiguriert.
- **2026-12-01 — Phase 1 (Restore-Test) PASS, unattended** (Skript
`scripts/phase1-restore-test.sh`, Log `/tmp/ct114-phase1-restore-test.log`):
frisches `backupwallet`+restic (Snapshot `86acb8a1…`), `restic check` clean,
Restore der wallet.dat sha256-identisch zur lokalen Backup-Kopie
(`4ade8012…`), `pct clone` von Snapshot `ghostnet-daily-20261201-040031` auf
Scratch-CT 199 (10.0.0.91), restic-wallet.dat im Scratch eingespielt (sha256
proof), litecoind startet damit, **hdseedid match** `9228fdbd…` mit Live-Node,
Wallet lädt verschlüsselt+gelockt (`unlocked_until: 0`), Scratch-CT danach
zerstört. Skript-Fixes unterwegs: ssh-Arg-quoting (restic sftp.command als
einzelner Remote-String), Glob-Expansion in 0700-litecoin-dir (find statt
ls-glob), neueste Backup-Generation wählen (sort|tail), pct unlock 114 im
Preflight, Swap-sha256 als Pass-Kriterium.
- **2026-12-01:** PR #23 gegen main eröffnet
(git.ghostnet.selfhost.eu/ghostnet.ai/infrastructure/pulls/23); alle 4
statischen CI-Jobs lokal grün. Empfangsadresse erzeugt:
`ltc1qnf452shz8lz52yy53cf33rs297lt7gavzerfd0` (bech32).
- **2026-12-01 — Phase 2a PASS:** Passphrase rotiert (`walletpassphrasechange`, alt
abgelehnt, neu in Bitwarden); Bitpanda-Auszahlung 0.0505 LTC auf
`ltc1qnf452shz8lz52yy53cf33rs297lt7gavzerfd0` empfangen als **0.05 LTC, 6
Bestätigungen** (txid `7bc24d30…`, Watcher-Log `/tmp/ct114-watch.log`).
- **2026-12-01 — Phase 2b PASS:** Passphrase auf raw-stdin rotiert (Befund o);
Rückversand Node → Bitpanda auf `MS8pbiT5azP9hHgwiBd3n4xnBy8VeMWdWp` (P2SH, validiert)
mit **0.027 LTC** gesendet (txid `d1bdbee7…`, Fee 0.0000142), Wallet danach wieder
gelockt (`unlocked_until: 0`); Balance 0.02298580 LTC. Receive-Tx 113 Conf;
Send-Tx 7 Conf und **von Bitpanda gutgeschrieben** (Operator bestätigt) —
Roundtrip Bitpanda↔Node komplett.
`-stdin` liest Rohzeilen — Senden/Unlock ab jetzt ohne Quotes (HowTo §2.3/§2.4).
- **Noch offen (Operator, vor Merge von PR #23):** Phase 2c/2d (Cake Wallet Roundtrip,
Rapidgator-Testzahlung; nur `ltc1…`-bech32 an Exchanges, nie MWEB); danach Merge PR #23.
@@ -0,0 +1,168 @@
#!/bin/bash
# GNAI-024 Abschnitt 10, Phase 1: unattended restore test for CT 114.
# Run on the operator workstation (needs ~/.ssh aliases ghostnet-pve-ansible-deploy
# and ghostnet-ct114-ansible-deploy). No secrets are read or logged: the restic
# password stays on CT 114, the wallet passphrase is NOT needed for this test
# (wallet is only checked loaded + hdseedid; the passphrase unlock stays an
# operator step on the live node).
#
# Steps:
# 1. fresh backupwallet + restic backup on CT 114, note restic snapshot ID
# 2. restic check (metadata + 5% data) on the off-host repo
# 3. restic restore of the wallet into /tmp on CT 114, sha256 vs. local backup copy
# 4. pct clone CT 114 from its latest snapshot into a scratch CT (10.0.0.91)
# 5. replace the scratch wallet.dat with the restic-restored file, boot litecoind,
# compare getwalletinfo.hdseedid with the live node
# 6. destroy the scratch CT, clean temp files, print PASS/FAIL summary
set -uo pipefail
LOG="${LOG:-/tmp/ct114-phase1-restore-test.log}"
exec > >(tee -a "$LOG") 2>&1
SSHOPTS=(-o BatchMode=yes -o ControlMaster=no)
PVE=(ssh -F ~/.ssh/config "${SSHOPTS[@]}" ghostnet-pve-ansible-deploy sudo -n)
CT=(ssh -F ~/.ssh/config "${SSHOPTS[@]}" ghostnet-ct114-ansible-deploy sudo -n)
CTSSH=(ssh -F ~/.ssh/config "${SSHOPTS[@]}" ghostnet-ct114-ansible-deploy)
SCRATCH_ID=199
SCRATCH_IP=10.0.0.91 # static range <= .99; .91 verified free 2026-11-30
SKEY=~/.ssh/id_ed25519_ghostnet_ct114_ansible_deploy
SOPTS=(-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o BatchMode=yes -o ControlMaster=no -i "$SKEY" -o ConnectTimeout=5)
SCRATCH=(ssh -F /dev/null "${SOPTS[@]}" "ansible-deploy@${SCRATCH_IP}")
FAILURES=()
note() { echo "[phase1] $*"; }
pass() { echo "[phase1] PASS: $*"; }
fail() { echo "[phase1] FAIL: $*"; FAILURES+=("$*"); }
RESTIC_REPO='sftp:gn-backup@10.0.0.90:/var/lib/ghostnet-ai-backup/ct114/restic'
# single remote command string: the inner single quotes protect the sftp.command
# value from the remote shell re-splitting (ssh argv join pitfall)
ct_restic() {
"${CTSSH[@]}" "sudo -n /usr/bin/restic $* -r '$RESTIC_REPO' -o 'sftp.command=ssh -F /etc/litecoin-backup/ssh_config gn-backup@10.0.0.90 -s sftp' --password-file /etc/litecoin-backup/restic-password"
}
note "=== GNAI-024 Phase 1 restore test started $(date -Is) ==="
# --- 0. preflight: scratch ID/IP free -------------------------------------
if "${PVE[@]}" pct list | awk '{print $1}' | grep -qx "$SCRATCH_ID"; then
fail "CTID $SCRATCH_ID already in use"; else pass "CTID $SCRATCH_ID free"; fi
if ping -c1 -W1 "$SCRATCH_IP" >/dev/null 2>&1; then
fail "IP $SCRATCH_IP answers ping"; else pass "IP $SCRATCH_IP free"; fi
[ ${#FAILURES[@]} -eq 0 ] || { echo "PHASE1 RESULT: FAIL (preflight)"; exit 1; }
# a previously interrupted clone can leave a lock on the source CT
"${PVE[@]}" pct unlock 114 2>/dev/null || true
# --- 1. fresh wallet backup + restic snapshot on CT 114 -------------------
note "step 1: backupwallet + restic backup on CT 114"
"${CT[@]}" systemctl start litecoin-wallet-backup.service
rc=$?
if [ $rc -eq 0 ] && ! "${CT[@]}" systemctl is-failed litecoin-wallet-backup.service >/dev/null 2>&1; then
pass "litecoin-wallet-backup.service succeeded (rc=0, not failed)"
else
fail "litecoin-wallet-backup.service rc=$rc or failed state"
fi
SNAP_JSON=$(ct_restic snapshots --json --latest 1)
SNAP_ID=$(python3 -c 'import json,sys; print(json.load(sys.stdin)[0]["id"])' <<<"$SNAP_JSON" 2>/dev/null || true)
note "restic snapshot: $SNAP_ID"
[ -n "$SNAP_ID" ] && pass "restic snapshot $SNAP_ID exists" || { fail "no restic snapshot"; echo "PHASE1 RESULT: FAIL"; exit 1; }
# --- 2. restic check on the off-host repo ----------------------------------
note "step 2: restic check"
if ct_restic check --read-data-subset=5% >/dev/null 2>&1; then
pass "restic check clean"
else
fail "restic check reported problems"
fi
# --- 3. restore wallet from restic on CT 114, compare sha256 ---------------
note "step 3: restic restore + sha256 comparison"
"${CT[@]}" rm -rf /tmp/restore-test
ct_restic restore "$SNAP_ID" --target /tmp/restore-test >/dev/null
RESTORED=$("${CT[@]}" find /tmp/restore-test -name 'wallet-*' -type f | sort | tail -1)
[ -n "$RESTORED" ] && pass "restored file: $RESTORED" || fail "no wallet file in restic restore"
# find (not ls-glob): backups/ is 0700 litecoin, so the remote login shell cannot
# expand a glob there; sudo find runs as root and the quoted -name reaches find intact
LOCAL_BAK=$("${CT[@]}" find /var/lib/litecoin/backups -maxdepth 1 -name 'wallet-*' | sort | tail -1)
[ -n "$LOCAL_BAK" ] || fail "no local backup wallet file found"
H_R=$("${CT[@]}" sha256sum "$RESTORED" </dev/null | awk '{print $1}')
H_L=$("${CT[@]}" sha256sum "$LOCAL_BAK" </dev/null | awk '{print $1}')
[ -n "$H_R" ] && [ "$H_R" = "$H_L" ] && pass "sha256 match restic vs local backup ($H_R)" || fail "sha256 mismatch: '$H_R' vs '$H_L'"
# stage the restored wallet on the workstation for the scratch CT
"${CTSSH[@]}" "sudo -n cat $RESTORED" > /tmp/ct114-wallet-restored
[ -s /tmp/ct114-wallet-restored ] && pass "wallet file staged locally ($(stat -c%s /tmp/ct114-wallet-restored) bytes)" || fail "staging failed"
# --- 4. live wallet facts + clone scratch CT from latest snapshot ----------
note "step 4: live hdseedid + pct clone to scratch CT $SCRATCH_ID"
LIVE_HD=$("${CT[@]}" /opt/litecoin/bin/litecoin-cli -conf=/etc/litecoin/litecoin.conf getwalletinfo | python3 -c 'import json,sys; print(json.load(sys.stdin)["hdseedid"])')
note "live hdseedid: $LIVE_HD"
SNAPNAME=$("${PVE[@]}" pct listsnapshot 114 | awk '/ghostnet-daily/{s=$2} END{print s}')
note "cloning from snapshot $SNAPNAME"
"${PVE[@]}" pct clone 114 "$SCRATCH_ID" --snapname "$SNAPNAME"
clone_rc=$?
if "${PVE[@]}" pct list | awk '{print $1}' | grep -qx "$SCRATCH_ID"; then
pass "clone created (rc=$clone_rc; CT $SCRATCH_ID exists)"
else
fail "pct clone failed (rc=$clone_rc, no CT)"
fi
"${PVE[@]}" pct set "$SCRATCH_ID" -hostname ltc-restore-test -protection 0 \
-net0 "name=eth0,bridge=vmbr0,gw=10.0.0.1,ip=${SCRATCH_IP}/24,type=veth" \
-memory 4096 -swap 1024 \
&& pass "scratch CT configured ($SCRATCH_IP)" || fail "pct set failed"
"${PVE[@]}" pct start "$SCRATCH_ID" && pass "scratch CT started" || fail "pct start failed"
BOOTED=0
for i in $(seq 1 30); do
if "${SCRATCH[@]}" -o ConnectTimeout=3 true 2>/dev/null; then BOOTED=1; break; fi
sleep 5
done
[ "$BOOTED" = 1 ] && pass "scratch CT ssh reachable" || fail "scratch CT ssh unreachable"
# --- 5. swap in the restic-restored wallet, boot litecoind, compare --------
if [ "$BOOTED" = 1 ]; then
note "step 5: wallet swap + hdseedid comparison in scratch CT"
cat /tmp/ct114-wallet-restored | "${SCRATCH[@]}" sudo -n tee /tmp/wallet-restored >/dev/null
RSIZE=$("${SCRATCH[@]}" sudo -n stat -c%s /tmp/wallet-restored 2>/dev/null || echo 0)
[ "$RSIZE" = "$(stat -c%s /tmp/ct114-wallet-restored)" ] && pass "wallet staged on scratch ($RSIZE bytes)" || fail "staging on scratch failed (rsize=$RSIZE)"
"${SCRATCH[@]}" sudo -n systemctl stop litecoind
for i in $(seq 1 24); do
"${SCRATCH[@]}" sudo -n systemctl is-active litecoind 2>/dev/null | grep -qx inactive && break
sleep 5
done
# individual steps; the sha256 check below is the pass criterion for the swap
"${SCRATCH[@]}" sudo -n cp /var/lib/litecoin/cold/wallet.dat /var/lib/litecoin/cold/wallet.dat.pretest
"${SCRATCH[@]}" sudo -n cp /tmp/wallet-restored /var/lib/litecoin/cold/wallet.dat
"${SCRATCH[@]}" sudo -n chown litecoin:litecoin /var/lib/litecoin/cold/wallet.dat
"${SCRATCH[@]}" sudo -n chmod 600 /var/lib/litecoin/cold/wallet.dat
SWAP_H=$("${SCRATCH[@]}" sudo -n sha256sum /var/lib/litecoin/cold/wallet.dat </dev/null | awk '{print $1}')
STAGE_H=$(sha256sum /tmp/ct114-wallet-restored | awk '{print $1}')
[ "$SWAP_H" = "$STAGE_H" ] && pass "scratch wallet.dat == restic-restored file ($SWAP_H)" || fail "swap landed wrong content: $SWAP_H vs $STAGE_H"
"${SCRATCH[@]}" sudo -n systemctl start litecoind
RPC_OK=0
for i in $(seq 1 40); do
if "${SCRATCH[@]}" sudo -n /opt/litecoin/bin/litecoin-cli -conf=/etc/litecoin/litecoin.conf getwalletinfo >/dev/null 2>&1; then RPC_OK=1; break; fi
sleep 5
done
[ "$RPC_OK" = 1 ] && pass "litecoind up in scratch with restored wallet" || fail "litecoind did not come up in scratch"
if [ "$RPC_OK" = 1 ]; then
SCRATCH_HD=$("${SCRATCH[@]}" sudo -n /opt/litecoin/bin/litecoin-cli -conf=/etc/litecoin/litecoin.conf getwalletinfo | python3 -c 'import json,sys; d=json.load(sys.stdin); print(d.get("hdseedid",""))')
[ "$SCRATCH_HD" = "$LIVE_HD" ] && pass "hdseedid match: $SCRATCH_HD" || fail "hdseedid mismatch: scratch='$SCRATCH_HD' live='$LIVE_HD'"
ENC=$("${SCRATCH[@]}" sudo -n /opt/litecoin/bin/litecoin-cli -conf=/etc/litecoin/litecoin.conf getwalletinfo | python3 -c 'import json,sys; d=json.load(sys.stdin); print(d.get("unlocked_until"))')
[ "$ENC" = "0" ] && pass "restored wallet loads encrypted+locked (unlocked_until=0)" || fail "restored wallet not locked (unlocked_until=$ENC)"
fi
fi
# --- 6. cleanup -------------------------------------------------------------
note "step 6: cleanup"
"${PVE[@]}" pct stop "$SCRATCH_ID" 2>/dev/null
"${PVE[@]}" pct destroy "$SCRATCH_ID" && pass "scratch CT $SCRATCH_ID destroyed" || fail "scratch destroy failed"
"${CT[@]}" rm -rf /tmp/restore-test
rm -f /tmp/ct114-wallet-restored
echo
if [ ${#FAILURES[@]} -eq 0 ]; then
echo "PHASE1 RESULT: PASS — snapshot clone + off-host restic restore + wallet load verified (hdseedid match, encrypted/locked)"
else
echo "PHASE1 RESULT: FAIL — ${#FAILURES[@]} failure(s):"
printf ' - %s\n' "${FAILURES[@]}"
fi
echo "[phase1] === end $(date -Is), log: $LOG ==="
@@ -10,8 +10,8 @@ readonly GATEWAY='10.0.0.1'
readonly NAMESERVER='10.0.0.14'
readonly BRIDGE='vmbr0'
readonly TEMPLATE_STORAGE='local'
readonly CONTAINER_STORAGE='local-lvm'
readonly ROOT_DISK_GIB='150'
readonly CONTAINER_STORAGE='daten4'
readonly ROOT_DISK_GIB='300'
readonly POST_INSTALL_HOOK='/usr/local/sbin/ghostnet-litecoin-ansible-bootstrap-hook.sh'
readonly BASELINE_HOOK='/usr/local/sbin/ghostnet-lxc-baseline.sh'
@@ -94,9 +94,9 @@ storage_is_active "$TEMPLATE_STORAGE" ||
die "template storage ${TEMPLATE_STORAGE} is not active"
storage_is_active "$CONTAINER_STORAGE" ||
die "container storage ${CONTAINER_STORAGE} is not active"
# The Litecoin chain needs roughly 100 GB plus growth on top of the thin
# 150 GiB rootfs; require headroom for rootfs plus chain before creating.
# (2026-11-27: local-lvm has ~206 GiB free, so +32 GiB headroom is the gate.)
# The Litecoin chain needs ~165 GiB (2026-11) plus growth; the rootfs lives on
# daten4 (7.3 TiB SSD btrfs, see GNAI-024 Befund m) — require headroom for the
# rootfs before creating. (2026-11-28: daten4 has ~7 TiB free.)
storage_has_free "$CONTAINER_STORAGE" $((ROOT_DISK_GIB + 32)) ||
die "container storage ${CONTAINER_STORAGE} has less than $((ROOT_DISK_GIB + 32)) GiB free"
@@ -133,7 +133,7 @@ require_file_sha256 "$DEBIAN_SCRIPT_SHA256" "$helper_path"
export COMMUNITY_SCRIPTS_URL COMMUNITY_SCRIPTS_CORE_URL
export mode='generated'
export var_cpu='2'
export var_ram='4096'
export var_ram='8192'
export var_disk="$ROOT_DISK_GIB"
export var_ctid="$CTID"
export var_hostname="$HOSTNAME"
@@ -163,12 +163,12 @@ pct config "$CTID" >/dev/null 2>&1 ||
die "helper returned without creating CT ${CTID}"
# Community Scripts does not currently expose an LXC swap variable.
pct set "$CTID" --swap 1024
pct set "$CTID" --swap 2048
config="$(pct config "$CTID")"
grep -qx 'cores: 2' <<<"$config" || die 'unexpected CPU allocation'
grep -qx 'memory: 4096' <<<"$config" || die 'unexpected memory allocation'
grep -qx 'swap: 1024' <<<"$config" || die 'unexpected swap allocation'
grep -qx 'memory: 8192' <<<"$config" || die 'unexpected memory allocation'
grep -qx 'swap: 2048' <<<"$config" || die 'unexpected swap allocation'
grep -qx 'hostname: ltc-node' <<<"$config" || die 'unexpected hostname'
grep -qx 'nameserver: 10.0.0.14' <<<"$config" || die 'unexpected nameserver'
grep -qx 'onboot: 1' <<<"$config" || die 'onboot is not enabled'
@@ -177,7 +177,7 @@ grep -qx 'unprivileged: 1' <<<"$config" || die 'container is not unprivileged'
grep -qx 'timezone: Europe/Berlin' <<<"$config" || die 'unexpected timezone'
grep -Eq '^features: .*nesting=0' <<<"$config" || die 'nesting is not disabled'
grep -Eq '^features: .*keyctl=0' <<<"$config" || die 'keyctl is not disabled'
grep -Eq '^rootfs: local-lvm:.*,size=150G(,|$)' <<<"$config" ||
grep -Eq '^rootfs: daten4:.*size=300G(,|$)' <<<"$config" ||
die 'unexpected root filesystem allocation'
net0="$(grep '^net0: ' <<<"$config")"
for expected_net_field in \