diff --git a/src/signer/nip46_client.rs b/src/signer/nip46_client.rs index 44ddf95..0d6ab3d 100644 --- a/src/signer/nip46_client.rs +++ b/src/signer/nip46_client.rs @@ -1305,7 +1305,22 @@ impl Nip46ClientSigner { let message = message.into(); eprintln!("[nip46] session failed: {message}"); eprintln!("[NIP46] session failed: {message}"); - pairing_trace(&format!("session failed: {message}")); + // Forensics-log only LIVE sessions. The e2e harness deliberately + // fails restored sessions (wrong-identity refusal test), and its + // "session failed" lines were landing in pairing-trace.log among + // real ones — three different bogus "restored signer answered as a + // different account" npubs turned out to be test runs, not live + // Amber misbehaviour. Read the relays under a short lock before the + // mutating one below. + let relays = self + .inner + .try_lock() + .ok() + .and_then(|g| g.connection.as_ref().map(|c| c.relays.clone())) + .unwrap_or_default(); + if live_relays(&relays) { + pairing_trace(&format!("session failed: {message}")); + } if let Ok(mut inner) = self.inner.try_lock() { // First failure wins: the demux loop exits with a generic // "Connect handshake failed" AFTER the handshake task already @@ -2328,6 +2343,7 @@ impl Nip46ClientSigner { // UI polls status and vault, so the row fills in a moment later. { let app = self.app.clone(); + let live_enrichment = live_relays(&connection.relays); tokio::spawn(async move { let relays_for_meta = { let app = app.lock().await; @@ -2358,15 +2374,27 @@ impl Nip46ClientSigner { meta = Some(found); break; } - Ok(Ok(None)) => pairing_trace(&format!( - "auto-name attempt {attempt}: no kind-0 found on any relay" - )), - Ok(Err(join_err)) => pairing_trace(&format!( - "auto-name attempt {attempt}: fetch task panicked: {join_err}" - )), - Err(_) => pairing_trace(&format!( - "auto-name attempt {attempt}: fetch timed out (75s budget)" - )), + Ok(Ok(None)) => { + if live_enrichment { + pairing_trace(&format!( + "auto-name attempt {attempt}: no kind-0 found on any relay" + )); + } + } + Ok(Err(join_err)) => { + if live_enrichment { + pairing_trace(&format!( + "auto-name attempt {attempt}: fetch task panicked: {join_err}" + )); + } + } + Err(_) => { + if live_enrichment { + pairing_trace(&format!( + "auto-name attempt {attempt}: fetch timed out (75s budget)" + )); + } + } } if attempt < 4 { tokio::time::sleep(Duration::from_secs(20)).await; @@ -2376,10 +2404,12 @@ impl Nip46ClientSigner { Some(meta) => meta, None => return, }; - pairing_trace(&format!( - "auto-name: kind-0 fetched (display_name={:?} name={:?})", - meta.display_name, meta.name - )); + if live_enrichment { + pairing_trace(&format!( + "auto-name: kind-0 fetched (display_name={:?} name={:?})", + meta.display_name, meta.name + )); + } let mut app = app.lock().await; let mut changed = false; if let Some(row) = app