mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-10 00:16:59 +00:00
Mirrors Android's NamecoinSharedPreferences pinned-cert API on Desktop so user-accepted TLS pins survive process restart. Same JSON-list shape, same distinct-append semantics, same wipe-on-reset behaviour. What's new - DesktopNamecoinPreferences gains addPinnedCert / loadPinnedCerts / clearPinnedCerts (sync rather than suspend, since java.util.prefs is synchronous). reset() now clears pinned certs too, matching Android. - DesktopNamecoinNameService accepts a pinnedCertsProvider and pushes the loaded list into ElectrumXClient.setDynamicCerts at init, mirroring Android's AppModules.kt wiring. Exposes the underlying client so the Settings UI can call testServer() and re-apply pins live. - Desktop NamecoinSettingsSection grows an optional Test Connection + TOFU pin sub-section: runs ElectrumXClient.testServer per active server, collects PEM + SHA-256 fingerprint from successful TLS handshakes, and prompts the user to pin each new cert via AlertDialog. UI hidden when no service is wired (so existing call sites stay valid). - Main.kt wires both halves together and updates the freshly-pinned cert list into the live client without waiting for restart. Persistence is plain java.util.prefs (same backing store as the rest of DesktopNamecoinPreferences) — explicitly NOT EncryptedSharedPreferences. Pinned cert PEMs are public material; no secrets stored. Tests - DesktopNamecoinPreferencesTest: +6 cases covering empty default, persistence + reload, dedup, blank input ignored, reset wipes, and independence from settings copies. Verification - ./gradlew :desktopApp:compileKotlin — BUILD SUCCESSFUL - ./gradlew :desktopApp:test — BUILD SUCCESSFUL (16 tests, 0 failures) - ./gradlew :amethyst:compilePlayDebugKotlin — BUILD SUCCESSFUL - ./gradlew :amethyst:spotlessCheck :commons:spotlessCheck :desktopApp:spotlessCheck — BUILD SUCCESSFUL Stack note Stacked behind #3072 (merged 2026-05-27). Next: PR-C for the full Namecoin Core RPC backend + composite fallback persistence + UI.