From 8c4900a52fca19f506f1a19834bb5371c1668d93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sun, 7 Jun 2026 22:54:25 +0200 Subject: [PATCH] Prevent ghost nodes during onboarding (#10647) * Prevent ghost nodes during onboarding * Coplilot is exceptionally nit-picky today --- src/mesh/NodeDB.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index ac724e5e0..b047a14a6 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -1989,6 +1989,14 @@ bool NodeDB::saveDeviceStateToDisk() bool NodeDB::saveNodeDatabaseToDisk() { + // Don't persist the node DB until this device has a PKI keypair + // TODO: revisit when https://github.com/meshtastic/firmware/pull/10478 lands +#if !(MESHTASTIC_EXCLUDE_PKI_KEYGEN || MESHTASTIC_EXCLUDE_PKI) + if (owner.public_key.size != 32 && !owner.is_licensed) { + LOG_DEBUG("Skip NodeDB without key"); + return true; + } +#endif // do not try to save anything if power level is not safe. In many cases flash will be lock-protected // and all writes will fail anyway. Device should be sleeping at this point anyway.