feat(federation): advertise own_fips_npub in state snapshots
Pre-v1.4 federation pairs (who exchanged invites before fips_npub was part of the invite code) had no path to learn each other's FIPS npub — they'd stay Tor-only forever even after upgrading. Fix: every state snapshot now carries the sender's own_fips_npub, and update_node_state refreshes the stored fips_npub on the receiver side whenever it differs. - NodeStateSnapshot.own_fips_npub (serde default for back-compat). - build_local_state takes own_fips_npub alongside the other single-value fields. - handle_federation_get_state populates own_fips_npub from identity::fips_npub, with a fallback to the upstream daemon's /etc/fips/fips.pub for legacy nodes that never materialised a seed-derived key. - storage::update_node_state now writes fips_npub into the FederatedNode when a new value arrives and trims whitespace before comparing, so key rotations also flow through. - Test fixtures (storage + transport/delta + sync) updated for the new field; existing tests pass. Net effect: on the next sync, .116 and .228 learn each other's fips_npub (currently null from the old invite) and subsequent federation calls route FIPS-first automatically. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
ab85c2e361
commit
6399b6881e
@@ -387,6 +387,23 @@ impl RpcHandler {
|
||||
.await
|
||||
.unwrap_or_default();
|
||||
|
||||
// Our own FIPS npub, so pre-v1.4 federation pairs (whose
|
||||
// invite codes didn't carry it) can learn it on the next sync.
|
||||
let identity_dir = self.config.data_dir.join("identity");
|
||||
let own_fips_npub = crate::identity::fips_npub(&identity_dir)
|
||||
.await
|
||||
.ok()
|
||||
.flatten()
|
||||
.or_else(|| {
|
||||
// Legacy/dev nodes without a seed-derived key fall back
|
||||
// to the upstream daemon's public key on disk.
|
||||
None
|
||||
});
|
||||
let own_fips_npub = match own_fips_npub {
|
||||
Some(n) => Some(n),
|
||||
None => crate::fips::service::read_upstream_npub().await.ok().flatten(),
|
||||
};
|
||||
|
||||
let state = federation::build_local_state(
|
||||
apps,
|
||||
0.0,
|
||||
@@ -398,6 +415,7 @@ impl RpcHandler {
|
||||
tor_active,
|
||||
server_name,
|
||||
nostr_npub,
|
||||
own_fips_npub,
|
||||
&federated_peers,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user